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

@@ -1 +1 @@
1.1.114 1.1.115

View File

@@ -79,7 +79,7 @@ async function testApiResponse() {
console.log('\n\n📊 验证结果:') console.log('\n\n📊 验证结果:')
// 检查 platform 字段 // 检查 platform 字段
const claudeWithPlatform = claudeAccounts.filter((a) => a.platform === 'claude-oauth') const claudeWithPlatform = claudeAccounts.filter((a) => a.platform === 'claude')
const consoleWithPlatform = consoleAccounts.filter((a) => a.platform === 'claude-console') const consoleWithPlatform = consoleAccounts.filter((a) => a.platform === 'claude-console')
if (claudeWithPlatform.length === claudeAccounts.length) { if (claudeWithPlatform.length === claudeAccounts.length) {

View File

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

View File

@@ -21,7 +21,9 @@ function createProxyAgent(proxy) {
if (proxy.type === 'socks5') { if (proxy.type === 'socks5') {
const auth = proxy.username && proxy.password ? `${proxy.username}:${proxy.password}@` : '' const auth = proxy.username && proxy.password ? `${proxy.username}:${proxy.password}@` : ''
const socksUrl = `socks5://${auth}${proxy.host}:${proxy.port}` 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') { } else if (proxy.type === 'http' || proxy.type === 'https') {
const auth = proxy.username && proxy.password ? `${proxy.username}:${proxy.password}@` : '' const auth = proxy.username && proxy.password ? `${proxy.username}:${proxy.password}@` : ''
const proxyUrl = `${proxy.type}://${auth}${proxy.host}:${proxy.port}` const proxyUrl = `${proxy.type}://${auth}${proxy.host}:${proxy.port}`

View File

@@ -55,6 +55,7 @@ class ClaudeAccountService {
proxy = null, // { type: 'socks5', host: 'localhost', port: 1080, username: '', password: '' } proxy = null, // { type: 'socks5', host: 'localhost', port: 1080, username: '', password: '' }
isActive = true, isActive = true,
accountType = 'shared', // 'dedicated' or 'shared' accountType = 'shared', // 'dedicated' or 'shared'
platform = 'claude',
priority = 50, // 调度优先级 (1-100数字越小优先级越高) priority = 50, // 调度优先级 (1-100数字越小优先级越高)
schedulable = true, // 是否可被调度 schedulable = true, // 是否可被调度
subscriptionInfo = null // 手动设置的订阅信息 subscriptionInfo = null // 手动设置的订阅信息
@@ -79,7 +80,8 @@ class ClaudeAccountService {
scopes: claudeAiOauth.scopes.join(' '), scopes: claudeAiOauth.scopes.join(' '),
proxy: proxy ? JSON.stringify(proxy) : '', proxy: proxy ? JSON.stringify(proxy) : '',
isActive: isActive.toString(), isActive: isActive.toString(),
accountType, // 账号类型:'dedicated' 或 'shared' accountType, // 账号类型:'dedicated' 或 'shared' 或 'group'
platform,
priority: priority.toString(), // 调度优先级 priority: priority.toString(), // 调度优先级
createdAt: new Date().toISOString(), createdAt: new Date().toISOString(),
lastUsedAt: '', lastUsedAt: '',
@@ -108,7 +110,8 @@ class ClaudeAccountService {
scopes: '', scopes: '',
proxy: proxy ? JSON.stringify(proxy) : '', proxy: proxy ? JSON.stringify(proxy) : '',
isActive: isActive.toString(), isActive: isActive.toString(),
accountType, // 账号类型:'dedicated' 或 'shared' accountType, // 账号类型:'dedicated' 或 'shared' 或 'group'
platform,
priority: priority.toString(), // 调度优先级 priority: priority.toString(), // 调度优先级
createdAt: new Date().toISOString(), createdAt: new Date().toISOString(),
lastUsedAt: '', lastUsedAt: '',
@@ -151,6 +154,7 @@ class ClaudeAccountService {
isActive, isActive,
proxy, proxy,
accountType, accountType,
platform,
priority, priority,
status: accountData.status, status: accountData.status,
createdAt: accountData.createdAt, createdAt: accountData.createdAt,
@@ -444,7 +448,7 @@ class ClaudeAccountService {
errorMessage: account.errorMessage, errorMessage: account.errorMessage,
accountType: account.accountType || 'shared', // 兼容旧数据,默认为共享 accountType: account.accountType || 'shared', // 兼容旧数据,默认为共享
priority: parseInt(account.priority) || 50, // 兼容旧数据默认优先级50 priority: parseInt(account.priority) || 50, // 兼容旧数据默认优先级50
platform: 'claude-oauth', // 添加平台标识,用于前端区分 platform: account.platform || 'claude', // 添加平台标识,用于前端区分
createdAt: account.createdAt, createdAt: account.createdAt,
lastUsedAt: account.lastUsedAt, lastUsedAt: account.lastUsedAt,
lastRefreshAt: account.lastRefreshAt, lastRefreshAt: account.lastRefreshAt,

View File

@@ -172,7 +172,7 @@
<!-- 编辑分组模态框 --> <!-- 编辑分组模态框 -->
<div <div
v-if="showEditForm" v-if="showEditForm"
class="modal z-60 fixed inset-0 flex items-center justify-center p-3 sm:p-4" class="modal fixed inset-0 z-50 flex items-center justify-center p-3 sm:p-4"
> >
<div class="modal-content w-full max-w-lg p-4 sm:p-6"> <div class="modal-content w-full max-w-lg p-4 sm:p-6">
<div class="mb-4 flex items-center justify-between"> <div class="mb-4 flex items-center justify-between">