diff --git a/device/peer.go b/device/peer.go index 41661ad..86a2646 100644 --- a/device/peer.go +++ b/device/peer.go @@ -476,7 +476,7 @@ func (peer *Peer) SetPSK(psk NoisePresharedKey) { func (peer *Peer) SetEndpointFromConnURL(connurl string, af int, af_perfer int, static bool) error { if peer.device.LogLevel.LogInternal { - fmt.Println("Internal: Set endpoint to " + connurl + " for NodeID:" + peer.ID.ToString()) + fmt.Printf("Internal: Set endpoint to %v for NodeID: %v static:%v\n", connurl, peer.ID.ToString(), static) } var err error _, connIP, err := conn.LookupIP(connurl, af, af_perfer) diff --git a/example_config/super_mode/EgNet_edge001.yaml b/example_config/super_mode/EgNet_edge001.yaml index c6b5886..699d053 100644 --- a/example_config/super_mode/EgNet_edge001.yaml +++ b/example_config/super_mode/EgNet_edge001.yaml @@ -40,7 +40,7 @@ DynamicRoute: PSKey: yl/4SNFee7+kNekajVCrK0toqXJ4mlT4IN0klyAgyqU= EndpointV4: 127.0.0.1:3456 PubKeyV4: 1NS6MxL2LUIlMsppJ5JfHnlofQfCxDUzaItBGwz+jBo= - EndpointV6: "" + EndpointV6: "[::1]:12345" PubKeyV6: gSBwlJH4aUPRfSP4ZHKAnXIkPZuVaEhsLBispLYFiwo= EndpointEdgeAPIUrl: http://127.0.0.1:3456/eg_net/eg_api SkipLocalIP: false diff --git a/main_edge.go b/main_edge.go index d3ab62b..b0b131a 100644 --- a/main_edge.go +++ b/main_edge.go @@ -13,6 +13,7 @@ import ( "os/exec" "os/signal" "strconv" + "strings" "syscall" "github.com/google/shlex" @@ -169,7 +170,16 @@ func Edge(configPath string, useUAPI bool, printExample bool, bindmode string) ( return err } peer.SetPSK(psk) - err = peer.SetEndpointFromConnURL(econfig.DynamicRoute.SuperNode.EndpointV4, 4, 0, true) + StaticSuper := true + sc := econfig.DynamicRoute.SuperNode.EndpointV4 + if strings.Contains(sc, ":") { + i := strings.LastIndex(sc, ":") + sch := sc[:i] + if sch == "127.0.0.1" { + StaticSuper = false + } + } + err = peer.SetEndpointFromConnURL(econfig.DynamicRoute.SuperNode.EndpointV4, 4, 0, StaticSuper) if err != nil { logger.Errorf("Failed to set endpoint for supernode v4 %v: %v", econfig.DynamicRoute.SuperNode.EndpointV4, err) S4 = false @@ -190,7 +200,16 @@ func Edge(configPath string, useUAPI bool, printExample bool, bindmode string) ( return err } peer.SetPSK(psk) - err = peer.SetEndpointFromConnURL(econfig.DynamicRoute.SuperNode.EndpointV6, 6, 0, true) + StaticSuper := true + sc := econfig.DynamicRoute.SuperNode.EndpointV6 + if strings.Contains(sc, ":") { + i := strings.LastIndex(sc, ":") + sch := sc[:i] + if sch == "[::1]" { + StaticSuper = false + } + } + err = peer.SetEndpointFromConnURL(econfig.DynamicRoute.SuperNode.EndpointV6, 6, 0, StaticSuper) if err != nil { logger.Errorf("Failed to set endpoint for supernode v6 %v: %v", econfig.DynamicRoute.SuperNode.EndpointV6, err) S6 = false