feat: add external proxy support (HTTP/SOCKS5 dialer)#57
feat: add external proxy support (HTTP/SOCKS5 dialer)#57pranavthakur0-0 wants to merge 1 commit intoZenPrivacy:masterfrom
Conversation
Add proxy.Dialer interface to route outbound connections through an external HTTP or SOCKS5 proxy. Defaults to proxy.Direct (unchanged). Changes: - New proxy/upstream.go: ExternalProxyConfig, WithExternalProxy option, httpConnectDialer implementing proxy.Dialer for HTTP CONNECT proxies. SOCKS5 uses golang.org/x/net/proxy (existing dependency). - proxy/proxy.go: Added dialer field, NewProxy accepts ...ProxyOption, requestTransport and tunnel() use p.dialer.Dial instead of net.Dial. - proxy/websocket.go: proxyWebsocket and proxyWebsocketTLS use p.dialer.Dial with manual TLS upgrade for external proxy support.
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Here's the PR description as plain text:
What does this PR do?
This PR adds external proxy support to the Zen proxy, allowing all outbound connections to be routed through an HTTP or SOCKS5 upstream proxy. This enables Zen to work alongside VPNs, corporate proxies, and tools like Tor that use proxy tunneling.
How it works
A new dialer field (proxy.Dialer) is added to the Proxy struct, defaulting to proxy.Direct (direct TCP connection — identical to current behavior). When an external proxy is configured via WithExternalProxy(), the dialer is swapped to either a proxy.SOCKS5 dialer (from golang.org/x/net/proxy, an existing dependency) or a custom httpConnectDialer for HTTP CONNECT proxies with optional Basic auth. All outbound connection points (requestTransport, tunnel(), proxyWebsocket(), proxyWebsocketTLS()) now use p.dialer.Dial instead of net.Dial / p.netDialer.Dial. Errors during SOCKS5 dialer creation and unsupported protocol values are logged rather than silently ignored.
Files changed
proxy/upstream.go (NEW) — ExternalProxyConfig struct, ProxyOption type, WithExternalProxy() functional option, httpConnectDialer with Basic auth support
proxy/proxy.go — Added dialer proxy.Dialer field; NewProxy() accepts ...ProxyOption; requestTransport.Dial and tunnel() use p.dialer.Dial
proxy/websocket.go — proxyWebsocket() and proxyWebsocketTLS() use p.dialer.Dial with manual TLS upgrade
How did you verify your code works?
go build ./... passes with no errors. No regression: default behavior is unchanged since proxy.Direct is the default dialer.
What are the relevant issues?
Closes ZenPrivacy/zen-desktop#609