fafa1978c5bcb894e01559d2b4bf43b3ccf35ad4
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
a4bf1a039e |
netproxy: Auto goes direct while the system's loopback proxy isn't running (@bitssly on X)
@bitssly (X, magpie 0.1.4519, Windows 11 amd64): with the proxy on Auto,
every model failed with 502 "proxy not reachable" once their VPN app was
off, a restart of magpie too, until they set the proxy Off. A VPN or
proxy app that quits without clearing Internet Options leaves
ProxyEnable=1 and ProxyServer=127.0.0.1:port in HKCU, and Auto took the
system proxy as it was: every request went to a port nothing listens on.
Auto now takes a system proxy on loopback only while its port accepts a
connection (liveSystem, through the same listening check the login
shell's proxy already had: 300ms dial, kept 15s while up, 2s while down,
so the VPN coming back is followed within 2 seconds). Every route that
asks Auto goes through it: For (netproxy.Func for the gateway and every
transport, and http.DefaultClient through Install), EnvWith (the CLIs
magpie starts, Bun, and the plugin host, whose proxy check every 15s/2s
restarts it on a change) and Describe. Settings › Network says it:
source "down" reads "Nothing answers at the proxy found, {proxy};
requests go direct until it runs again", in every language.
Not changed, on purpose:
- A proxy set in magpie is never gone around: a dead one still fails.
- The environment's *_PROXY, set for this process by whoever started
it, is taken as it is, dead or not.
- A system proxy elsewhere than loopback isn't probed: a proxy that is
down can't be told from a network that drops a probe.
- internal/agent/codex_proxy.go reads the raw System(): it predicts what
Codex itself does.
- Going direct while the VPN is off means vendors see the computer's own
address. A user who needs to fail closed sets the proxy in magpie.
Run:
- win-run (xiaomi-gpu, Windows 11) go test ./internal/netproxy: ok.
TestWindowsDeadSystemProxyGoesDirect writes ProxyEnable/ProxyServer to
a scratch key that RegOverridePredefKey puts in place of HKCU, so the
box's own Internet Options are untouched. It reads them through the
real system() and the real 300ms dial: direct while nothing listens,
the proxy again once a listener runs.
- win-run go test ./internal/plugin: TestPiPackage,
TestCachedReadsSavedProvidersOnce (#7197), TestDistReadFailedIsntMissing
(#6075) and TestPluginLeavesTheUserNetworkDirect (#4115) are red on
Windows at origin/main
|
||
|
|
4e93ff9fce |
netproxy: Auto takes the login shell's *_PROXY when the system has none
jimlee0824v2 on X asked for the proxy to default by region, because
they set it in magpie by hand and take it out again. Clash's and most
proxy apps' guides have `export https_proxy=…` put in the shell
profile, with the app's "system proxy" off: every program run in a
terminal goes through it, magpie run there too, but magpie opened from
the Dock or a desktop menu has no *_PROXY, found no system proxy, and
went direct.
Auto now goes, in order: magpie's setting ("direct" too), magpie's own
environment, the system's proxy, then the login shell's HTTPS_PROXY
(https://, wss://) or HTTP_PROXY, else ALL_PROXY, with its NO_PROXY
(shell.go). Settings says "Following HTTPS_PROXY" for it, and a CLI
magpie starts is given it as it is the system's (EnvWith). A value the
user set anywhere still wins; the shell's is the user's too.
- A loopback proxy is taken only while its port has a listener, looked
at again every 2s while down and 15s while up, so a profile that
exports the proxy app's port for good doesn't cut magpie off while
the app is closed, and the app opened later is taken within 2s.
- The shell's values come from what proc last read of it (UserPath at
start, or a LoginPath since), through proc.LoginEnvSaid, a lock-free
snapshot: LoginPath holds its lock while the shell answers, and this
is read on every request. A profile edited after magpie started is
read at the next LoginPath. Windows: none (a desktop app there has
the user's environment already).
Not a region or language guess: those are wrong for anyone travelling
or on a VPN/TUN, and say nothing of whether a proxy is running. PAC
(Clash's "PAC mode" system proxy) is still not read.
Run:
- red on the old wiring (shell.go present, netproxy.go from the parent):
TestAutoTakesTheShellsProxy, TestShellProxyByScheme,
TestClosedShellProxyGoesDirect fail; TestShellProxyComesLast (settings
"direct", magpie's environment, the system's proxy win) passes there
and here.
- mica-run: go test -race ./internal/netproxy ./internal/proc ok; go vet
of both for darwin, GOOS=linux and GOOS=windows ok.
- wsl-run and win-run: go test ./internal/netproxy ./internal/proc ok.
- gofmt -l clean.
- full suite, both commits on
|