Commit 88b99b6
committed
bitreq: add SOCKS5 proxy support
Add SOCKS5 proxy support (RFC 1928) alongside existing HTTP CONNECT.
Uses domain-based addressing (ATYP 0x03) so DNS resolution happens at
the proxy, enabling .onion routing through Tor.
New public API:
- `Proxy::new_socks5(addr)` for unauthenticated SOCKS5. Accepts both
`socks5://` and `socks5h://` URL schemes; both behave identically
since destination hostnames are always forwarded to the proxy.
- `Proxy::new_socks5_with_credentials(addr, user, pass)` for RFC 1929
username/password auth at construction.
- `Proxy::set_credentials(user, pass)` to mutate credentials on an
existing `Proxy`. Lets a caller hold one `Proxy` and rotate
credentials for Tor circuit isolation without rebuilding from URL.
Both sync and async handshake paths share protocol logic via helpers,
with only I/O differing between them.
Motivation: ldk-node needs to route HTTP calls (RGS, scoring) through
Tor's SOCKS proxy. See lightningdevkit/ldk-node#834.
Tests: 10 parsing/credential tests + 8 mock handshake tests covering
success, .onion domains, server rejection, port encoding, domain
length validation, credential auth, credential rejection, no-auth
fallback, and credential rotation.1 parent 774a655 commit 88b99b6
3 files changed
Lines changed: 720 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
14 | 33 | | |
15 | 34 | | |
16 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
336 | 336 | | |
337 | 337 | | |
338 | 338 | | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
339 | 345 | | |
340 | | - | |
| 346 | + | |
341 | 347 | | |
342 | 348 | | |
343 | 349 | | |
| |||
709 | 715 | | |
710 | 716 | | |
711 | 717 | | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
712 | 724 | | |
713 | | - | |
| 725 | + | |
714 | 726 | | |
715 | 727 | | |
716 | 728 | | |
| |||
0 commit comments