fix(traffic): 流量录制代理默认只监听 127.0.0.1,避免默认开放代理暴露 (#129) (#130)

This commit is contained in:
dingpotian authored and GitHub committed 2026-09-16 09:36:32 +08:00
1 parent 7f71f77d16
commit 80a085d157
5 files changed
+32 -5

No files matched your search

+8 -2
View File
@@ -200,8 +200,14 @@ func hostOnly(hostport string) string {
return hostport
}
// ProxyAddr returns the address workers should set as HTTP(S)_PROXY.
func (t *Traffic) ProxyAddr() string { return "http://127.0.0.1" + t.addr }
// ProxyAddr returns the address workers should set as HTTP(S)_PROXY. A bare
// ":port" means "bind all interfaces" (legacy default), so map it to loopback.
func (t *Traffic) ProxyAddr() string {
if strings.HasPrefix(t.addr, ":") {
return "http://127.0.0.1" + t.addr
}
return "http://" + t.addr
}
// SetUpstreamProxy points every captured request at a global egress proxy
// (http/https/socks5, optional user:pass in the URL). An empty raw string clears