mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region,baremetal): ipv6 baremetal register support (#23422)
This commit is contained in:
@@ -17,6 +17,7 @@ package agent
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -82,7 +83,14 @@ func (agent *SBaseAgent) GetListenIPs() []net.IP {
|
||||
func (agent *SBaseAgent) FindListenIP(listenAddr string) (net.IP, error) {
|
||||
ips := agent.GetListenIPs()
|
||||
if listenAddr == "" {
|
||||
return ips[0], nil
|
||||
for i := range ips {
|
||||
ipstr := ips[i].String()
|
||||
if strings.HasPrefix(ipstr, netutils2.SECRET_PREFIX) {
|
||||
continue
|
||||
}
|
||||
return ips[i], nil
|
||||
}
|
||||
return nil, fmt.Errorf("Not Address on Interface %#v", agent.ListenInterface)
|
||||
}
|
||||
if listenAddr == "0.0.0.0" {
|
||||
return net.ParseIP(listenAddr), nil
|
||||
@@ -287,6 +295,9 @@ func (agent *SBaseAgent) GetManagerUri() string {
|
||||
if agent.IAgent().GetEnableSsl() {
|
||||
proto = "https"
|
||||
}
|
||||
if accessIP.To4() == nil { // ipv6 addr
|
||||
return fmt.Sprintf("%s://[%s]:%d", proto, accessIP, agent.IAgent().GetPort())
|
||||
}
|
||||
return fmt.Sprintf("%s://%s:%d", proto, accessIP, agent.IAgent().GetPort())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user