mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-10-25 17:54:34 +08:00
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:
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')
|
||||
})
|
||||
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user