What: netproxy.Redact is the one place a proxy address is made fit to
show. It is the rule 708ae4144 (#852) gave the Settings status
(proxyAddress, now Redact): the userinfo is left out, the rest kept as
written (no scheme added to one written without), a malformed address
"". Every place a proxy value reached text now goes through it:
- provider/logins.go: the switch's "Claude Code sessions ... go through
<user>'s proxy" log line (#1886's first).
- provider/claude_proxy_env.go: "<user>'s proxy is SOCKS" (#1886's
second).
- agent/codex_proxy.go + reach.go: the proxied drift's Detail and Addr,
shown in the GUI's pill and dialog; Codex's proxy comes from
HTTP_PROXY/ALL_PROXY/the system, which can carry a user:password.
- update/mirror.go: CheckProxy's error echoed the raw --proxy value
("not %q"); it now names it redacted, or not at all when malformed.
- netproxy.Describe already went through it.
Why: an account proxy like http://alice:s3cret@10.0.0.2:8080 landed in
magpie's log, which users paste into issues and Discord.
Swept and left alone: settings.CheckProxy's error names no value;
netproxy.DialSOCKS's error names the host only; Go's transport errors
(proxyconnect, socks connect) name host:port, not userinfo; the GUI's
provider editor and Settings field return the proxy whole as the
user's own editable value; env injection (EnvWith, ForBun, wslrun)
must carry it whole.
Tests place the credential where the user writes it: http, https,
socks5, socks5h, with and without a scheme, percent-encoded user and
password, user alone, malformed. TestRedactLeavesOutUserAndPassword,
TestClaudeAccountProxyLogsNoCredentials (captures the log over real
switches; Claude Code's HTTPS_PROXY still gets the proxy whole),
TestCodexProxiedDriftShowsNoCredentials (the probe still goes through
the whole proxy), TestCheckProxyErrorShowsNoCredentials.
Run: each site reverted alone turns its test red (logins.go,
claude_proxy_env.go, reach.go, codex_proxy.go, mirror.go; Redact
keeping the userinfo turns Redact and Describe's tests red). gofmt -l
clean; go vet ./... on darwin, GOOS=linux -tags nogui, GOOS=windows.
go test ./... at 0dd821c13 + this, sandbox HOME: 47 packages ok;
agent, gateway and library timed out at 10m on a machine at load ~20,
then on rerun hit ENOSPC (the disk filled from other sessions). Rerun
with space: library ok in full; agent's TestClaudeOutputTokens and
gateway's TestGroupFirstTokenFailsOver (the ENOSPC ones) ok, with
every Proxy/Proxied test in both. Not tried in the GUI by hand.
liu_dyj: with the VPN on, magpie said Codex reached magpie through a
proxy that didn't pass its requests on; versions before f156d9046 had
no such check, which is why upgrading brought it.
Cause: codexProxyFor didn't read the proxy the way Codex does.
- It read magpie's own environment. Codex in a terminal has the login
shell's, and the ChatGPT app's Codex too (ChatGPT.app 26.1007 runs
$SHELL -ilc at start and Object.assign()s its env into process.env).
magpie opened from the Dock has neither, so a NO_PROXY=127.0.0.1 in
.zshrc, which keeps Codex direct, wasn't seen, and magpie probed the
system proxy and warned.
- For the system proxy it took netproxy's one URL (HTTPS over HTTP over
SOCKS). hyper-util 0.1.20's Matcher::from_system, which reqwest
0.12.28 uses for Codex, takes only macOS' HTTP entry for an http://
URL; with only the HTTPS or SOCKS entry set (ShadowsocksX-NG's global
mode is SOCKS only) Codex goes direct and magpie warned. On Windows
it takes ProxyServer as one address, which a per-protocol list
("http=..;https=..") isn't (http's Authority::parse refuses two
colons), so Codex goes direct there too.
- With respect_system_proxy on macOS, CFNetwork's SOCKS entry is
UnsupportedProxyScheme, and Codex falls back to HTTP_PROXY/ALL_PROXY
with NO_PROXY (codex-rs outbound_proxy.rs resolve_env_proxy_route);
magpie used the SOCKS URL.
- The probe spoke real SOCKS5 to a socks5:// proxy. Codex's reqwest is
built without SOCKS (no tokio-socks in codex-rs Cargo.lock) and sends
an absolute-URI HTTP request to it, so the probe now does the same:
it passes a Clash mixed port as Codex does and fails a SOCKS-only
port as Codex does.
So netproxy.Proxy carries the HTTP and SOCKS entries alone beside URL
(parseScutil, parseWindows), proc asks the login shell for the
*_PROXY variables with agentenv.Vars in the same probe and only reads
them (proc.LoginEnv; never set in magpie's env, whose requests use
netproxy), and codexProxyFor uses both. Failover's gate
(codexProxyOK) and the drift share codexProxyFor and proxyProbe, so
both follow. The pill's How to fix now names the shell profile for
NO_PROXY. Clash/mihomo rule mode with a 127.0.0.0/8 DIRECT rule never
warned and still doesn't; global mode or a rule set without it still
warns, rightly (real codex 502s there). TUN mode sets no proxy and
never warned.
Run:
- real codex-cli 0.162.1 in a sandbox HOME/CODEX_HOME against a fake
gateway and mihomo v1.19.32 (rule, no-LAN-rule, global ports):
direct, rule, and ALL_PROXY=socks5:// on the rule port reach the
gateway; no-LAN-rule and global 502; global with NO_PROXY=127.0.0.1
reaches it. The Go probe agrees on every one.
- go test -tags nogui ./internal/agent, ./internal/netproxy,
./internal/proc; gofmt -l; GOOS=linux and GOOS=windows go vet
-tags nogui on the three packages.
- Broke each part by hand: sys.URL back in codexProxyFor (Windows per
protocol, macOS HTTPS/SOCKS alone red), the probe's socks->http
(TestRealProxyProbe red), codexEnv without the login shell
(TestCodexEnvTakesLoginShell red), the respect-path SOCKS fallback
(three respect cases red), setUnset of every shell var and the probe
without ProxyVars (TestLoginEnvProxyVarsNotSet red).
Not tried: the macOS system proxy cases with real Codex (changing the
system's proxy settings is off limits here; read from hyper-util,
reqwest and codex-rs sources), the Windows per-protocol ProxyServer
with real Codex (from the http crate's source; no Windows run), and
the reporter's own app and mode, which are asked on X.
CC Switch with "unify Codex session history" runs the official sign-in
as model_provider = "custom" (name OpenAI, requires_openai_auth,
supports_websockets), so failover goes on that table's base_url, not
openai_base_url. f156d9046 already gates and ends both; this pins it with
CC Switch's literal config. Run: the test, red with the proxy gate removed
and with dropMirrorFailover left out of EndFailover; CCSwitch tests green.
Muma102kMichael (Windows): after magpie took Codex over, every project
and every new chat got 502. Codex's reqwest sends its requests for
http://127.0.0.1:3425 through HTTP_PROXY/ALL_PROXY or the system's
proxy, and only an exact IP or a CIDR in NO_PROXY (on Windows, with no
NO_PROXY, the bypass list with "*." removed) keeps 127.0.0.1 off it:
"127.*" and "localhost" don't, and macOS' exceptions aren't read. A
proxy in global mode answers 502 for every request. With [features]
respect_system_proxy Codex asks the system alone and goes direct with
no proxy set there. Account failover, which magpie writes uninvited
when 2+ ChatGPT accounts are on, put all of Codex's traffic, its own
models included, behind that proxy.
- codex_proxy.go works out Codex's proxy the way Codex does and probes
GET / through it (must answer as magpie). Failover waits for that
probe and isn't written while the proxy doesn't pass Codex on; one
written before goes again.
- New drift kind "proxied": the Agents pill says Codex reaches magpie
through a proxy that doesn't pass its requests on, How to fix names
the fix (DIRECT rule for 127.0.0.0/8, NO_PROXY=127.0.0.1, or
127.0.0.1 in Windows' bypass list), and the dialog has a one-click
Disconnect from magpie (also on unreachable drift).
- Leon920717: after quitting magpie Codex kept retrying. The app that
serves the gateway now takes failover out in OnShutdown
(EndCodexFailover); the next start's Sync writes it again. A
connected Codex is kept (its model is magpie's; Disconnect restores).
A kill or crash still leaves failover in place.
- thisisvainxx: "several restarts". Codex's app-server keeps the base
URL it started with, and KeepCodexDaemonCurrent ends with magpie, so
EndCodexFailover restarts it when no codex session is on it.
Run:
- real codex-cli 0.162.1 in a sandbox CODEX_HOME against a fake 502
proxy and a fake gateway: NO_PROXY=localhost,127.* -> 30 POSTs to the
proxy; NO_PROXY=localhost -> proxy; NO_PROXY=127.0.0.1 -> gateway;
respect_system_proxy with HTTP_PROXY set -> gateway directly.
- go test -tags nogui ./internal/agent/ (full package, 465s, ok) and
the new tests after the daemon change; each new test went red with
its guarantee broken by hand (failover gate, drift, EndFailover,
daemon restart on quit).
- node --test agent-proxied/agent-unreachable/agent-failover/
agent-disconnect-preview: 104 passed, chromium + webkit, en zh zh-TW
ja de, window and panel.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui clean.
Not tried: the quit path in the real app, on the Windows box, or
whether computer use / remote connection broke for this same reason.