mirror of
https://github.com/KusakabeShi/EtherGuard-VPN.git
synced 2025-07-12 11:55:00 +02:00
Check CreatePeer success before continue
This commit is contained in:
@ -482,8 +482,11 @@ func (device *Device) process_UpdatePeerMsg(peer *Peer, State_hash string) error
|
|||||||
if device.graph.Weight(peerinfo.NodeID, device.ID, false) == mtypes.Infinity { // add node to graph
|
if device.graph.Weight(peerinfo.NodeID, device.ID, false) == mtypes.Infinity { // add node to graph
|
||||||
device.graph.UpdateLatency(peerinfo.NodeID, device.ID, mtypes.Infinity, 0, device.EdgeConfig.DynamicRoute.AdditionalCost, true, false)
|
device.graph.UpdateLatency(peerinfo.NodeID, device.ID, mtypes.Infinity, 0, device.EdgeConfig.DynamicRoute.AdditionalCost, true, false)
|
||||||
}
|
}
|
||||||
device.NewPeer(sk, peerinfo.NodeID, false, 0)
|
thepeer, err = device.NewPeer(sk, peerinfo.NodeID, false, 0)
|
||||||
thepeer = device.LookupPeer(sk)
|
if err != nil {
|
||||||
|
device.log.Errorf("Failed to create peer with ID:%v PunKey:%v :%v", peerinfo.NodeID.ToString(), PubKey, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if peerinfo.PSKey != "" {
|
if peerinfo.PSKey != "" {
|
||||||
pk, err := Str2PSKey(peerinfo.PSKey)
|
pk, err := Str2PSKey(peerinfo.PSKey)
|
||||||
|
@ -39,7 +39,7 @@ DynamicRoute:
|
|||||||
PSKey: 2eOq1sJlEs3No80xYOaKJ059ElgRaSveyMu9IyQG3X8=
|
PSKey: 2eOq1sJlEs3No80xYOaKJ059ElgRaSveyMu9IyQG3X8=
|
||||||
EndpointV4: 127.0.0.1:3456
|
EndpointV4: 127.0.0.1:3456
|
||||||
PubKeyV4: 10CPQrpXKqXxnjtpdxDwnYqLglnuRnCFsiSAjxMrMTc=
|
PubKeyV4: 10CPQrpXKqXxnjtpdxDwnYqLglnuRnCFsiSAjxMrMTc=
|
||||||
EndpointV6: :3456
|
EndpointV6: ""
|
||||||
PubKeyV6: KhpV1fJ+jtNT6S5wKUZJbb0oFlDNMS5qxO0f5Ow/QQU=
|
PubKeyV6: KhpV1fJ+jtNT6S5wKUZJbb0oFlDNMS5qxO0f5Ow/QQU=
|
||||||
EndpointEdgeAPIUrl: http://127.0.0.1:3456/eg_net/eg_api
|
EndpointEdgeAPIUrl: http://127.0.0.1:3456/eg_net/eg_api
|
||||||
SkipLocalIP: false
|
SkipLocalIP: false
|
||||||
|
@ -39,7 +39,7 @@ DynamicRoute:
|
|||||||
PSKey: Ye1vd4P8vZWCLmuhYq8yiu1ziB84AGwuO+/cexQObqc=
|
PSKey: Ye1vd4P8vZWCLmuhYq8yiu1ziB84AGwuO+/cexQObqc=
|
||||||
EndpointV4: 127.0.0.1:3456
|
EndpointV4: 127.0.0.1:3456
|
||||||
PubKeyV4: 10CPQrpXKqXxnjtpdxDwnYqLglnuRnCFsiSAjxMrMTc=
|
PubKeyV4: 10CPQrpXKqXxnjtpdxDwnYqLglnuRnCFsiSAjxMrMTc=
|
||||||
EndpointV6: :3456
|
EndpointV6: ""
|
||||||
PubKeyV6: KhpV1fJ+jtNT6S5wKUZJbb0oFlDNMS5qxO0f5Ow/QQU=
|
PubKeyV6: KhpV1fJ+jtNT6S5wKUZJbb0oFlDNMS5qxO0f5Ow/QQU=
|
||||||
EndpointEdgeAPIUrl: http://127.0.0.1:3456/eg_net/eg_api
|
EndpointEdgeAPIUrl: http://127.0.0.1:3456/eg_net/eg_api
|
||||||
SkipLocalIP: false
|
SkipLocalIP: false
|
||||||
|
@ -156,6 +156,8 @@ func GetExampleEdgeConf(templatePath string, getDemo bool) mtypes.EdgeConfig {
|
|||||||
econfig.Peers = []mtypes.PeerInfo{}
|
econfig.Peers = []mtypes.PeerInfo{}
|
||||||
econfig.NextHopTable = make(mtypes.NextHopTable)
|
econfig.NextHopTable = make(mtypes.NextHopTable)
|
||||||
econfig.DynamicRoute.P2P.GraphRecalculateSetting.ManualLatency = make(mtypes.DistTable)
|
econfig.DynamicRoute.P2P.GraphRecalculateSetting.ManualLatency = make(mtypes.DistTable)
|
||||||
|
econfig.DynamicRoute.SuperNode.EndpointV4 = ""
|
||||||
|
econfig.DynamicRoute.SuperNode.EndpointV6 = ""
|
||||||
}
|
}
|
||||||
return econfig
|
return econfig
|
||||||
}
|
}
|
||||||
|
@ -261,8 +261,12 @@ func GenSuperCfg(SMCinfigPath string, printExample bool) (err error) {
|
|||||||
idstr := fmt.Sprintf("%0"+strconv.Itoa(len(strconv.Itoa(ModeIDmax)))+"d", i)
|
idstr := fmt.Sprintf("%0"+strconv.Itoa(len(strconv.Itoa(ModeIDmax)))+"d", i)
|
||||||
|
|
||||||
allec[i] = peerceconf
|
allec[i] = peerceconf
|
||||||
peerceconf.DynamicRoute.SuperNode.EndpointV4 = EndpointV4 + ":" + ListenPort
|
if EndpointV4 != "" {
|
||||||
peerceconf.DynamicRoute.SuperNode.EndpointV6 = EndpointV6 + ":" + ListenPort
|
peerceconf.DynamicRoute.SuperNode.EndpointV4 = EndpointV4 + ":" + ListenPort
|
||||||
|
}
|
||||||
|
if EndpointV6 != "" {
|
||||||
|
peerceconf.DynamicRoute.SuperNode.EndpointV6 = EndpointV6 + ":" + ListenPort
|
||||||
|
}
|
||||||
peerceconf.DynamicRoute.SuperNode.EndpointEdgeAPIUrl = EndpointEdgeAPIUrl
|
peerceconf.DynamicRoute.SuperNode.EndpointEdgeAPIUrl = EndpointEdgeAPIUrl
|
||||||
peerceconf.Interface.MacAddrPrefix = MacPrefix
|
peerceconf.Interface.MacAddrPrefix = MacPrefix
|
||||||
peerceconf.Interface.IPv4CIDR = IPv4Block
|
peerceconf.Interface.IPv4CIDR = IPv4Block
|
||||||
|
@ -261,7 +261,7 @@ func Edge(configPath string, useUAPI bool, printExample bool, bindmode string) (
|
|||||||
mtypes.SdNotify(false, mtypes.SdNotifyReady)
|
mtypes.SdNotify(false, mtypes.SdNotifyReady)
|
||||||
SdNotify, err := mtypes.SdNotify(false, mtypes.SdNotifyReady)
|
SdNotify, err := mtypes.SdNotify(false, mtypes.SdNotifyReady)
|
||||||
if econfig.LogLevel.LogInternal {
|
if econfig.LogLevel.LogInternal {
|
||||||
fmt.Printf("Internal: SdNotify:%v err:%v", SdNotify, err)
|
fmt.Printf("Internal: SdNotify:%v err:%v\n", SdNotify, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
|
@ -215,7 +215,7 @@ func Super(configPath string, useUAPI bool, printExample bool, bindmode string)
|
|||||||
return fmt.Errorf("error parse PostScript %v", err)
|
return fmt.Errorf("error parse PostScript %v", err)
|
||||||
}
|
}
|
||||||
if sconfig.LogLevel.LogInternal {
|
if sconfig.LogLevel.LogInternal {
|
||||||
fmt.Printf("PostScript: exec.Command(%v)", cmdarg)
|
fmt.Printf("PostScript: exec.Command(%v)\n", cmdarg)
|
||||||
}
|
}
|
||||||
cmd := exec.Command(cmdarg[0], cmdarg[1:]...)
|
cmd := exec.Command(cmdarg[0], cmdarg[1:]...)
|
||||||
out, err := cmd.CombinedOutput()
|
out, err := cmd.CombinedOutput()
|
||||||
@ -229,7 +229,7 @@ func Super(configPath string, useUAPI bool, printExample bool, bindmode string)
|
|||||||
|
|
||||||
SdNotify, err := mtypes.SdNotify(false, mtypes.SdNotifyReady)
|
SdNotify, err := mtypes.SdNotify(false, mtypes.SdNotifyReady)
|
||||||
if sconfig.LogLevel.LogInternal {
|
if sconfig.LogLevel.LogInternal {
|
||||||
fmt.Printf("Internal: SdNotify:%v err:%v", SdNotify, err)
|
fmt.Printf("Internal: SdNotify:%v err:%v\n", SdNotify, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
signal.Notify(term, syscall.SIGTERM)
|
signal.Notify(term, syscall.SIGTERM)
|
||||||
|
Reference in New Issue
Block a user