dsh-proxy — hot-swappable outbound proxy for every DSH request (manual / system / direct, zero restarts) #5886
tr1v3r
started this conversation in
Show Your Plugins!
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I made a DSH plugin that routes every in-process outbound request — LLM providers,
web_search/web_fetch, streamable-http MCP — through a proxy you can switch at runtime, without restarting dsh. One hot-reloaded settings section picks the strategy:manual— route through yourproxyURL:http(s)://CONNECT orsocks5://(URL credentials supported,socks5h://accepted), with anoProxybypass listsystem— just follow the host:HTTP_PROXY/HTTPS_PROXY/ALL_PROXY/NO_PROXYenv everywhere (socksALL_PROXYincluded), falling back to the macOS System Settings network proxy (scutil --proxy) when env is unset; re-detected on every savedirect— no proxyEvery save takes effect immediately — proxy on, off, re-pointed at another server, or switched between manual and system. The GIF above is a real recording walking all three; the full boot-verified flow (settings watcher → dispatcher swap → live fetch) is in the repo's probe.
How it works: DSH and pi-ai issue requests via
globalThis.fetch, which reads undici's well-known global dispatcher slot. The plugin owns that slot.http(s)://→EnvHttpProxyAgent(CONNECT tunneling);socks5://→ undici's nativeSocks5ProxyAgenthost:portpins a port,*bypasses all); ambientNO_PROXY/HTTP_PROXYenv is deliberately ignored in manual mode so routing is fully settings-drivenexportEnv(manual mode) mirrors the switch into child-process env —curl/git/stdio MCP servers spawned after a switch follow along; operator-set variables are never clobberedKnown limits: Windows registry / PAC / Linux-desktop proxy detection not yet covered in
systemmode; pi-ai's Bedrock route manages its own proxying via AWS SDK env; the built-in browser host is a separate process and is not routed.Restart once to mount — after that, never again for switching.
All reactions