Page MenuHomePhabricator

Force port 0 in I2P
ClosedPublic

Authored by PiRK on Feb 21 2022, 13:16.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC10df6b1378b8: Force port 0 in I2P
Summary

net: change assumed I2P port to 0

  • When accepting an I2P connection, assume the peer has port 0 instead of the default 8333 (for mainnet). It is not being sent to us, so we must assume something.
  • When deriving our own I2P listen CService use port 0 instead of the default 8333 (for mainnet). So that we later advertise it to peers with port 0.

In the I2P protocol SAM 3.1 and older (we use 3.1) ports are not used,
so they are irrelevant. However in SAM 3.2 and newer ports are used and
from the point of view of SAM 3.2, a peer using SAM 3.1 seems to have
specified port=0.

net: distinguish default port per network

Change CChainParams::GetDefaultPort() to return 0 if the network is
I2P.

net: do not connect to I2P hosts on port!=0

When connecting to an I2P host we don't specify destination port and it
is being forced to 0 by the SAM 3.1 proxy, so if we connect to the same
host on two different ports, that would be actually two connections to
the same service (listening on port 0).

Fixes https://github.com/bitcoin/bitcoin/issues/21389

test: ensure I2P ports are handled as expected

doc: mention that we enforce port=0 in I2P

Co-authored-by: Jon Atack <jon@atack.com>

This is a backport of core#22112 and core#22497 (reverts all changes to addrman and addrman_tests.cpp)

Test Plan

ninja all check-all

Event Timeline

PiRK requested review of this revision.Feb 21 2022, 13:16

Use the correct project name is the documentation (ABC).

This revision is now accepted and ready to land.Feb 21 2022, 14:45
This revision was automatically updated to reflect the committed changes.