From f791775e585ddb6ea5d4b5f5c811668181619bcb Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sat, 20 Sep 2014 11:04:51 -0500 Subject: [PATCH] Allow peers to tell us of their actual IPs. --- libp2p/Host.cpp | 2 +- libp2p/Session.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/libp2p/Host.cpp b/libp2p/Host.cpp index e94a3215d..1100eb54d 100644 --- a/libp2p/Host.cpp +++ b/libp2p/Host.cpp @@ -312,7 +312,7 @@ std::map Host::potentialPeers() if (auto j = i.second.lock()) { auto ep = j->endpoint(); - cdebug << "Checking potential peer" << j->m_listenPort << j->endpoint() << isPrivateAddress(ep.address()) << ep.port() << j->m_id.abridged(); + cnote << "Checking potential peer" << j->m_listenPort << j->endpoint() << isPrivateAddress(ep.address()) << ep.port() << j->m_id.abridged(); // Skip peers with a listen port of zero or are on a private network bool peerOnNet = (j->m_listenPort != 0 && (!isPrivateAddress(ep.address()) || m_netPrefs.localNetworking)); if (peerOnNet && ep.port() && j->m_id) diff --git a/libp2p/Session.cpp b/libp2p/Session.cpp index 6f1edd693..3bff33490 100644 --- a/libp2p/Session.cpp +++ b/libp2p/Session.cpp @@ -164,9 +164,8 @@ bool Session::interpret(RLP const& _r) if (isPrivateAddress(peerAddress) && !m_server->m_netPrefs.localNetworking) goto CONTINUE; - // check that it's not us or one we already know: - if (id && (m_server->m_id == id || m_server->havePeer(id) || m_server->m_incomingPeers.count(id))) + if (id && (m_server->m_id == id || (m_id == id && isPrivateAddress(endpoint().address())) || m_server->m_incomingPeers.count(id))) goto CONTINUE; // check that we're not already connected to addr: