Skip to content

feat: add external proxy support (HTTP/SOCKS5 dialer)#57

Open
pranavthakur0-0 wants to merge 1 commit intoZenPrivacy:masterfrom
pranavthakur0-0:feat/external-proxy
Open

feat: add external proxy support (HTTP/SOCKS5 dialer)#57
pranavthakur0-0 wants to merge 1 commit intoZenPrivacy:masterfrom
pranavthakur0-0:feat/external-proxy

Conversation

@pranavthakur0-0
Copy link

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

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.
@coderabbitai
Copy link

coderabbitai bot commented Mar 3, 2026

Warning

Rate limit exceeded

@pranavthakur0-0 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 10 minutes and 54 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 8488c49 and 7011064.

📒 Files selected for processing (3)
  • proxy/proxy.go
  • proxy/upstream.go
  • proxy/websocket.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

Add support for chaining proxies

1 participant