HomePhabricator

Force port 0 in I2P

Description

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

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D11083

Details

Provenance
Vasil Dimov <vd@FreeBSD.org>Authored on May 31 2021, 15:18
PiRKCommitted on Feb 22 2022, 08:40
PiRKPushed on Feb 22 2022, 08:40
Reviewer
Restricted Project
Differential Revision
D11083: Force port 0 in I2P
Parents
rABC96e8702ac80d: [Cashtab] [utxo opt. part 3 of 8] Add function whichUtxosWereConsumed
Branches
Unknown
Tags
Unknown

Event Timeline