Skip to content

feat: skip onion maker addresses when Tor is disabled#1150

Open
pokefan77 wants to merge 1 commit into
eigenwallet:masterfrom
pokefan77:feat/tor-filter-onion-dials
Open

feat: skip onion maker addresses when Tor is disabled#1150
pokefan77 wants to merge 1 commit into
eigenwallet:masterfrom
pokefan77:feat/tor-filter-onion-dials

Conversation

@pokefan77

@pokefan77 pokefan77 commented Jul 3, 2026

Copy link
Copy Markdown

When Tor is disabled the CLI/GUI has no Tor transport, so /onion3 addresses fall
through to TCP+DNS and always fail the dial — wasting dial budget and producing
noisy failures.

This filters onion (/onion, /onion3) addresses out of the dial candidates when
Tor is off, while still dialing the clearnet addresses of the same maker.

fixes where a maker advertising both onion and clearnet but is
unreachable with Tor off, because the onion address was attempted over the
clearnet transport instead of using the working clearnet address.

this also covers rendezvous nodes: onion-only rendezvous points are no longer
dialed with Tor off, and clearnet rendezvous addresses are used instead.

Revised implementation notes:
Adds TorDialFilter, a NetworkBehaviour wrapper (tor_dial_filter.rs) that, when Tor is disabled, strips /onion and /onion3 addresses from the candidate list the inner behaviour returns from handle_pending_outbound_connection. When Tor is enabled it's a transparent pass-through.
Wraps the top-level CLI/Bob behaviour with it. libp2p builds an address-less dial's candidate list by concatenating every behaviour's handle_pending_outbound_connection output, so filtering once at this choke point covers every address source — redial, identify, and each request_response per-peer address book — plus rendezvous-discovered peers, instead of fragile per-behaviour filtering.
tor_enabled is derived from the same maybe_tor_client.is_some() that decides whether the transport can dial onion at all (threaded through swarm.rs and event_loop.rs), so the filter and the transport can never disagree.
The ASB behaviour is unchanged (no filtering).
Adds a CHANGELOG entry.

@pokefan77

Copy link
Copy Markdown
Author

This is not completely working as intended yet.

Wrap the top-level CLI behaviour in TorDialFilter, which strips
/onion (and /onion3) addresses from the combined dial-candidate list
whenever Tor is disabled. Without Tor these addresses can only fail
with MultiaddrNotSupported and cause pointless redial churn.

Filtering once at the top-level choke point covers every inner
behaviour that contributes cached peer addresses (redial, identify,
and request_response address books) instead of fragile per-behaviour
filtering. tor_enabled is derived from the same maybe_tor_client that
decides whether the transport can dial onion at all, so the filter
and the transport can never disagree.
@pokefan77 pokefan77 force-pushed the feat/tor-filter-onion-dials branch from 563eb72 to 78d5219 Compare July 4, 2026 14:50
@pokefan77

Copy link
Copy Markdown
Author

compiled and tested locally. behaviour as expected. doesnt dial onions with tor disabled, does dial onions with tor enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant