net: advertise CJDNS addresses when `-externalip` disables discovery #34812

pull w0xlt wants to merge 4 commits into bitcoin:master from w0xlt:fix-33471-cjdns-externalip changing 8 files +210 −6
  1. w0xlt commented at 1:51 AM on March 12, 2026: contributor

    Fixes #33471

    When -externalip is set, -discover is implicitly disabled. This prevents CJDNS bound addresses from being added to localaddresses, so the node never advertises itself on the CJDNS network - even though outbound CJDNS connections work fine.

    CJDNS addresses live on a separate overlay network and don't conflict with manually specified external IPs, so there is no reason to suppress them. This PR adds CJDNS exceptions to the three code paths in net.cpp that gate on fDiscover:

    • AddLocal() — accept CJDNS regardless of fDiscover
    • Discover() — don't skip CJDNS-prefixed interfaces when !fDiscover
    • Bind() — call AddLocal() for CJDNS bound addresses when !fDiscover

    Note to reviewers: the functional test (feature_cjdns_externalip.py) requires Docker to create an fc00::/8 bridge interface and is skipped when Docker is unavailable. It is included so reviewers can easily verify the fix end-to-end, but can be easily dropped (it's in a separate commit) if the dependency is unwanted. Note that this test cannot be run in CI containers.

  2. DrahtBot commented at 1:52 AM on March 12, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34812.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #34931 (validation: abort on DB unreadable coins instead of treating them as missing by furszy)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  3. DrahtBot added the label CI failed on Mar 12, 2026
  4. w0xlt marked this as a draft on Mar 12, 2026
  5. w0xlt force-pushed on Mar 12, 2026
  6. w0xlt force-pushed on Mar 12, 2026
  7. w0xlt marked this as ready for review on Mar 12, 2026
  8. DrahtBot removed the label CI failed on Mar 12, 2026
  9. DrahtBot added the label P2P on Mar 12, 2026
  10. w0xlt commented at 5:36 PM on March 12, 2026: contributor

    To reproduce the error and verify the fix manually, run ./build/bin/bitcoind -cjdnsreachable -externalip=<ip> -daemon and then ./build/bin/bitcoin-cli getnetworkinfo | jq '.localaddresses'.

    On master, the fc00:: address is missing. In this branch, both fc00:: and <ip> appear.

  11. luke-jr commented at 4:39 PM on March 18, 2026: member

    Why wouldn't this also apply to Tor?

  12. w0xlt commented at 12:32 AM on March 19, 2026: contributor

    Tor onion services are handled differently. The automatically created onion service is added in TorController::add_onion_cb() via AddLocal(service,LOCAL_MANUAL), so it does not hit the fDiscover check in AddLocal(), because that check only rejects addresses with nScore < LOCAL_MANUAL.

  13. DrahtBot added the label Needs rebase on Mar 26, 2026
  14. sedited commented at 8:53 AM on June 5, 2026: contributor

    @w0xlt can you rebase this?

  15. w0xlt force-pushed on Jun 6, 2026
  16. DrahtBot removed the label Needs rebase on Jun 6, 2026
  17. w0xlt commented at 5:44 AM on June 6, 2026: contributor

    @sedited Done.

  18. sedited requested review from vasild on Jun 7, 2026
  19. DrahtBot added the label Needs rebase on Jun 10, 2026
  20. w0xlt force-pushed on Jun 10, 2026
  21. w0xlt commented at 10:32 PM on June 10, 2026: contributor

    Rebased again.

  22. net: allow CJDNS addresses when -externalip disables discovery
    When -externalip is set, -discover is implicitly disabled. This
    prevented CJDNS addresses from being registered in mapLocalHost
    (shown in the localaddresses RPC field), even though CJDNS operates
    on a separate overlay network unrelated to the node's public
    IPv4/IPv6 address.
    
    Note: registering in mapLocalHost is a prerequisite for address
    advertisement, but GetLocal() already ensures CJDNS addresses are
    only advertised to CJDNS peers (privacy network isolation).
    
    Fix three code paths that blocked CJDNS when fDiscover was false:
    
    - Discover(): skip the early return for CJDNS-prefix addresses
    - AddLocal(): allow CJDNS addresses regardless of discovery score
    - Bind(): register bound CJDNS addresses even without discovery
    361aa7262e
  23. test: unit test CJDNS AddLocal() discovery gating 9cdf4e21ab
  24. doc: release note for CJDNS address advertising with -externalip a660afa40d
  25. test: add functional test for CJDNS address with -externalip
    Verify that a CJDNS address bound via -bind is registered in
    localaddresses even when -externalip is set (which disables
    -discover). The test creates a Docker network with an fc00::/8
    subnet to provide a bindable CJDNS-prefix address.
    636a515d7b
  26. w0xlt force-pushed on Jun 10, 2026
  27. DrahtBot added the label CI failed on Jun 10, 2026
  28. DrahtBot removed the label Needs rebase on Jun 10, 2026
  29. DrahtBot removed the label CI failed on Jun 11, 2026
  30. in doc/release-notes-34812.md:5 in 636a515d7b
       0 | @@ -0,0 +1,9 @@
       1 | +P2P and network changes
       2 | +-----------------------
       3 | +
       4 | +- Nodes configured with `-cjdnsreachable` now advertise their CJDNS address
       5 | +  even when `-externalip` is set. Previously, specifying `-externalip`
    


    vasild commented at 1:44 PM on June 18, 2026:

    I commented on the issue #33471 (comment)

    This will change bitcoind to run auto discovery for some networks (CJDNS) even if -externalip= is used but not for others (IPv4, IPv6). That seems non-intuitive.


    w0xlt commented at 9:23 PM on June 18, 2026:

    Thanks. I replied there. Better to keep the conversation in one place.


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-06-21 02:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me