mirror of
https://github.com/KusakabeShi/EtherGuard-VPN.git
synced 2024-11-25 08:43:08 +01:00
Endpoint option in SuperConfig
This commit is contained in:
parent
b4285d3e5d
commit
ca697b4822
@ -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) {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user