aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-05-02 23:57:07 +0800
committerFelix Lange <fjl@twurst.com>2016-05-03 00:50:16 +0800
commit81106719601c6eb0fa9e9421262569c16e3c2fde (patch)
tree8b54108010758f2ef2278c6aa8a89b4c486aba29
parent32bb280179a44b9ad1058766bf61cdbacea30a59 (diff)
downloaddexon-81106719601c6eb0fa9e9421262569c16e3c2fde.tar
dexon-81106719601c6eb0fa9e9421262569c16e3c2fde.tar.gz
dexon-81106719601c6eb0fa9e9421262569c16e3c2fde.tar.bz2
dexon-81106719601c6eb0fa9e9421262569c16e3c2fde.tar.lz
dexon-81106719601c6eb0fa9e9421262569c16e3c2fde.tar.xz
dexon-81106719601c6eb0fa9e9421262569c16e3c2fde.tar.zst
dexon-81106719601c6eb0fa9e9421262569c16e3c2fde.zip
p2p/discover: prevent bonding self
-rw-r--r--p2p/discover/table.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/p2p/discover/table.go b/p2p/discover/table.go
index 1de045f04..ad0b5c8ca 100644
--- a/p2p/discover/table.go
+++ b/p2p/discover/table.go
@@ -25,6 +25,7 @@ package discover
import (
"crypto/rand"
"encoding/binary"
+ "errors"
"fmt"
"net"
"sort"
@@ -457,6 +458,9 @@ func (tab *Table) bondall(nodes []*Node) (result []*Node) {
// If pinged is true, the remote node has just pinged us and one half
// of the process can be skipped.
func (tab *Table) bond(pinged bool, id NodeID, addr *net.UDPAddr, tcpPort uint16) (*Node, error) {
+ if id == tab.self.ID {
+ return nil, errors.New("is self")
+ }
// Retrieve a previously known node and any recent findnode failures
node, fails := tab.db.node(id), 0
if node != nil {