net: make address overlap impossible when relaying addresses

bitcoin/bitcoin: PR #36954

1 suggestion

Optional improvements

Link

[suggestion] · Regression test misses the IPv6/CJDNS same-bytes overlap

The new tor_i2p_same_bytes test would still pass if GetKey() accidentally assigned IPv6 and CJDNS the same prefix, restoring another cross-network key overlap.

Location: src/test/net_tests.cpp:1845 (head).

Details and suggested fix

GetAddrBytes() preserves the raw 16 address bytes for both IPv6 and CJDNS, so matching bytes and ports produce equal GetKey(false) results. The current prefixes correctly separate them, but none of the new assertions exercises that distinction. Add a paired case using Lookup("fc00:3344:5566:7788:9900:aabb:ccdd:eeff", 8333, false) for the IPv6 service and, after enabling NET_CJDNS in g_reachable_nets, MaybeFlipIPv6toCJDNS for its CJDNS copy, following the existing advertise_local_address fixture. Assert the network types, equal GetKey(false) results, and different GetKey(true) and default GetKey() results. This would detect a shared-prefix regression independently of the Tor/I2P case.


Coverage details