mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-02 01:40:12 +02:00
Merge bitcoin/bitcoin#22112: Force port 0 in I2P
4101ec9d2edoc: mention that we enforce port=0 in I2P (Vasil Dimov)e0a2b390c1addrman: reset I2P ports to 0 when loading from disk (Vasil Dimov)41cda9d075test: ensure I2P ports are handled as expected (Vasil Dimov)4f432bd738net: do not connect to I2P hosts on port!=0 (Vasil Dimov)1f096f091enet: distinguish default port per network (Vasil Dimov)aeac3bce3enet: change I2P seeds' ports to 0 (Vasil Dimov)38f900290cnet: change assumed I2P port to 0 (Vasil Dimov) Pull request description: _This is an alternative to https://github.com/bitcoin/bitcoin/pull/21514, inspired by https://github.com/bitcoin/bitcoin/pull/21514#issuecomment-815049933. They are mutually exclusive. Just one of them should be merged._ Change assumed ports for I2P to 0 (instead of the default 8333) as this is closer to what actually happens underneath with SAM 3.1 (https://github.com/bitcoin/bitcoin/pull/21514#issuecomment-812632520, https://github.com/bitcoin/bitcoin/pull/21514#issuecomment-816564719). Don't connect to I2P peers with advertised port != 0 (we don't specify a port to our SAM 3.1 proxy and it always connects to port = 0). Note, this change: * Keeps I2P addresses with port != 0 in addrman and relays them to others via P2P gossip. There may be non-bitcoin-core-22.0 peers using SAM 3.2 and for them such addresses may be useful. * Silently refuses to connect to I2P hosts with port != 0. This is ok for automatically chosen peers from addrman. Not so ok for peers provided via `-addnode` or `-connect` - a user who specifies `foo.b32.i2p:1234` (non zero port) may wonder why "nothing is happening". Fixes #21389 ACKs for top commit: laanwj: Code review ACK4101ec9d2ejonatack: re-ACK4101ec9d2eper `git range-diffefff9c30b0ee03 4101ec9`, built with DDEBUG_ADDRMAN, did fairly extensive testing on mainnet both with and without a peers.dat / -dnsseeds=0 to test boostrapping. Tree-SHA512: 0e3c019e1dc05e54f559275859d3450e0c735596d179e30b66811aad9d5b5fabe3dcc44571e8f7b99f9fe16453eee393d6e153454dd873b9ff14907d4e6354fe
This commit is contained in:
43
test/functional/p2p_i2p_ports.py
Executable file
43
test/functional/p2p_i2p_ports.py
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2021-2021 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
"""
|
||||
Test ports handling for I2P hosts
|
||||
"""
|
||||
|
||||
import re
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
|
||||
|
||||
class I2PPorts(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 1
|
||||
# The test assumes that an I2P SAM proxy is not listening here.
|
||||
self.extra_args = [["-i2psam=127.0.0.1:60000"]]
|
||||
|
||||
def run_test(self):
|
||||
node = self.nodes[0]
|
||||
|
||||
self.log.info("Ensure we don't try to connect if port!=0")
|
||||
addr = "zsxwyo6qcn3chqzwxnseusqgsnuw3maqnztkiypyfxtya4snkoka.b32.i2p:8333"
|
||||
raised = False
|
||||
try:
|
||||
with node.assert_debug_log(expected_msgs=[f"Error connecting to {addr}"]):
|
||||
node.addnode(node=addr, command="onetry")
|
||||
except AssertionError as e:
|
||||
raised = True
|
||||
if not re.search(r"Expected messages .* does not partially match log", str(e)):
|
||||
raise AssertionError(f"Assertion raised as expected, but with an unexpected message: {str(e)}")
|
||||
if not raised:
|
||||
raise AssertionError("Assertion should have been raised")
|
||||
|
||||
self.log.info("Ensure we try to connect if port=0 and get an error due to missing I2P proxy")
|
||||
addr = "h3r6bkn46qxftwja53pxiykntegfyfjqtnzbm6iv6r5mungmqgmq.b32.i2p:0"
|
||||
with node.assert_debug_log(expected_msgs=[f"Error connecting to {addr}"]):
|
||||
node.addnode(node=addr, command="onetry")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
I2PPorts().main()
|
||||
@@ -293,6 +293,7 @@ BASE_SCRIPTS = [
|
||||
'p2p_permissions.py',
|
||||
'feature_blocksdir.py',
|
||||
'wallet_startup.py',
|
||||
'p2p_i2p_ports.py',
|
||||
'feature_config_args.py',
|
||||
'feature_settings.py',
|
||||
'rpc_getdescriptorinfo.py',
|
||||
|
||||
Reference in New Issue
Block a user