feat: skip onion maker addresses when Tor is disabled#1150
Open
pokefan77 wants to merge 1 commit into
Open
Conversation
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.
563eb72 to
78d5219
Compare
Author
|
compiled and tested locally. behaviour as expected. doesnt dial onions with tor disabled, does dial onions with tor enabled. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.