Ignore static setting for localhost supernode

This commit is contained in:
Kusakabe Si 2021-12-24 13:16:36 +00:00
parent d90fcdbd25
commit d9cccdd96b
3 changed files with 23 additions and 4 deletions

View File

@ -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)

View File

@ -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

View File

@ -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