提交 81106719 编写于 作者: F Felix Lange

p2p/discover: prevent bonding self

上级 32bb2801
...@@ -25,6 +25,7 @@ package discover ...@@ -25,6 +25,7 @@ package discover
import ( import (
"crypto/rand" "crypto/rand"
"encoding/binary" "encoding/binary"
"errors"
"fmt" "fmt"
"net" "net"
"sort" "sort"
...@@ -457,6 +458,9 @@ func (tab *Table) bondall(nodes []*Node) (result []*Node) { ...@@ -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 // If pinged is true, the remote node has just pinged us and one half
// of the process can be skipped. // of the process can be skipped.
func (tab *Table) bond(pinged bool, id NodeID, addr *net.UDPAddr, tcpPort uint16) (*Node, error) { 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 // Retrieve a previously known node and any recent findnode failures
node, fails := tab.db.node(id), 0 node, fails := tab.db.node(id), 0
if node != nil { if node != nil {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册