Check CreatePeer success before continue

This commit is contained in:
Kusakabe Si 2021-12-11 04:29:19 +00:00
parent 32b674d629
commit fdecd0c45b
7 changed files with 18 additions and 9 deletions

View File

@ -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
device.graph.UpdateLatency(peerinfo.NodeID, device.ID, mtypes.Infinity, 0, device.EdgeConfig.DynamicRoute.AdditionalCost, true, false)
}
device.NewPeer(sk, peerinfo.NodeID, false, 0)
thepeer = device.LookupPeer(sk)
thepeer, err = device.NewPeer(sk, peerinfo.NodeID, false, 0)
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 != "" {
pk, err := Str2PSKey(peerinfo.PSKey)

View File

@ -39,7 +39,7 @@ DynamicRoute:
PSKey: 2eOq1sJlEs3No80xYOaKJ059ElgRaSveyMu9IyQG3X8=
EndpointV4: 127.0.0.1:3456
PubKeyV4: 10CPQrpXKqXxnjtpdxDwnYqLglnuRnCFsiSAjxMrMTc=
EndpointV6: :3456
EndpointV6: ""
PubKeyV6: KhpV1fJ+jtNT6S5wKUZJbb0oFlDNMS5qxO0f5Ow/QQU=
EndpointEdgeAPIUrl: http://127.0.0.1:3456/eg_net/eg_api
SkipLocalIP: false

View File

@ -39,7 +39,7 @@ DynamicRoute:
PSKey: Ye1vd4P8vZWCLmuhYq8yiu1ziB84AGwuO+/cexQObqc=
EndpointV4: 127.0.0.1:3456
PubKeyV4: 10CPQrpXKqXxnjtpdxDwnYqLglnuRnCFsiSAjxMrMTc=
EndpointV6: :3456
EndpointV6: ""
PubKeyV6: KhpV1fJ+jtNT6S5wKUZJbb0oFlDNMS5qxO0f5Ow/QQU=
EndpointEdgeAPIUrl: http://127.0.0.1:3456/eg_net/eg_api
SkipLocalIP: false

View File

@ -156,6 +156,8 @@ func GetExampleEdgeConf(templatePath string, getDemo bool) mtypes.EdgeConfig {
econfig.Peers = []mtypes.PeerInfo{}
econfig.NextHopTable = make(mtypes.NextHopTable)
econfig.DynamicRoute.P2P.GraphRecalculateSetting.ManualLatency = make(mtypes.DistTable)
econfig.DynamicRoute.SuperNode.EndpointV4 = ""
econfig.DynamicRoute.SuperNode.EndpointV6 = ""
}
return econfig
}

View File

@ -261,8 +261,12 @@ func GenSuperCfg(SMCinfigPath string, printExample bool) (err error) {
idstr := fmt.Sprintf("%0"+strconv.Itoa(len(strconv.Itoa(ModeIDmax)))+"d", i)
allec[i] = peerceconf
peerceconf.DynamicRoute.SuperNode.EndpointV4 = EndpointV4 + ":" + ListenPort
peerceconf.DynamicRoute.SuperNode.EndpointV6 = EndpointV6 + ":" + ListenPort
if EndpointV4 != "" {
peerceconf.DynamicRoute.SuperNode.EndpointV4 = EndpointV4 + ":" + ListenPort
}
if EndpointV6 != "" {
peerceconf.DynamicRoute.SuperNode.EndpointV6 = EndpointV6 + ":" + ListenPort
}
peerceconf.DynamicRoute.SuperNode.EndpointEdgeAPIUrl = EndpointEdgeAPIUrl
peerceconf.Interface.MacAddrPrefix = MacPrefix
peerceconf.Interface.IPv4CIDR = IPv4Block

View File

@ -261,7 +261,7 @@ func Edge(configPath string, useUAPI bool, printExample bool, bindmode string) (
mtypes.SdNotify(false, mtypes.SdNotifyReady)
SdNotify, err := mtypes.SdNotify(false, mtypes.SdNotifyReady)
if econfig.LogLevel.LogInternal {
fmt.Printf("Internal: SdNotify:%v err:%v", SdNotify, err)
fmt.Printf("Internal: SdNotify:%v err:%v\n", SdNotify, err)
}
select {

View File

@ -215,7 +215,7 @@ func Super(configPath string, useUAPI bool, printExample bool, bindmode string)
return fmt.Errorf("error parse PostScript %v", err)
}
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:]...)
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)
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)