diff --git a/main_super.go b/main_super.go index 929ea05..508fbf2 100644 --- a/main_super.go +++ b/main_super.go @@ -266,6 +266,14 @@ func super_peeradd(peerconf mtypes.SuperPeerInfo) error { if peerconf.PSKey != "" { peer4.SetPSK(psk) } + if peerconf.EndPoint != "" { + err = peer4.SetEndpointFromConnURL(peerconf.EndPoint, 4, false) + if err != nil { + if httpobj.http_sconfig.LogLevel.LogInternal { + fmt.Printf("Internal: Set endpoint failed:%v\n", err) + } + } + } } if httpobj.http_sconfig.PrivKeyV6 != "" { var psk device.NoisePresharedKey @@ -283,6 +291,14 @@ func super_peeradd(peerconf mtypes.SuperPeerInfo) error { if peerconf.PSKey != "" { peer6.SetPSK(psk) } + if peerconf.EndPoint != "" { + err = peer6.SetEndpointFromConnURL(peerconf.EndPoint, 6, false) + if err != nil { + if httpobj.http_sconfig.LogLevel.LogInternal { + fmt.Printf("Internal: Set endpoint failed:%v\n", err) + } + } + } } httpobj.http_PeerID2Info[peerconf.NodeID] = peerconf @@ -469,7 +485,7 @@ func PushNhTable(force bool) { copy(buf[path.EgHeaderLen:], body) for pkstr, peerstate := range httpobj.http_PeerState { isAlive := peerstate.LastSeen.Load().(time.Time).Add(mtypes.S2TD(httpobj.http_sconfig.PeerAliveTimeout)).After(time.Now()) - if !isAlive { + if !isAlive && !force { continue } if force || peerstate.NhTableState.Load().(string) != httpobj.http_NhTable_Hash { @@ -502,7 +518,7 @@ func PushPeerinfo(force bool) { copy(buf[path.EgHeaderLen:], body) for pkstr, peerstate := range httpobj.http_PeerState { isAlive := peerstate.LastSeen.Load().(time.Time).Add(mtypes.S2TD(httpobj.http_sconfig.PeerAliveTimeout)).After(time.Now()) - if !isAlive { + if !isAlive && !force { continue } if force || peerstate.PeerInfoState.Load().(string) != httpobj.http_PeerInfo_hash { @@ -520,7 +536,7 @@ func PushServerParams(force bool) { //No lock for pkstr, peerstate := range httpobj.http_PeerState { isAlive := peerstate.LastSeen.Load().(time.Time).Add(mtypes.S2TD(httpobj.http_sconfig.PeerAliveTimeout)).After(time.Now()) - if !isAlive { + if !isAlive && !force { continue } if force || peerstate.SuperParamState.Load().(string) != peerstate.SuperParamStateClient.Load().(string) { diff --git a/mtypes/config.go b/mtypes/config.go index 10e0c6c..007ad8f 100644 --- a/mtypes/config.go +++ b/mtypes/config.go @@ -95,6 +95,7 @@ type SuperPeerInfo struct { PSKey string `yaml:"PSKey"` AdditionalCost float64 `yaml:"AdditionalCost"` SkipLocalIP bool `yaml:"SkipLocalIP"` + EndPoint string `yaml:"EndPoint"` } type LoggerInfo struct {