Skip to content

Commit 8110671

Browse files
committed
p2p/discover: prevent bonding self
1 parent 32bb280 commit 8110671

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

p2p/discover/table.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ package discover
2525
import (
2626
"crypto/rand"
2727
"encoding/binary"
28+
"errors"
2829
"fmt"
2930
"net"
3031
"sort"
@@ -457,6 +458,9 @@ func (tab *Table) bondall(nodes []*Node) (result []*Node) {
457458
// If pinged is true, the remote node has just pinged us and one half
458459
// of the process can be skipped.
459460
func (tab *Table) bond(pinged bool, id NodeID, addr *net.UDPAddr, tcpPort uint16) (*Node, error) {
461+
if id == tab.self.ID {
462+
return nil, errors.New("is self")
463+
}
460464
// Retrieve a previously known node and any recent findnode failures
461465
node, fails := tab.db.node(id), 0
462466
if node != nil {

0 commit comments

Comments
 (0)