Skip to content

Commit c997bb0

Browse files
thinkAfCodGrapeBaBa
authored andcommitted
fix: log packet nonce
1 parent d28ff8f commit c997bb0

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

p2p/discover/v5_udp.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,7 @@ func (t *UDPv5) send(toID enode.ID, toAddr netip.AddrPort, packet v5wire.Packet,
713713
t.logcontext = packet.AppendLogInfo(t.logcontext)
714714

715715
enc, nonce, err := t.codec.Encode(toID, addr, packet, c)
716+
t.logcontext = append(t.logcontext, "nonce", fmt.Sprintf("%x", nonce[:]))
716717
if err != nil {
717718
t.logcontext = append(t.logcontext, "err", err)
718719
t.log.Warn(">> "+packet.Name(), t.logcontext...)
@@ -866,7 +867,7 @@ var (
866867
func (t *UDPv5) handleWhoareyou(p *v5wire.Whoareyou, fromID enode.ID, fromAddr netip.AddrPort) {
867868
c, err := t.matchWithCall(fromID, p.Nonce)
868869
if err != nil {
869-
t.log.Debug("Invalid "+p.Name(), "addr", fromAddr, "err", err)
870+
t.log.Debug("Invalid "+p.Name(), "addr", fromAddr, "nonce", fmt.Sprintf("%x", p.Nonce[:]), "err", err)
870871
return
871872
}
872873

@@ -877,7 +878,7 @@ func (t *UDPv5) handleWhoareyou(p *v5wire.Whoareyou, fromID enode.ID, fromAddr n
877878
return
878879
}
879880
// Resend the call that was answered by WHOAREYOU.
880-
t.log.Trace("<< "+p.Name(), "id", c.node.ID(), "addr", fromAddr)
881+
t.log.Trace("<< "+p.Name(), "id", c.node.ID(), "addr", fromAddr, "nonce", fmt.Sprintf("%x", p.Nonce[:]))
881882
c.handshakeCount++
882883
c.challenge = p
883884
p.Node = c.node

0 commit comments

Comments
 (0)