Update default MTU to 1402

This commit is contained in:
Kusakabe Si 2021-12-12 08:29:05 +00:00
parent 92e2c7d2e1
commit ad4ffff985
25 changed files with 52 additions and 48 deletions

View File

@ -501,7 +501,7 @@ func (peer *Peer) RoutineSequentialReceiver() {
should_receive = true should_receive = true
case mtypes.NodeID_Broadcast: case mtypes.NodeID_Broadcast:
should_receive = true should_receive = true
case mtypes.NodeID_AllPeer: case mtypes.NodeID_Spread:
should_receive = true should_receive = true
} }
} }
@ -511,7 +511,7 @@ func (peer *Peer) RoutineSequentialReceiver() {
should_process = true should_process = true
case mtypes.NodeID_Broadcast: case mtypes.NodeID_Broadcast:
should_process = true should_process = true
case mtypes.NodeID_AllPeer: case mtypes.NodeID_Spread:
should_process = true should_process = true
} }
} }
@ -534,7 +534,7 @@ func (peer *Peer) RoutineSequentialReceiver() {
switch dst_nodeID { switch dst_nodeID {
case mtypes.NodeID_Broadcast: case mtypes.NodeID_Broadcast:
should_transfer = true should_transfer = true
case mtypes.NodeID_AllPeer: case mtypes.NodeID_Spread:
packet := elem.packet[path.EgHeaderLen:] //packet body packet := elem.packet[path.EgHeaderLen:] //packet body
if device.CheckNoDup(packet) { if device.CheckNoDup(packet) {
should_transfer = true should_transfer = true
@ -566,7 +566,7 @@ func (peer *Peer) RoutineSequentialReceiver() {
EgHeader.SetTTL(l2ttl - 1) EgHeader.SetTTL(l2ttl - 1)
if dst_nodeID == mtypes.NodeID_Broadcast { //Regular transfer algorithm if dst_nodeID == mtypes.NodeID_Broadcast { //Regular transfer algorithm
device.TransitBoardcastPacket(src_nodeID, peer.ID, elem.Type, elem.packet, MessageTransportOffsetContent) device.TransitBoardcastPacket(src_nodeID, peer.ID, elem.Type, elem.packet, MessageTransportOffsetContent)
} else if dst_nodeID == mtypes.NodeID_AllPeer { // Control Message will try send to every know node regardless the connectivity } else if dst_nodeID == mtypes.NodeID_Spread { // Control Message will try send to every know node regardless the connectivity
skip_list := make(map[mtypes.Vertex]bool) skip_list := make(map[mtypes.Vertex]bool)
skip_list[src_nodeID] = true //Don't send to conimg peer and source peer skip_list[src_nodeID] = true //Don't send to conimg peer and source peer
skip_list[peer.ID] = true skip_list[peer.ID] = true
@ -604,12 +604,12 @@ func (peer *Peer) RoutineSequentialReceiver() {
if should_receive { // Write message to tap device if should_receive { // Write message to tap device
if packet_type == path.NormalPacket { if packet_type == path.NormalPacket {
if len(elem.packet) <= path.EgHeaderLen+12 { if len(elem.packet) <= path.EgHeaderLen+12 {
device.log.Errorf("Invalid normal packet: Ethernet packet too small from peer %v", peer.ID.ToString()) device.log.Errorf("Invalid Normal packet: Ethernet packet too small from peer %v", peer.ID.ToString())
goto skip goto skip
} }
if device.LogLevel.LogNormal { if device.LogLevel.LogNormal {
packet_len := len(elem.packet) - path.EgHeaderLen packet_len := len(elem.packet) - path.EgHeaderLen
fmt.Println("Normal: Recv Normal packet From:" + peer.GetEndpointDstStr() + " SrcID:" + src_nodeID.ToString() + " DstID:" + dst_nodeID.ToString() + " Len:" + strconv.Itoa(packet_len)) fmt.Printf("Normal: Recv Len:%v S:%v D:%v From:%v IP:%v:\n", strconv.Itoa(packet_len), src_nodeID.ToString(), dst_nodeID.ToString(), peer.ID.ToString(), peer.GetEndpointDstStr())
packet := gopacket.NewPacket(elem.packet[path.EgHeaderLen:], layers.LayerTypeEthernet, gopacket.Default) packet := gopacket.NewPacket(elem.packet[path.EgHeaderLen:], layers.LayerTypeEthernet, gopacket.Default)
fmt.Println(packet.Dump()) fmt.Println(packet.Dump())
} }

View File

@ -36,7 +36,7 @@ func (device *Device) SendPacket(peer *Peer, usage path.Usage, packet []byte, of
} }
if usage == path.NormalPacket && len(packet)-path.EgHeaderLen <= 12 { if usage == path.NormalPacket && len(packet)-path.EgHeaderLen <= 12 {
if device.LogLevel.LogNormal { if device.LogLevel.LogNormal {
fmt.Printf("Normal: Send Len:%v Invalid packet: Ethernet packet too small\n", len(packet)) fmt.Printf("Normal: Send Len:%v Invalid packet: Ethernet packet too small\n", len(packet)-path.EgHeaderLen)
} }
return return
} }
@ -46,7 +46,7 @@ func (device *Device) SendPacket(peer *Peer, usage path.Usage, packet []byte, of
if usage == path.NormalPacket && EgHeader.GetSrc() == device.ID { if usage == path.NormalPacket && EgHeader.GetSrc() == device.ID {
dst_nodeID := EgHeader.GetDst() dst_nodeID := EgHeader.GetDst()
packet_len := len(packet) - path.EgHeaderLen packet_len := len(packet) - path.EgHeaderLen
fmt.Printf("Normal: Send Len%v S:%v D:%v To:%v IP:%v:\n", packet_len, device.ID.ToString(), dst_nodeID.ToString(), peer.ID.ToString(), peer.GetEndpointDstStr()) fmt.Printf("Normal: Send Len:%v S:%v D:%v To:%v IP:%v:\n", packet_len, device.ID.ToString(), dst_nodeID.ToString(), peer.ID.ToString(), peer.GetEndpointDstStr())
packet := gopacket.NewPacket(packet[path.EgHeaderLen:], layers.LayerTypeEthernet, gopacket.Default) packet := gopacket.NewPacket(packet[path.EgHeaderLen:], layers.LayerTypeEthernet, gopacket.Default)
fmt.Println(packet.Dump()) fmt.Println(packet.Dump())
} }
@ -251,7 +251,7 @@ func (device *Device) GeneratePingPacket(src_nodeID mtypes.Vertex, request_reply
if err != nil { if err != nil {
return nil, path.PingPacket, err return nil, path.PingPacket, err
} }
header.SetDst(mtypes.NodeID_AllPeer) header.SetDst(mtypes.NodeID_Spread)
header.SetTTL(0) header.SetTTL(0)
header.SetSrc(device.ID) header.SetSrc(device.ID)
header.SetPacketLength(uint16(len(body))) header.SetPacketLength(uint16(len(body)))
@ -359,7 +359,7 @@ func (device *Device) process_ping(peer *Peer, content mtypes.PingMsg) error {
device.Send2Super(path.PongPacket, buf, MessageTransportOffsetContent) device.Send2Super(path.PongPacket, buf, MessageTransportOffsetContent)
} }
if device.EdgeConfig.DynamicRoute.P2P.UseP2P { if device.EdgeConfig.DynamicRoute.P2P.UseP2P {
header.SetDst(mtypes.NodeID_AllPeer) header.SetDst(mtypes.NodeID_Spread)
device.SpreadPacket(make(map[mtypes.Vertex]bool), path.PongPacket, buf, MessageTransportOffsetContent) device.SpreadPacket(make(map[mtypes.Vertex]bool), path.PongPacket, buf, MessageTransportOffsetContent)
} }
go device.SendPing(peer, content.RequestReply, 0, 3) go device.SendPing(peer, content.RequestReply, 0, 3)
@ -707,7 +707,7 @@ func (device *Device) process_RequestPeerMsg(content mtypes.QueryPeerMsg) error
} }
buf := make([]byte, path.EgHeaderLen+len(body)) buf := make([]byte, path.EgHeaderLen+len(body))
header, _ := path.NewEgHeader(buf[0:path.EgHeaderLen], device.EdgeConfig.Interface.MTU) header, _ := path.NewEgHeader(buf[0:path.EgHeaderLen], device.EdgeConfig.Interface.MTU)
header.SetDst(mtypes.NodeID_AllPeer) header.SetDst(mtypes.NodeID_Spread)
header.SetTTL(device.EdgeConfig.DefaultTTL) header.SetTTL(device.EdgeConfig.DefaultTTL)
header.SetSrc(device.ID) header.SetSrc(device.ID)
header.SetPacketLength(uint16(len(body))) header.SetPacketLength(uint16(len(body)))
@ -924,7 +924,7 @@ func (device *Device) RoutinePostPeerInfo(startchan <-chan struct{}) {
} }
pongs = append(pongs, pong) pongs = append(pongs, pong)
if device.LogLevel.LogControl { if device.LogLevel.LogControl {
fmt.Println("Control: Pack to: Post body " + pong.ToString()) fmt.Printf("Control: Pack %v S:%v D:%v To:Post body\n", pong.ToString(), pong.Src_nodeID.ToString(), pong.Dst_nodeID.ToString())
} }
} }
device.peers.RLock() device.peers.RLock()
@ -982,15 +982,19 @@ func (device *Device) RoutinePostPeerInfo(startchan <-chan struct{}) {
req.Header.Set("Content-Encoding", "gzip") req.Header.Set("Content-Encoding", "gzip")
device.HttpPostCount += 1 device.HttpPostCount += 1
if device.LogLevel.LogControl { if device.LogLevel.LogControl {
fmt.Println("Control: Post to " + req.URL.RequestURI()) fmt.Printf("Control: Post to %v\n", downloadurl)
} }
resp, err := client.Do(req) resp, err := client.Do(req)
if err != nil { if err != nil {
device.log.Errorf("RoutinePostPeerInfo: " + err.Error()) device.log.Errorf("RoutinePostPeerInfo: " + err.Error())
} else { } else {
if device.LogLevel.LogControl { if device.LogLevel.LogControl {
res, _ := ioutil.ReadAll(resp.Body) res, err := ioutil.ReadAll(resp.Body)
fmt.Println("Control: Post result " + string(res)) if err == nil {
fmt.Printf("Control: Post result %v\n", string(res))
} else {
fmt.Printf("Control: Post error %v %v\n", err, string(res))
}
} }
resp.Body.Close() resp.Body.Close()
} }

View File

@ -286,7 +286,8 @@ func (device *Device) RoutineReadFromTUN() {
continue continue
} }
if device.LogLevel.LogNormal { if device.LogLevel.LogNormal {
fmt.Println("Normal: Send packet To:" + peer.GetEndpointDstStr() + " SrcID:" + device.ID.ToString() + " DstID:" + dst_nodeID.ToString() + " Len:" + strconv.Itoa(len(elem.packet))) packet_len := len(elem.packet) - path.EgHeaderLen
fmt.Printf("Normal: Send Len:%v S:%v D:%v To:%v IP:%v:\n", packet_len, device.ID.ToString(), dst_nodeID.ToString(), peer.ID.ToString(), peer.GetEndpointDstStr())
packet := gopacket.NewPacket(elem.packet[path.EgHeaderLen:], layers.LayerTypeEthernet, gopacket.Default) packet := gopacket.NewPacket(elem.packet[path.EgHeaderLen:], layers.LayerTypeEthernet, gopacket.Default)
fmt.Println(packet.Dump()) fmt.Println(packet.Dump())
} }

View File

@ -12,7 +12,7 @@ import (
"github.com/KusakabeSi/EtherGuard-VPN/tap" "github.com/KusakabeSi/EtherGuard-VPN/tap"
) )
const DefaultMTU = 1416 const DefaultMTU = 1402
func (device *Device) RoutineTUNEventReader() { func (device *Device) RoutineTUNEventReader() {
device.log.Verbosef("Routine: event worker - started") device.log.Verbosef("Routine: event worker - started")

View File

@ -7,7 +7,7 @@ Interface:
IPv4CIDR: 192.168.76.0/24 IPv4CIDR: 192.168.76.0/24
IPv6CIDR: fd95:71cb:a3df:e586::/64 IPv6CIDR: fd95:71cb:a3df:e586::/64
IPv6LLPrefix: fe80::a3df:0/112 IPv6LLPrefix: fe80::a3df:0/112
MTU: 1416 MTU: 1402
RecvAddr: 127.0.0.1:4001 RecvAddr: 127.0.0.1:4001
SendAddr: 127.0.0.1:5001 SendAddr: 127.0.0.1:5001
L2HeaderMode: kbdbg L2HeaderMode: kbdbg

View File

@ -7,7 +7,7 @@ Interface:
IPv4CIDR: 192.168.76.0/24 IPv4CIDR: 192.168.76.0/24
IPv6CIDR: fd95:71cb:a3df:e586::/64 IPv6CIDR: fd95:71cb:a3df:e586::/64
IPv6LLPrefix: fe80::a3df:0/112 IPv6LLPrefix: fe80::a3df:0/112
MTU: 1416 MTU: 1402
RecvAddr: 127.0.0.1:4001 RecvAddr: 127.0.0.1:4001
SendAddr: 127.0.0.1:5001 SendAddr: 127.0.0.1:5001
L2HeaderMode: kbdbg L2HeaderMode: kbdbg

View File

@ -7,7 +7,7 @@ Interface:
IPv4CIDR: 192.168.76.0/24 IPv4CIDR: 192.168.76.0/24
IPv6CIDR: fd95:71cb:a3df:e586::/64 IPv6CIDR: fd95:71cb:a3df:e586::/64
IPv6LLPrefix: fe80::a3df:0/112 IPv6LLPrefix: fe80::a3df:0/112
MTU: 1416 MTU: 1402
RecvAddr: 127.0.0.1:4001 RecvAddr: 127.0.0.1:4001
SendAddr: 127.0.0.1:5001 SendAddr: 127.0.0.1:5001
L2HeaderMode: kbdbg L2HeaderMode: kbdbg

View File

@ -7,7 +7,7 @@ Interface:
IPv4CIDR: 192.168.76.0/24 IPv4CIDR: 192.168.76.0/24
IPv6CIDR: fd95:71cb:a3df:e586::/64 IPv6CIDR: fd95:71cb:a3df:e586::/64
IPv6LLPrefix: fe80::a3df:0/112 IPv6LLPrefix: fe80::a3df:0/112
MTU: 1416 MTU: 1402
RecvAddr: 127.0.0.1:4001 RecvAddr: 127.0.0.1:4001
SendAddr: 127.0.0.1:5001 SendAddr: 127.0.0.1:5001
L2HeaderMode: kbdbg L2HeaderMode: kbdbg

View File

@ -7,7 +7,7 @@ Interface:
IPv4CIDR: 192.168.76.0/24 IPv4CIDR: 192.168.76.0/24
IPv6CIDR: fd95:71cb:a3df:e586::/64 IPv6CIDR: fd95:71cb:a3df:e586::/64
IPv6LLPrefix: fe80::a3df:0/112 IPv6LLPrefix: fe80::a3df:0/112
MTU: 1416 MTU: 1402
RecvAddr: 127.0.0.1:4001 RecvAddr: 127.0.0.1:4001
SendAddr: 127.0.0.1:5001 SendAddr: 127.0.0.1:5001
L2HeaderMode: kbdbg L2HeaderMode: kbdbg

View File

@ -7,7 +7,7 @@ Interface:
IPv4CIDR: 192.168.76.0/24 IPv4CIDR: 192.168.76.0/24
IPv6CIDR: fd95:71cb:a3df:e586::/64 IPv6CIDR: fd95:71cb:a3df:e586::/64
IPv6LLPrefix: fe80::a3df:0/112 IPv6LLPrefix: fe80::a3df:0/112
MTU: 1416 MTU: 1402
RecvAddr: 127.0.0.1:4001 RecvAddr: 127.0.0.1:4001
SendAddr: 127.0.0.1:5001 SendAddr: 127.0.0.1:5001
L2HeaderMode: kbdbg L2HeaderMode: kbdbg

View File

@ -7,7 +7,7 @@ Interface:
IPv4CIDR: 192.168.76.0/24 IPv4CIDR: 192.168.76.0/24
IPv6CIDR: fd95:71cb:a3df:e586::/64 IPv6CIDR: fd95:71cb:a3df:e586::/64
IPv6LLPrefix: fe80::a3df:0/112 IPv6LLPrefix: fe80::a3df:0/112
MTU: 1416 MTU: 1402
RecvAddr: 127.0.0.1:4001 RecvAddr: 127.0.0.1:4001
SendAddr: 127.0.0.1:5001 SendAddr: 127.0.0.1:5001
L2HeaderMode: kbdbg L2HeaderMode: kbdbg

View File

@ -7,7 +7,7 @@ Interface:
IPv4CIDR: 192.168.76.0/24 IPv4CIDR: 192.168.76.0/24
IPv6CIDR: fd95:71cb:a3df:e586::/64 IPv6CIDR: fd95:71cb:a3df:e586::/64
IPv6LLPrefix: fe80::a3df:0/112 IPv6LLPrefix: fe80::a3df:0/112
MTU: 1416 MTU: 1402
RecvAddr: 127.0.0.1:4001 RecvAddr: 127.0.0.1:4001
SendAddr: 127.0.0.1:5001 SendAddr: 127.0.0.1:5001
L2HeaderMode: kbdbg L2HeaderMode: kbdbg

View File

@ -7,7 +7,7 @@ Interface:
IPv4CIDR: 192.168.76.0/24 IPv4CIDR: 192.168.76.0/24
IPv6CIDR: fd95:71cb:a3df:e586::/64 IPv6CIDR: fd95:71cb:a3df:e586::/64
IPv6LLPrefix: fe80::a3df:0/112 IPv6LLPrefix: fe80::a3df:0/112
MTU: 1416 MTU: 1402
RecvAddr: 127.0.0.1:4001 RecvAddr: 127.0.0.1:4001
SendAddr: 127.0.0.1:5001 SendAddr: 127.0.0.1:5001
L2HeaderMode: kbdbg L2HeaderMode: kbdbg

View File

@ -7,7 +7,7 @@ Interface:
IPv4CIDR: 192.168.76.0/24 IPv4CIDR: 192.168.76.0/24
IPv6CIDR: fd95:71cb:a3df:e586::/64 IPv6CIDR: fd95:71cb:a3df:e586::/64
IPv6LLPrefix: fe80::a3df:0/112 IPv6LLPrefix: fe80::a3df:0/112
MTU: 1416 MTU: 1402
RecvAddr: 127.0.0.1:4001 RecvAddr: 127.0.0.1:4001
SendAddr: 127.0.0.1:5001 SendAddr: 127.0.0.1:5001
L2HeaderMode: kbdbg L2HeaderMode: kbdbg

View File

@ -7,7 +7,7 @@ Interface:
IPv4CIDR: 192.168.76.0/24 IPv4CIDR: 192.168.76.0/24
IPv6CIDR: fd95:71cb:a3df:e586::/64 IPv6CIDR: fd95:71cb:a3df:e586::/64
IPv6LLPrefix: fe80::a3df:0/112 IPv6LLPrefix: fe80::a3df:0/112
MTU: 1416 MTU: 1402
RecvAddr: 127.0.0.1:4001 RecvAddr: 127.0.0.1:4001
SendAddr: 127.0.0.1:5001 SendAddr: 127.0.0.1:5001
L2HeaderMode: kbdbg L2HeaderMode: kbdbg

View File

@ -7,7 +7,7 @@ Interface:
IPv4CIDR: 192.168.76.0/24 IPv4CIDR: 192.168.76.0/24
IPv6CIDR: fd95:71cb:a3df:e586::/64 IPv6CIDR: fd95:71cb:a3df:e586::/64
IPv6LLPrefix: fe80::a3df:0/112 IPv6LLPrefix: fe80::a3df:0/112
MTU: 1416 MTU: 1402
RecvAddr: 127.0.0.1:4001 RecvAddr: 127.0.0.1:4001
SendAddr: 127.0.0.1:5001 SendAddr: 127.0.0.1:5001
L2HeaderMode: kbdbg L2HeaderMode: kbdbg

View File

@ -7,7 +7,7 @@ Interface:
IPv4CIDR: 192.168.76.0/24 IPv4CIDR: 192.168.76.0/24
IPv6CIDR: fd95:71cb:a3df:e586::/64 IPv6CIDR: fd95:71cb:a3df:e586::/64
IPv6LLPrefix: fe80::a3df:0/112 IPv6LLPrefix: fe80::a3df:0/112
MTU: 1416 MTU: 1402
RecvAddr: 127.0.0.1:4001 RecvAddr: 127.0.0.1:4001
SendAddr: 127.0.0.1:5001 SendAddr: 127.0.0.1:5001
L2HeaderMode: kbdbg L2HeaderMode: kbdbg

View File

@ -7,7 +7,7 @@ Interface:
IPv4CIDR: 192.168.76.0/24 IPv4CIDR: 192.168.76.0/24
IPv6CIDR: fd95:71cb:a3df:e586::/64 IPv6CIDR: fd95:71cb:a3df:e586::/64
IPv6LLPrefix: fe80::a3df:0/112 IPv6LLPrefix: fe80::a3df:0/112
MTU: 1416 MTU: 1402
RecvAddr: 127.0.0.1:4002 RecvAddr: 127.0.0.1:4002
SendAddr: 127.0.0.1:5002 SendAddr: 127.0.0.1:5002
L2HeaderMode: kbdbg L2HeaderMode: kbdbg

View File

@ -7,7 +7,7 @@ Interface:
IPv4CIDR: 192.168.76.0/24 IPv4CIDR: 192.168.76.0/24
IPv6CIDR: fd95:71cb:a3df:e586::/64 IPv6CIDR: fd95:71cb:a3df:e586::/64
IPv6LLPrefix: fe80::a3df:0/112 IPv6LLPrefix: fe80::a3df:0/112
MTU: 1416 MTU: 1402
RecvAddr: 127.0.0.1:4100 RecvAddr: 127.0.0.1:4100
SendAddr: 127.0.0.1:5100 SendAddr: 127.0.0.1:5100
L2HeaderMode: kbdbg L2HeaderMode: kbdbg

View File

@ -306,7 +306,7 @@ interface:
vppifaceid: 1 vppifaceid: 1
vppbridgeid: 4242 vppbridgeid: 4242
macaddrprefix: AA:BB:CC:DD macaddrprefix: AA:BB:CC:DD
mtu: 1416 mtu: 1402
recvaddr: 127.0.0.1:4001 recvaddr: 127.0.0.1:4001
sendaddr: 127.0.0.1:5001 sendaddr: 127.0.0.1:5001
l2headermode: kbdbg l2headermode: kbdbg

View File

@ -4,7 +4,7 @@ interface:
vppifaceid: 1 vppifaceid: 1
vppbridgeid: 4242 vppbridgeid: 4242
macaddrprefix: AA:BB:CC:DD macaddrprefix: AA:BB:CC:DD
mtu: 1416 mtu: 1402
recvaddr: 127.0.0.1:4001 recvaddr: 127.0.0.1:4001
sendaddr: 127.0.0.1:5001 sendaddr: 127.0.0.1:5001
l2headermode: kbdbg l2headermode: kbdbg

View File

@ -6,6 +6,7 @@
package gencfg package gencfg
import ( import (
"github.com/KusakabeSi/EtherGuard-VPN/device"
"github.com/KusakabeSi/EtherGuard-VPN/mtypes" "github.com/KusakabeSi/EtherGuard-VPN/mtypes"
"github.com/KusakabeSi/EtherGuard-VPN/path" "github.com/KusakabeSi/EtherGuard-VPN/path"
) )
@ -27,7 +28,7 @@ func GetExampleEdgeConf(templatePath string, getDemo bool) mtypes.EdgeConfig {
VPPIFaceID: 1, VPPIFaceID: 1,
VPPBridgeID: 4242, VPPBridgeID: 4242,
MacAddrPrefix: "AA:BB:CC:DD", MacAddrPrefix: "AA:BB:CC:DD",
MTU: 1416, MTU: device.DefaultMTU,
RecvAddr: "127.0.0.1:4001", RecvAddr: "127.0.0.1:4001",
SendAddr: "127.0.0.1:5001", SendAddr: "127.0.0.1:5001",
L2HeaderMode: "nochg", L2HeaderMode: "nochg",

View File

@ -470,7 +470,7 @@ func edge_post_nodeinfo(w http.ResponseWriter, r *http.Request) {
continue continue
} }
if info, has := httpobj.http_PeerID2Info[pong_msg.Dst_nodeID]; !has { if info, has := httpobj.http_PeerID2Info[pong_msg.Dst_nodeID]; has {
AdditionalCost_use := info.AdditionalCost AdditionalCost_use := info.AdditionalCost
if AdditionalCost_use >= 0 { if AdditionalCost_use >= 0 {
@ -478,7 +478,7 @@ func edge_post_nodeinfo(w http.ResponseWriter, r *http.Request) {
} }
applied_pones = append(applied_pones, pong_msg) applied_pones = append(applied_pones, pong_msg)
if httpobj.http_sconfig.LogLevel.LogControl { if httpobj.http_sconfig.LogLevel.LogControl {
fmt.Println("Control: Unpack from : Post body " + pong_msg.ToString()) fmt.Printf("Control: Recv %v S:%v D:%v From: %v(HTTP) IP:%v\n", pong_msg.ToString(), pong_msg.Src_nodeID.ToString(), pong_msg.Dst_nodeID.ToString(), NodeID.ToString(), r.RemoteAddr)
} }
} }
} }

View File

@ -11,7 +11,7 @@ type Vertex uint16
const ( const (
NodeID_Broadcast Vertex = math.MaxUint16 - iota // Normal boardcast, boardcast with route table NodeID_Broadcast Vertex = math.MaxUint16 - iota // Normal boardcast, boardcast with route table
NodeID_AllPeer Vertex = math.MaxUint16 - iota // p2p mode: boardcast to every know peer and prevent dup. super mode: send to supernode NodeID_Spread Vertex = math.MaxUint16 - iota // p2p mode: boardcast to every know peer and prevent dup. super mode: send to supernode
NodeID_SuperNode Vertex = math.MaxUint16 - iota NodeID_SuperNode Vertex = math.MaxUint16 - iota
NodeID_Invalid Vertex = math.MaxUint16 - iota NodeID_Invalid Vertex = math.MaxUint16 - iota
NodeID_Special Vertex = NodeID_Invalid NodeID_Special Vertex = NodeID_Invalid
@ -110,8 +110,8 @@ func (v *Vertex) ToString() string {
switch *v { switch *v {
case NodeID_Broadcast: case NodeID_Broadcast:
return "Boardcast" return "Boardcast"
case NodeID_AllPeer: case NodeID_Spread:
return "AllPeer" return "Spread"
case NodeID_SuperNode: case NodeID_SuperNode:
return "Super" return "Super"
case NodeID_Invalid: case NodeID_Invalid:

View File

@ -2,7 +2,6 @@ package mtypes
import ( import (
"bytes" "bytes"
"encoding/base64"
"encoding/gob" "encoding/gob"
"fmt" "fmt"
"strconv" "strconv"
@ -33,17 +32,16 @@ type RegisterMsg struct {
HttpPostCount uint64 HttpPostCount uint64
} }
func Hash2Str(h []byte) string { func Hash2Str(h string) string {
for _, v := range h { n := 10
if v != 0 { if len(h) > n-3 {
return base64.StdEncoding.EncodeToString(h)[:10] + "..." return h[:n] + "..."
} }
} return "\"" + h + "\""
return "\"\""
} }
func (c *RegisterMsg) ToString() string { func (c *RegisterMsg) ToString() string {
return fmt.Sprint("RegisterMsg Node_id:"+c.Node_id.ToString(), " Version:"+c.Version, " PeerHash:"+c.PeerStateHash, " NhHash:"+c.NhStateHash, " SuperParamHash:"+c.SuperParamStateHash) return fmt.Sprint("RegisterMsg Node_id:"+c.Node_id.ToString(), " Version:"+c.Version, " PeerHash:"+Hash2Str(c.PeerStateHash), " NhHash:"+Hash2Str(c.NhStateHash), " SuperParamHash:"+Hash2Str(c.SuperParamStateHash))
} }
func ParseRegisterMsg(bin []byte) (StructPlace RegisterMsg, err error) { func ParseRegisterMsg(bin []byte) (StructPlace RegisterMsg, err error) {