mirror of
https://github.com/KusakabeShi/EtherGuard-VPN.git
synced 2025-01-26 14:08:34 +01:00
parse error for metamessage and allow single network stack
This commit is contained in:
parent
2ac7c0547d
commit
34443127b9
@ -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 {
|
||||
|
@ -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{}{}
|
||||
|
Loading…
Reference in New Issue
Block a user