It is possible to open >1 connections to the same I2P node
Expected behavior
addnode should not open a second connection even if the destination port is different for I2P nodes.
Actual behavior
A second connection is being opened even though ports are irrelevant and we actually connect to the same node two times.
To reproduce
# Set up two I2P nodes A and B.
node_a$ bitcoin-cli addnode bbb.b32.i2p:8333 onetry
# If we would try the same again it would not open a second connection,
# but trying on a different port does.
node_a$ bitcoin-cli addnode bbb.b32.i2p:8833 onetry # notice it is different port
node_a$ bitcoin-cli getpeerinfo |jq 'map(select(.network == "i2p")) |map({inbound: .inbound, addr: .addr, addrbind: .addrbind})'
[
{
"inbound": false,
"addr": "bbb.b32.i2p:8333",
"addrbind": "aaa.b32.i2p:8333"
},
{
"inbound": false,
"addr": "bbb.b32.i2p:8833",
"addrbind": "aaa.b32.i2p:8333"
}
]
# Both connections are established, but in I2P ports are ignored,
# so we actually connected two times to the same node.
# This is how it looks on the B's end:
node_b$ bitcoin-cli getpeerinfo |jq 'map(select(.network == "i2p")) |map({inbound: .inbound, addr: .addr, addrbind: .addrbind})'
[
{
"inbound": true,
"addr": "aaa.b32.i2p:8333",
"addrbind": "bbb.b32.i2p:8333"
},
{
"inbound": true,
"addr": "aaa.b32.i2p:8333",
"addrbind": "bbb.b32.i2p:8333"
}
]