Merge pull request #262 from mouyong/dev

fix(proxy): 强制 SOCKS5 代理使用 IPv4
This commit is contained in:
Wesley Liddick
2025-08-20 21:43:40 +08:00
committed by GitHub
6 changed files with 15 additions and 7 deletions

View File

@@ -1340,6 +1340,7 @@ router.post('/claude-accounts', authenticateAdmin, async (req, res) => {
claudeAiOauth,
proxy,
accountType,
platform = 'claude',
priority,
groupId
} = req.body
@@ -1377,6 +1378,7 @@ router.post('/claude-accounts', authenticateAdmin, async (req, res) => {
claudeAiOauth,
proxy,
accountType: accountType || 'shared', // 默认为共享类型
platform,
priority: priority || 50 // 默认优先级为50
})

View File

@@ -21,7 +21,9 @@ function createProxyAgent(proxy) {
if (proxy.type === 'socks5') {
const auth = proxy.username && proxy.password ? `${proxy.username}:${proxy.password}@` : ''
const socksUrl = `socks5://${auth}${proxy.host}:${proxy.port}`
return new SocksProxyAgent(socksUrl)
return new SocksProxyAgent(socksUrl, {
family: 4
})
} else if (proxy.type === 'http' || proxy.type === 'https') {
const auth = proxy.username && proxy.password ? `${proxy.username}:${proxy.password}@` : ''
const proxyUrl = `${proxy.type}://${auth}${proxy.host}:${proxy.port}`