diff --git a/device/receivesendproc.go b/device/receivesendproc.go index bf92b61..d50c200 100644 --- a/device/receivesendproc.go +++ b/device/receivesendproc.go @@ -166,44 +166,51 @@ func (device *Device) process_received(msg_type path.Usage, peer *Peer, body []b return } -func (device *Device) sprint_received(msg_type path.Usage, body []byte) (ret string) { +func (device *Device) sprint_received(msg_type path.Usage, body []byte) (string) { switch msg_type { case path.Register: if content, err := path.ParseRegisterMsg(body); err == nil { - ret = content.ToString() + return content.ToString() } + return "RegisterMsg: Parse failed" case path.UpdatePeer: if content, err := path.ParseUpdatePeerMsg(body); err == nil { - ret = content.ToString() + return content.ToString() } + return "UpdatePeerMsg: Parse failed" case path.UpdateNhTable: if content, err := path.ParseUpdateNhTableMsg(body); err == nil { - ret = content.ToString() + return content.ToString() } + return "UpdateNhTableMsg: Parse failed" case path.UpdateError: if content, err := path.ParseUpdateErrorMsg(body); err == nil { - ret = content.ToString() + return content.ToString() } + return "UpdateErrorMsg: Parse failed" case path.PingPacket: if content, err := path.ParsePingMsg(body); err == nil { - ret = content.ToString() + return content.ToString() } + return "PingPacketMsg: Parse failed" case path.PongPacket: if content, err := path.ParsePongMsg(body); err == nil { - ret = content.ToString() + return content.ToString() } + return "PongPacketMsg: Parse failed" case path.QueryPeer: if content, err := path.ParseQueryPeerMsg(body); err == nil { - ret = content.ToString() + return content.ToString() } + return "QueryPeerMsg: Parse failed" case path.BoardcastPeer: if content, err := path.ParseBoardcastPeerMsg(body); err == nil { - ret = content.ToString() + return content.ToString() } + return "BoardcastPeerMsg: Parse failed" default: - ret = "Not a valid msg_type" + return "UnknowMsg: Not a valid msg_type" } - return } func (device *Device) server_process_RegisterMsg(peer *Peer, content path.RegisterMsg) error { diff --git a/main_edge.go b/main_edge.go index c905dbc..c5db96b 100644 --- a/main_edge.go +++ b/main_edge.go @@ -237,6 +237,8 @@ func Edge(configPath string, useUAPI bool, printExample bool, bindmode string) ( } if econfig.DynamicRoute.SuperNode.UseSuperNode { + S4 := true + S6 := true if econfig.DynamicRoute.SuperNode.ConnURLV4 != "" { pk, err := device.Str2PubKey(econfig.DynamicRoute.SuperNode.PubKeyV4) if err != nil { @@ -256,7 +258,7 @@ func Edge(configPath string, useUAPI bool, printExample bool, bindmode string) ( err = peer.SetEndpointFromConnURL(econfig.DynamicRoute.SuperNode.ConnURLV4, 4, false) if err != nil { logger.Errorf("Failed to set endpoint for supernode v4 %v: %v", econfig.DynamicRoute.SuperNode.ConnURLV4, err) - return err + S4 = false } } if econfig.DynamicRoute.SuperNode.ConnURLV6 != "" { @@ -279,7 +281,10 @@ func Edge(configPath string, useUAPI bool, printExample bool, bindmode string) ( err = peer.SetEndpointFromConnURL(econfig.DynamicRoute.SuperNode.ConnURLV6, 6, false) if err != nil { logger.Errorf("Failed to set endpoint for supernode v6 %v: %v", econfig.DynamicRoute.SuperNode.ConnURLV6, err) - return err + S6 = false + } + if !(S4 || S6) { + return errors.New("Failed to connect to supernode.") } } the_device.Event_Supernode_OK <- struct{}{}