diff options
author | Felix Lange <fjl@twurst.com> | 2015-02-13 21:50:14 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-02-13 22:06:47 +0800 |
commit | 5cc1256fd679cbb8cb80502494b8c02befc757c8 (patch) | |
tree | 1305c584d0c3c7afa9b97e62aa5212d4d33d6d35 /p2p/server.go | |
parent | 7101f4499873fbf6a68cbe08a45797ff8ec71e74 (diff) | |
download | go-tangerine-5cc1256fd679cbb8cb80502494b8c02befc757c8.tar.gz go-tangerine-5cc1256fd679cbb8cb80502494b8c02befc757c8.tar.zst go-tangerine-5cc1256fd679cbb8cb80502494b8c02befc757c8.zip |
p2p: ensure we don't dial ourself
addPeer doesn't allow self connects, but we can avoid opening
connections in the first place.
Diffstat (limited to 'p2p/server.go')
-rw-r--r-- | p2p/server.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/p2p/server.go b/p2p/server.go index b93340150..e510be521 100644 --- a/p2p/server.go +++ b/p2p/server.go @@ -289,10 +289,13 @@ func (srv *Server) dialLoop() { go srv.findPeers() case dest := <-srv.peerConnect: + // avoid dialing nodes that are already connected. + // there is another check for this in addPeer, + // which runs after the handshake. srv.lock.Lock() _, isconnected := srv.peers[dest.ID] srv.lock.Unlock() - if isconnected || dialing[dest.ID] { + if isconnected || dialing[dest.ID] || dest.ID == srv.ntab.Self() { continue } |