mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:43:35 +00:00
Merge pull request #262 from mouyong/dev
fix(proxy): 强制 SOCKS5 代理使用 IPv4
This commit is contained in:
@@ -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
|
||||
})
|
||||
|
||||
|
||||
@@ -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}`
|
||||
|
||||
@@ -55,6 +55,7 @@ class ClaudeAccountService {
|
||||
proxy = null, // { type: 'socks5', host: 'localhost', port: 1080, username: '', password: '' }
|
||||
isActive = true,
|
||||
accountType = 'shared', // 'dedicated' or 'shared'
|
||||
platform = 'claude',
|
||||
priority = 50, // 调度优先级 (1-100,数字越小优先级越高)
|
||||
schedulable = true, // 是否可被调度
|
||||
subscriptionInfo = null // 手动设置的订阅信息
|
||||
@@ -79,7 +80,8 @@ class ClaudeAccountService {
|
||||
scopes: claudeAiOauth.scopes.join(' '),
|
||||
proxy: proxy ? JSON.stringify(proxy) : '',
|
||||
isActive: isActive.toString(),
|
||||
accountType, // 账号类型:'dedicated' 或 'shared'
|
||||
accountType, // 账号类型:'dedicated' 或 'shared' 或 'group'
|
||||
platform,
|
||||
priority: priority.toString(), // 调度优先级
|
||||
createdAt: new Date().toISOString(),
|
||||
lastUsedAt: '',
|
||||
@@ -108,7 +110,8 @@ class ClaudeAccountService {
|
||||
scopes: '',
|
||||
proxy: proxy ? JSON.stringify(proxy) : '',
|
||||
isActive: isActive.toString(),
|
||||
accountType, // 账号类型:'dedicated' 或 'shared'
|
||||
accountType, // 账号类型:'dedicated' 或 'shared' 或 'group'
|
||||
platform,
|
||||
priority: priority.toString(), // 调度优先级
|
||||
createdAt: new Date().toISOString(),
|
||||
lastUsedAt: '',
|
||||
@@ -151,6 +154,7 @@ class ClaudeAccountService {
|
||||
isActive,
|
||||
proxy,
|
||||
accountType,
|
||||
platform,
|
||||
priority,
|
||||
status: accountData.status,
|
||||
createdAt: accountData.createdAt,
|
||||
@@ -444,7 +448,7 @@ class ClaudeAccountService {
|
||||
errorMessage: account.errorMessage,
|
||||
accountType: account.accountType || 'shared', // 兼容旧数据,默认为共享
|
||||
priority: parseInt(account.priority) || 50, // 兼容旧数据,默认优先级50
|
||||
platform: 'claude-oauth', // 添加平台标识,用于前端区分
|
||||
platform: account.platform || 'claude', // 添加平台标识,用于前端区分
|
||||
createdAt: account.createdAt,
|
||||
lastUsedAt: account.lastUsedAt,
|
||||
lastRefreshAt: account.lastRefreshAt,
|
||||
|
||||
Reference in New Issue
Block a user