Skip to content

net: SOCKS5 --proxy for P2P outbound - #641

Open
rearden-grok[bot] wants to merge 10 commits into
masterfrom
net/socks-proxy
Open

rearden-grok[bot] wants to merge 10 commits into
masterfrom
net/socks-proxy

Conversation

@rearden-grok

@rearden-grok rearden-grok Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Plan docs/personal-node-plans/00-socks-proxy.md: every P2P outbound dial goes through a SOCKS5 CONNECT when --proxy is set.

Summary

  • Hand-rolled SOCKS5 client (Dialer::{Direct,Socks}) is the only outbound TCP path (IBD spawn, tip-follow, feeler).
  • --proxy / --onion / --proxy-randomize (default on) CLI + snake conf; empty/invalid proxy is a start error.
  • With --proxy, DNS/fixed seeds are not ToSocketAddrs locally (use --connect / peers). Isolation creds are fresh per peer unless --proxy-randomize=0.
  • NixOS first-class services.rbitcoin.proxy / onionProxy / proxyRandomize (not extraArgs). Eval pins argv. No services.tor in the fixture.

First of the stacked home-node plans (00–09). Fake SOCKS only — no live Tor.

Test plan

  • cargo test -p rbitcoin-net --lib socks5_ / outbound_dial_uses_proxy_when_set / dns_seeds_not_resolved_locally_when_proxy
  • cargo test -p rbitcoin-node --lib proxy_ / proxy_randomize_defaults_on / dns_seeds_not_resolved_locally_when_proxy
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo deny check / ./scripts/ast-grep.sh / cargo fmt --all -- --check
  • nix build .#checks.x86_64-linux.nixos-module-eval --no-link
  • ./scripts/ci-os-smoke.sh
  • required GitHub checks green (fmt, deny, clippy, ast-grep, test, windows, macos, coverage, nixos-module-eval)

Made with Cursor

rearden-grok Bot and others added 10 commits September 20, 2026 14:34
Hand-rolled client so P2P outbound can tunnel via system Tor. Test
records ATYP=1 and echoes a byte through the tunnel. No live Tor.

Co-authored-by: Cursor <cursoragent@cursor.com>
ATYP=3 sends the hostname bytes so seed lookup can use remote DNS through
the proxy. One CONNECT encoder covers IPv4, IPv6, and domain.

Co-authored-by: Cursor <cursoragent@cursor.com>
ProxyCreds::fresh and dial_isolated mint a new RFC 1929 username per
call so Tor can isolate circuits. Fake proxy records the bytes.

Co-authored-by: Cursor <cursoragent@cursor.com>
spawn_peer, tip-follow, and feelers share one Dialer. A fake SOCKS
splice plus BIP324 handshake proves CONNECT is used; Direct is unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
Operator SOCKS is a ListenOpts dialer passed into P2P start and IBD,
so outbound never bypasses the proxy when one is configured.

Co-authored-by: Cursor <cursoragent@cursor.com>
SOCKS does remote DNS; ToSocketAddrs on seed hostnames would leak
queries off-proxy. --proxy-randomize stays on unless explicitly off.

Co-authored-by: Cursor <cursoragent@cursor.com>
Home-node Tor SOCKS is a module option and OPERATOR flag, not extraArgs.
proxyRandomize stays on so Tor isolates circuits unless the operator
turns it off.

Co-authored-by: Cursor <cursoragent@cursor.com>
Catch-up and retry already start through P2PNode; cloning that dialer
keeps SOCKS on the IBD path without growing run_ibd_or_skip's arity.

Co-authored-by: Cursor <cursoragent@cursor.com>
Coverage CRAP flagged the unused Dialer domain path. The SOCKS encoder
was already tested; this drives the production Dialer match arms.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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.

0 participants