Skip to content

Commit 8d6224f

Browse files
author
MarcoFalke
committed
Merge bitcoin#19628: net: change CNetAddr::ip to have flexible size
102867c net: change CNetAddr::ip to have flexible size (Vasil Dimov) 1ea57ad net: don't accept non-left-contiguous netmasks (Vasil Dimov) Pull request description: (chopped off from bitcoin#19031 to ease review) Before this change `CNetAddr::ip` was a fixed-size array of 16 bytes, not being able to store larger addresses (e.g. TORv3) and encoded smaller ones as 16-byte IPv6 addresses. Change its type to `prevector`, so that it can hold larger addresses and do not disguise non-IPv6 addresses as IPv6. So the IPv4 address `1.2.3.4` is now encoded as `01020304` instead of `00000000000000000000FFFF01020304`. Rename `CNetAddr::ip` to `CNetAddr::m_addr` because it is not an "IP" or "IP address" (TOR addresses are not IP addresses). In order to preserve backward compatibility with serialization (where e.g. `1.2.3.4` is serialized as `00000000000000000000FFFF01020304`) introduce `CNetAddr` dedicated legacy serialize/unserialize methods. Adjust `CSubNet` accordingly. Still use `CSubNet::netmask[]` of fixed 16 bytes, but use the first 4 for IPv4 (not the last 4). Do not accept invalid netmasks that have 0-bits followed by 1-bits and only allow subnetting for IPv4 and IPv6. Co-authored-by: Carl Dong <[email protected]> ACKs for top commit: sipa: utACK 102867c MarcoFalke: Concept ACK 102867c ryanofsky: Code review ACK 102867c. Just many suggested updates since last review. Thanks for following up on everything! jonatack: re-ACK 102867c diff review, code review, build/tests/running bitcoind with ipv4/ipv6/onion peers kallewoof: ACK 102867c Tree-SHA512: d60bf716cecf8d3e8146d2f90f897ebe956befb16f711a24cfe680024c5afc758fb9e4a0a22066b42f7630d52cf916318bedbcbc069ae07092d5250a11e8f762
2 parents f8462a6 + 102867c commit 8d6224f

11 files changed

+496
-267
lines changed

doc/release-notes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ Updated settings
139139
in future releases. Refer to the help of the affected settings `-whitebind`
140140
and `-whitelist` for more details. (#19191)
141141

142+
- Netmasks that contain 1-bits after 0-bits (the 1-bits are not contiguous on
143+
the left side, e.g. 255.0.255.255) are no longer accepted. They are invalid
144+
according to RFC 4632.
145+
142146
Changes to Wallet or GUI related settings can be found in the GUI or Wallet section below.
143147

144148
Tools and Utilities

0 commit comments

Comments
 (0)