提交 5cc1256f 编写于 作者: F Felix Lange

p2p: ensure we don't dial ourself

addPeer doesn't allow self connects, but we can avoid opening
connections in the first place.
上级 7101f449
......@@ -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
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册