Skip to content

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

Closed
w0xlt wants to merge 4 commits into
bitcoin:masterfrom
w0xlt:fix-33471-cjdns-externalip
Closed

w0xlt wants to merge 4 commits into
bitcoin:masterfrom
w0xlt:fix-33471-cjdns-externalip

Conversation

@w0xlt

@w0xlt w0xlt commented Mar 12, 2026 •

Copy link
Copy Markdown
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.

@DrahtBot

DrahtBot commented Mar 12, 2026 •

Copy link
Copy Markdown
Contributor

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

Code Coverage & Benchmarks

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

Reviews

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

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)
  • #17783 (common: Disallow calling IsArgSet() on ALLOW_LIST options by ryanofsky)
  • #17581 (refactor: Remove settings merge reverse precedence code by ryanofsky)
  • #17580 (refactor: Add ALLOW_LIST flags and enforce usage in CheckArgFlags by ryanofsky)
  • #17493 (util: Forbid ambiguous multiple assignments in config file by ryanofsky)

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.

@w0xlt
w0xlt marked this pull request as draft March 12, 2026 06:55
@w0xlt
w0xlt force-pushed the fix-33471-cjdns-externalip branch 2 times, most recently from 99b1006 to 0513c9f Compare March 12, 2026 08:21
@w0xlt
w0xlt marked this pull request as ready for review March 12, 2026 08:26
@DrahtBot DrahtBot added P2P and removed CI failed labels Mar 12, 2026
@w0xlt

w0xlt commented Mar 12, 2026

Copy link
Copy Markdown
Contributor Author

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.

@luke-jr

luke-jr commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

Why wouldn't this also apply to Tor?

@w0xlt

w0xlt commented Mar 19, 2026

Copy link
Copy Markdown
Contributor Author

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.

@sedited

sedited commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

@w0xlt can you rebase this?

@w0xlt
w0xlt force-pushed the fix-33471-cjdns-externalip branch from 0513c9f to dbabe2f Compare June 6, 2026 01:30
@w0xlt

w0xlt commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

@sedited Done.

@w0xlt

w0xlt commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

Rebased again.

w0xlt added 4 commits June 10, 2026 16:13
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
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.
@w0xlt
w0xlt force-pushed the fix-33471-cjdns-externalip branch from 8d6df90 to 636a515 Compare June 10, 2026 23:14
Comment on lines +4 to +5
- Nodes configured with `-cjdnsreachable` now advertise their CJDNS address
even when `-externalip` is set. Previously, specifying `-externalip`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@DrahtBot

DrahtBot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

@w0xlt

w0xlt commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Closing this PR since CJDNS is being considered for removal from the project.

@w0xlt w0xlt closed this Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistent CJDNS address handling in Local addresses and AddLocal logs

5 participants