mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:43:35 +00:00
fix(proxy): 强制 SOCKS5 代理使用 IPv4
WHAT: 为 SOCKS5 代理配置添加 family: 4 选项强制使用 IPv4 地址族 WHY: 解决 IPv4 主机名在代理连接时被意外解析到 IPv6 地址的问题,确保代理连接的稳定性和可预期性 HOW: 在 SocksProxyAgent 构造函数中添加 family: 4 配置选项;保持与现有 HTTP/HTTPS 代理的兼容性;无破坏性变更
This commit is contained in:
@@ -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}`
|
||||
|
||||
Reference in New Issue
Block a user