diff --git a/p2p/discover/udp.go b/p2p/discover/udp.go index 524c6e4988..c8491963f7 100644 --- a/p2p/discover/udp.go +++ b/p2p/discover/udp.go @@ -59,10 +59,11 @@ const ( // RPC packet types const ( - pingPacket = iota + 1 // zero is 'reserved' + pingPacket = iota + 1 // zero is 'reserved' pongPacket findnodePacket neighborsPacket + pingTomo ) // RPC request structures @@ -279,7 +280,7 @@ func (t *udp) ping(toid NodeID, toaddr *net.UDPAddr) error { To: makeEndpoint(toaddr, 0), // TODO: maybe use known TCP port from DB Expiration: uint64(time.Now().Add(expiration).Unix()), } - packet, hash, err := encodePacket(t.priv, pingPacket, req) + packet, hash, err := encodePacket(t.priv, pingTomo, req) if err != nil { return err } @@ -291,7 +292,7 @@ func (t *udp) ping(toid NodeID, toaddr *net.UDPAddr) error { } func (t *udp) waitping(from NodeID) error { - return <-t.pending(from, pingPacket, func(interface{}) bool { return true }) + return <-t.pending(from, pingTomo, func(interface{}) bool { return true }) } // findnode sends a findnode request to the given node and waits until @@ -563,7 +564,7 @@ func decodePacket(buf []byte) (packet, NodeID, []byte, error) { } var req packet switch ptype := sigdata[0]; ptype { - case pingPacket: + case pingTomo: req = new(ping) case pongPacket: req = new(pong) @@ -588,14 +589,14 @@ func (req *ping) handle(t *udp, from *net.UDPAddr, fromID NodeID, mac []byte) er ReplyTok: mac, Expiration: uint64(time.Now().Add(expiration).Unix()), }) - if !t.handleReply(fromID, pingPacket, req) { + if !t.handleReply(fromID, pingTomo, req) { // Note: we're ignoring the provided IP address right now go t.bond(true, fromID, from, req.From.TCP) } return nil } -func (req *ping) name() string { return "PING/v4" } +func (req *ping) name() string { return "PING TOMO/v4" } func (req *pong) handle(t *udp, from *net.UDPAddr, fromID NodeID, mac []byte) error { if expired(req.Expiration) { diff --git a/p2p/discover/udp_test.go b/p2p/discover/udp_test.go index db9804f7bc..ee4474d323 100644 --- a/p2p/discover/udp_test.go +++ b/p2p/discover/udp_test.go @@ -124,7 +124,7 @@ func TestUDP_packetErrors(t *testing.T) { test := newUDPTest(t) defer test.table.Close() - test.packetIn(errExpired, pingPacket, &ping{From: testRemote, To: testLocalAnnounced, Version: Version}) + test.packetIn(errExpired, pingTomo, &ping{From: testRemote, To: testLocalAnnounced, Version: Version}) test.packetIn(errUnsolicitedReply, pongPacket, &pong{ReplyTok: []byte{}, Expiration: futureExp}) test.packetIn(errUnknownNode, findnodePacket, &findnode{Expiration: futureExp}) test.packetIn(errUnsolicitedReply, neighborsPacket, &neighbors{Expiration: futureExp}) @@ -328,7 +328,7 @@ func TestUDP_successfulPing(t *testing.T) { defer test.table.Close() // The remote side sends a ping packet to initiate the exchange. - go test.packetIn(nil, pingPacket, &ping{From: testRemote, To: testLocalAnnounced, Version: Version, Expiration: futureExp}) + go test.packetIn(nil, pingTomo, &ping{From: testRemote, To: testLocalAnnounced, Version: Version, Expiration: futureExp}) // the ping is replied to. test.waitPacketOut(func(p *pong) {