Merge pull request #38 from noir017/fix/authenticated-socks5-proxy

fix: support authenticated socks5/http proxies
This commit is contained in:
AntBlack
2026-07-08 16:34:51 +08:00
committed by GitHub
2 changed files with 12 additions and 1 deletions
+9 -1
View File
@@ -117,7 +117,15 @@ func DetectProxyProtocol(proxyConfig string) string {
func SupportedKernelsForProtocol(protocol string, proxyConfig string, proxies []config.BrowserProxy, proxyId string) []string {
switch strings.ToLower(strings.TrimSpace(protocol)) {
case "direct", "http", "https", "socks5":
case "direct":
return []string{ProxyKernelNative}
case "http", "https", "socks5":
// 带账号密码鉴权的 socks5/http 代理:Chromium 的 --proxy-server 无法携带凭据,
// 浏览器 native 会静默丢弃鉴权信息导致连接失败。这类代理必须通过 xray / mihomo
// 桥接成本地无鉴权 socks5 再交给浏览器。无鉴权的代理仍走 native。
if RequiresLocalProxyBridgeForBrowser(proxyConfig) {
return []string{ProxyKernelXray, ProxyKernelMihomo}
}
return []string{ProxyKernelNative}
case "vmess", "vless", "trojan", "ss", "shadowsocks", "chain+socks5":
return []string{ProxyKernelXray, ProxyKernelMihomo}
@@ -17,6 +17,9 @@ func TestResolveProxyKernelDefaultPriority(t *testing.T) {
{name: "anytls URI uses sing-box", proxy: "anytls://pass@example.com:443?sni=example.com", wantKernel: ProxyKernelSingBox},
{name: "mieru uses mihomo", proxy: mieruClashNode, wantKernel: ProxyKernelMihomo},
{name: "http uses native", proxy: "http://127.0.0.1:8080", wantKernel: ProxyKernelNative},
{name: "socks5 without auth uses native", proxy: "socks5://127.0.0.1:1080", wantKernel: ProxyKernelNative},
{name: "socks5 with auth uses xray", proxy: "socks5://user:pass@127.0.0.1:1080", wantKernel: ProxyKernelXray},
{name: "http with auth uses xray", proxy: "http://user:pass@127.0.0.1:8080", wantKernel: ProxyKernelXray},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {