diff --git a/device/receivesendproc.go b/device/receivesendproc.go index 8a6ffbe..f445ab6 100644 --- a/device/receivesendproc.go +++ b/device/receivesendproc.go @@ -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) diff --git a/example_config/super_mode/EgNet_edge001.yaml b/example_config/super_mode/EgNet_edge001.yaml index b6c28f8..0278423 100644 --- a/example_config/super_mode/EgNet_edge001.yaml +++ b/example_config/super_mode/EgNet_edge001.yaml @@ -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 diff --git a/example_config/super_mode/EgNet_edge002.yaml b/example_config/super_mode/EgNet_edge002.yaml index 775cece..369a1ee 100644 --- a/example_config/super_mode/EgNet_edge002.yaml +++ b/example_config/super_mode/EgNet_edge002.yaml @@ -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 diff --git a/gencfg/example_conf.go b/gencfg/example_conf.go index ccfab57..67885a0 100644 --- a/gencfg/example_conf.go +++ b/gencfg/example_conf.go @@ -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 } diff --git a/gencfg/gencfgSM.go b/gencfg/gencfgSM.go index 28a42bc..bd9faa0 100644 --- a/gencfg/gencfgSM.go +++ b/gencfg/gencfgSM.go @@ -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 diff --git a/main_edge.go b/main_edge.go index 2101da1..4494477 100644 --- a/main_edge.go +++ b/main_edge.go @@ -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 { diff --git a/main_super.go b/main_super.go index 4fb619e..3daa9c8 100644 --- a/main_super.go +++ b/main_super.go @@ -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)