From 11c1b13e272eb21be3825009ae331a0ddda6d21a Mon Sep 17 00:00:00 2001 From: subtly Date: Sun, 22 Mar 2015 17:12:14 +0100 Subject: [PATCH] clarify peersAdded log. Increment failedAttempts so fallback timer goes up. Temporarily exclude private addresses from network-restore. This exclusion will be removed when unit tests are written for local/private/public/failed-pnp scenarios. --- libp2p/Host.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libp2p/Host.cpp b/libp2p/Host.cpp index 082ff6a2f..8226c35fb 100644 --- a/libp2p/Host.cpp +++ b/libp2p/Host.cpp @@ -260,7 +260,7 @@ void Host::onNodeTableEvent(NodeId const& _n, NodeTableEventType const& _e) p->required = n.required; m_peers[_n] = p; - clog(NetNote) << "p2p.host.peers.events.peersAdded " << _n << p->endpoint.tcp.address() << p->endpoint.udp.address(); + clog(NetNote) << "p2p.host.peers.events.peersAdded " << _n << "udp:" << p->endpoint.udp.address() << "tcp:" << p->endpoint.tcp.address(); } p->endpoint.tcp = n.endpoint.tcp; } @@ -474,6 +474,7 @@ void Host::connect(std::shared_ptr const& _p) clog(NetConnect) << "Connection refused to node" << _p->id.abridged() << "@" << _p->peerEndpoint() << "(" << ec.message() << ")"; _p->m_lastDisconnect = TCPError; _p->m_lastAttempted = std::chrono::system_clock::now(); + _p->m_failedAttempts++; } else { @@ -741,6 +742,13 @@ void Host::restoreNetwork(bytesConstRef _b) tcp = bi::tcp::endpoint(bi::address_v6(i[0].toArray()), i[1].toInt()); udp = bi::udp::endpoint(bi::address_v6(i[0].toArray()), i[1].toInt()); } + + // skip private addresses + // todo: to support private addresseses entries must be stored + // and managed externally by host rather than nodetable. + if (isPrivateAddress(tcp.address()) || isPrivateAddress(udp.address())) + continue; + auto id = (NodeId)i[2]; if (i.itemCount() == 3) m_nodeTable->addNode(id, udp, tcp);