Ava Chow e2174378aa
Merge bitcoin/bitcoin#32539: init: Configure reachable networks before we start the RPC server
12ff4be9c724c752fe67835419be3ff4d0e65990 test: ensure -rpcallowip is compatible with RFC4193 (Matthew Zipkin)
c02bd3c1875abd877a0dc73fb8866c883b7fcd32 config: Explain RFC4193 and CJDNS interaction in help and init error (Matthew Zipkin)
f728b6b11100fae1e27f7a0ef92a5930fa8cffb3 init: Configure reachable networks before we start the RPC server (Matthew Zipkin)

Pull request description:

  Closes https://github.com/bitcoin/bitcoin/issues/32433

  `MaybeFlipIPv6toCJDNS()` relies on `g_reachable_nets` to distinguish between CJDNS addresses and other IPv6 addresses. In particular, [RFC4193](https://www.rfc-editor.org/rfc/rfc4193#section-3.1) address or "Unique Local Address" with the L-bit unset also begins with the `fc` prefix. #32433 highlights a use case for these addresses that have nothing to do with CJDNS.

  On master we don't parse init flags like `-cjdnsreachable` until *after* the HTTP server has started, causing conflicts with `-rpcallowip` because CJDNS doesn't support subnets.

  This PR ensures that `NET_CJDNS` is only present in the reachable networks list if set by `-cjdnsreachable` *before* `-rpcallowip` is checked. If it is set all `fc` addresses are assumed to be CJDNS, can not have subnets, and can't be set for `-rpcallowip`.

  I also noted this specific parameter interaction in the init help as well as the error message if configured incorrectly.

  This can be tested locally:

  `bitcoind -regtest -rpcallowip=fc00:dead:beef::/64 -rpcuser=u -rpcpassword=p`

  On master this will just throw an error that doesn't even mention IPv6 at all.

  On the branch, this will succeed and can be tested by adding the ULA to a local interface.

  On linux: `sudo ip -6 addr add fc00:dead:beef::1/64 dev lo`

  On macos: `sudo ifconfig lo0 inet6 fc00:dead:beef::1/128 add`

  then: `curl -v -g -6 --interface fc00:dead:beef::1 u:p@[::1]:18443 --data '{"method":"getblockcount"}'`

  If the `rpcallowip` option is removed, the RPC request will fail to authorize.

  Finally, adding `-cjdnsreachable` to the start up command will throw an error and specify the incompatibility:

  > RFC4193 is allowed only if -cjdnsreachable=0.

ACKs for top commit:
  achow101:
    ACK 12ff4be9c724c752fe67835419be3ff4d0e65990
  tapcrafter:
    tACK 12ff4be9c724c752fe67835419be3ff4d0e65990
  ryanofsky:
    Code review ACK 12ff4be9c724c752fe67835419be3ff4d0e65990
  willcl-ark:
    ACK 12ff4be9c724c752fe67835419be3ff4d0e65990

Tree-SHA512: a4dd70ca2bb9f6ec2c0a9463fd73985d1ed80552c674a9067ac9a86662d1c018cc275ba757cebb2993c5f3971ecf4778b95d35fe7a7178fb41b1d18b601c9960
2025-06-06 15:31:36 -07:00
..
2025-06-03 08:09:28 +01:00
2025-05-08 16:49:58 +01:00
2025-05-20 11:14:17 +01:00
2025-05-19 16:40:33 +01:00
2025-06-03 08:09:21 +01:00
2025-05-14 14:00:43 -07:00
2025-05-19 16:40:33 +01:00
2025-05-19 16:40:33 +01:00
2025-03-13 11:13:13 +00:00
2025-05-20 09:30:41 +01:00
2024-11-26 20:47:08 -05:00
2025-05-19 16:40:33 +01:00
2025-05-06 12:21:32 -07:00
2025-05-19 16:40:33 +01:00
2024-11-04 14:19:40 -05:00
2025-06-03 08:09:21 +01:00
2025-01-22 11:29:05 +01:00
2025-05-08 16:49:58 +01:00
2025-06-03 08:09:28 +01:00
2024-12-31 00:04:20 -03:00
2024-12-31 00:04:20 -03:00
2025-05-19 16:40:33 +01:00
2025-04-09 15:59:59 +01:00
2025-04-09 15:59:59 +01:00
2025-06-03 08:09:21 +01:00