Skip to content

net: onion AddrMan, --only-net, SOCKS dial of .onion - #645

Merged
reardencode merged 13 commits into
net/listen-offfrom
net/onion-addrman
Sep 21, 2026
Merged

reardencode merged 13 commits into
net/listen-offfrom
net/onion-addrman

Conversation

@rearden-grok

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

Copy link
Copy Markdown
Contributor

Plan docs/personal-node-plans/02-onion-addrman.md: BIP155 Tor v3 rows stay in the peer book, persist as rbitcoin-peers-v2, and dial through the SOCKS client from #641.

Stacked on #644 (net/listen-off). NixOS onlyNet is eval-only argv; this PR does not change systemd After/Wants and is not labeled nixos-module-runtime.

Summary

  • NetAddr::{Ip,Onion} with Tor v3 SHA3 checksum parse/display; learn_addrv2 keeps AddrV2::TorV3.
  • Peers file v2 writes .onion:port; v1 IPv4/IPv6 files still load.
  • Dialer::connect_net SOCKS ATYP=3 for onion; Direct onion is an error. --only-net=onion without --proxy/--onion is a start error.
  • --connect / --seed-node accept ….onion:port. --only-net is repeatable ipv4/ipv6/onion (i2p/cjdns stay unknown until 04/08).
  • NixOS first-class services.rbitcoin.onlyNet list; eval asserts --only-net onion when set.

Test plan

  • cargo test -p rbitcoin-net --lib netaddr_
  • cargo test -p rbitcoin-net --lib learn_addrv2 / addrman / peers_file_
  • cargo test -p rbitcoin-net --lib dial_onion_
  • cargo test -p rbitcoin-node --lib connect_onion / only_net_
  • 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
  • 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 13 commits September 20, 2026 19:24
AddrMan is still SocketAddr-keyed; onion rows need a stable pubkey+port
identity with checksummed .onion display before they can be stored.

Co-authored-by: Cursor <cursoragent@cursor.com>
learn_addrv2 dropped onion because AddrMan was SocketAddr-keyed.
The book now stores NetAddr; clearnet dial and peers-v1 save still
use the Ip arm so existing IBD paths stay unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
Onion rows were dropped on save because v1 tokens were SocketAddr-only.
v2 writes .onion:port; v1 IPv4/IPv6 files still load.

Co-authored-by: Cursor <cursoragent@cursor.com>
Onion outbound must not TcpStream::connect or local DNS. Dialer::connect_net
sends ATYP=3 through --proxy/--onion SOCKS; Direct onion is an error.

Co-authored-by: Cursor <cursoragent@cursor.com>
Operator-pinned peers are NetAddr so .onion:port is a start error when
invalid, not a silent SocketAddr parse miss.

Co-authored-by: Cursor <cursoragent@cursor.com>
Repeatable ipv4/ipv6/onion. i2p/cjdns stay unknown until later plans.
only-net=onion without --proxy/--onion is a start error.

Co-authored-by: Cursor <cursoragent@cursor.com>
NixOS onlyNet list emits --only-net per entry. OPERATOR documents peers
v2, SOCKS required for onion, and kebab --only-net.

Co-authored-by: Cursor <cursoragent@cursor.com>
`--all-targets` also needs the run_p2p integration connect list as
NetAddr after ListenOpts.connect left SocketAddr.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
PeerEvent::Addrs was Vec<SocketAddr>, so onion-only IBD dropped learned
Tor v3 rows and could not redial from getaddr.

Co-authored-by: Cursor <cursoragent@cursor.com>
Domain peers parsed back through 0.0.0.0, so VERSION/LivePeer lost the
onion NetAddr. Name the dummy version_socket and parse Domain as onion.

Co-authored-by: Cursor <cursoragent@cursor.com>
@reardencode
reardencode added this pull request to stack #669 September 21, 2026 03:40
@reardencode
reardencode merged commit 1c5cc90 into master Sep 21, 2026
18 of 19 checks passed
@rearden-grok
rearden-grok Bot deleted the net/onion-addrman branch September 21, 2026 03:44
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