Browse Source

Avoid trying to connect to obviously private ports.

cl-refactor
Gav Wood 10 years ago
parent
commit
86127f3820
  1. 3
      libp2p/Host.cpp
  2. 7
      libp2p/Session.cpp

3
libp2p/Host.cpp

@ -687,7 +687,8 @@ bytes Host::saveNodes() const
for (auto const& i: m_nodes) for (auto const& i: m_nodes)
{ {
Node const& n = *(i.second); Node const& n = *(i.second);
if (!n.dead && n.address.port() > 0 && n.address.port() >= 30300 && n.address.port() <= 30305 && n.id != id() && !isPrivateAddress(n.address.address())) // TODO: PoC-7: Figure out why it ever shares these ports.//n.address.port() >= 30300 && n.address.port() <= 30305 &&
if (!n.dead && n.address.port() > 0 && n.address.port() < 49152 && n.id != id() && !isPrivateAddress(n.address.address()))
{ {
nodes.appendList(10); nodes.appendList(10);
if (n.address.address().is_v4()) if (n.address.address().is_v4())

7
libp2p/Session.cpp

@ -326,10 +326,13 @@ bool Session::interpret(RLP const& _r)
if (!ep.port()) if (!ep.port())
goto CONTINUE; // Zero port? Don't think so. goto CONTINUE; // Zero port? Don't think so.
if (ep.port() >= 49152)
goto CONTINUE; // Private port according to IANA.
// TODO: PoC-7: // TODO: PoC-7:
// Technically fine, but ignore for now to avoid peers passing on incoming ports until we can be sure that doesn't happen any more. // Technically fine, but ignore for now to avoid peers passing on incoming ports until we can be sure that doesn't happen any more.
if (ep.port() < 30300 || ep.port() > 30305) // if (ep.port() < 30300 || ep.port() > 30305)
goto CONTINUE; // Wierd port. // goto CONTINUE; // Wierd port.
// Avoid our random other addresses that they might end up giving us. // Avoid our random other addresses that they might end up giving us.
for (auto i: m_server->m_addresses) for (auto i: m_server->m_addresses)

Loading…
Cancel
Save