Commit Graph

24 Commits

Author SHA1 Message Date
liasica 02328e59a2 fix(proxy): make SOCKS5 upstream username/password authentication reliable
Two independent root causes were producing auth failures on the upstream
SOCKS5 dial path:

1. `url::Url::username()` / `Url::password()` return percent-encoded
   strings per the WHATWG URL spec, but the producer side already
   percent-encodes the credentials when assembling the upstream URL —
   so the upstream was receiving `%40` instead of `@` and authentication
   silently failed for any credential containing `@ : / + = % ! space`
   or non-ASCII characters. Centralize the decode in a new
   `upstream_userpass` helper and route all four upstream-dial sites
   through it (HTTP CONNECT → SOCKS5, HTTP CONNECT → HTTP Basic-Auth,
   local SOCKS5 → HTTP Basic-Auth, local SOCKS5 → SOCKS5). The
   Shadowsocks path already decoded manually and is unchanged.

2. async_socks5 0.6 issues a `write_u8` for every single-byte field of
   the SOCKS5 method-selection and RFC1929 sub-negotiation. On a raw
   `TcpStream` each call becomes its own TCP segment, and some upstream
   SOCKS5 implementations treat this fragmented submission as a
   misbehaving client and silently FIN instead of returning a status —
   curl with the same credentials succeeds because it buffers each
   sub-message into a single send(). Wrap the upstream socket in
   `tokio::io::BufStream` (the usage pattern the async_socks5 README
   shows) and enable TCP_NODELAY so flushes leave unsegmented.

Includes unit tests covering percent-decode for ASCII / special-char /
non-ASCII / no-credentials / username-only inputs, plus a trace-level
SOCKS5 handshake byte logger that can be enabled with
RUST_LOG=donutbrowser_lib::proxy_server=trace for future debugging.
2026-06-19 20:03:24 +08:00
zhom 9dc9e13182 refactor: switch local proxy from http to socks 2026-06-17 18:33:09 +04:00
zhom 15f3aa03f7 refactor: cleanup 2026-06-08 00:06:44 +04:00
zhom f81e8b6162 refactor: more robust camoufox proxy handling 2026-05-26 04:40:19 +04:00
zhom 722aaecbbe refactor: proxy spawn 2026-05-11 23:13:03 +04:00
zhom 34450ad06b refactor: cleanup 2026-05-05 22:34:56 +04:00
zhom dfc8f80ba5 refactor: wayfern launch 2026-04-13 02:47:16 +04:00
zhom ce63eccfa4 feat: shadowsocks 2026-04-12 13:54:50 +04:00
zhom 35723de96a feat: dns block lists 2026-03-31 14:21:31 +04:00
zhom 116a54942d refactor: networking 2026-03-20 02:45:11 +04:00
zhom 8511535d69 refactor: socks5 chaining 2026-03-16 17:48:02 +04:00
zhom 76dd0d84e8 refactor: check proxy validity via donut-proxy 2026-03-16 15:48:00 +04:00
zhom 8a96d18e46 feat: extension management 2026-03-02 07:26:42 +04:00
zhom f1c4245c5a chore: linting 2025-12-21 13:52:06 +04:00
zhom 7518ee9e87 fix: prevent duplicate header 2025-12-21 13:23:33 +04:00
zhom ab8db06dfb refactor: more robust proxy connection 2025-12-21 13:23:33 +04:00
zhom cc74589243 refactor: reduce disk usage for proxy data sharing 2025-12-21 13:23:33 +04:00
zhom 1c5444928d refactor: flush consistently 2025-12-02 23:06:30 +04:00
zhom 57ead61139 refactor: reduce cpu usage for proxies 2025-12-02 22:30:40 +04:00
zhom c43f141907 refactor: better error handling 2025-12-01 01:46:28 +04:00
zhom f098128988 refactor: cleanup bandwidth tracking functionality 2025-11-30 16:55:23 +04:00
zhom cdba9aac33 feat: add network overview 2025-11-30 15:04:48 +04:00
zhom 0b63ad6556 refactor: add proper logging 2025-11-26 20:21:17 +04:00
zhom 64328e91a2 refactor: migrate proxy functionality from nodecar to rust sidecar 2025-11-25 20:43:12 +04:00