fix(electron): preserve socks proxy fallback

Return a recorded SOCKS proxy before a fallback DIRECT rule so local model downloads fail explicitly instead of silently bypassing the configured system proxy.
This commit is contained in:
digua committed 2026-06-26 09:56:32 +08:00
1 parent cbc8728f41
commit 6cc7454049
2 files changed
+2 -1

No files matched your search

@@ -14,6 +14,7 @@ test('proxyUrlFromElectronResolvedProxy returns the first usable model download
proxyUrlFromElectronResolvedProxy('SOCKS5 127.0.0.1:1080; PROXY 127.0.0.1:7890'),
'http://127.0.0.1:7890'
)
assert.equal(proxyUrlFromElectronResolvedProxy('SOCKS5 127.0.0.1:1080; DIRECT'), 'socks5://127.0.0.1:1080')
assert.equal(proxyUrlFromElectronResolvedProxy('SOCKS5 127.0.0.1:1080'), 'socks5://127.0.0.1:1080')
assert.equal(proxyUrlFromElectronResolvedProxy('SOCKS 127.0.0.1:1080'), 'socks://127.0.0.1:1080')
})
+1 -1
View File
@@ -10,7 +10,7 @@ export function proxyUrlFromElectronResolvedProxy(resolvedProxy: string): string
for (const rawRule of resolvedProxy.split(';')) {
const rule = rawRule.trim()
if (!rule) continue
if (rule.toUpperCase() === 'DIRECT') return undefined
if (rule.toUpperCase() === 'DIRECT') return firstSocksProxyUrl
const [schemeRaw, targetRaw] = rule.split(/\s+/, 2)
const scheme = schemeRaw?.toUpperCase()