feat(proxy): add proxy IP management and account routing

Add admin CRUD and connectivity checks for SOCKS5/SOCKS5H proxy nodes.

Allow accounts to bind to a proxy, route DeepSeek requests through the selected node, and expose proxy management in the admin UI.
This commit is contained in:
Jason.li
2026-04-07 02:05:25 +08:00
parent 1c95942e5d
commit 8ae2ea10c8
30 changed files with 1675 additions and 51 deletions

View File

@@ -12,6 +12,7 @@ export function useAccountActions({ apiFetch, t, onMessage, onRefresh, config, f
const [batchProgress, setBatchProgress] = useState({ current: 0, total: 0, results: [] })
const [sessionCounts, setSessionCounts] = useState({})
const [deletingSessions, setDeletingSessions] = useState({})
const [updatingProxy, setUpdatingProxy] = useState({})
const addKey = async () => {
if (!newKey.trim()) return
@@ -213,6 +214,34 @@ export function useAccountActions({ apiFetch, t, onMessage, onRefresh, config, f
}
}
const updateAccountProxy = async (identifier, proxyID) => {
const accountID = String(identifier || '').trim()
if (!accountID) {
onMessage('error', t('accountManager.invalidIdentifier'))
return
}
setUpdatingProxy(prev => ({ ...prev, [accountID]: true }))
try {
const res = await apiFetch(`/admin/accounts/${encodeURIComponent(accountID)}/proxy`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ proxy_id: proxyID || '' }),
})
const data = await res.json()
if (!res.ok) {
onMessage('error', data.detail || t('messages.requestFailed'))
return
}
onMessage('success', t('accountManager.proxyUpdateSuccess'))
fetchAccounts()
onRefresh()
} catch (_err) {
onMessage('error', t('messages.networkError'))
} finally {
setUpdatingProxy(prev => ({ ...prev, [accountID]: false }))
}
}
return {
showAddKey,
setShowAddKey,
@@ -230,6 +259,7 @@ export function useAccountActions({ apiFetch, t, onMessage, onRefresh, config, f
batchProgress,
sessionCounts,
deletingSessions,
updatingProxy,
addKey,
deleteKey,
addAccount,
@@ -237,5 +267,6 @@ export function useAccountActions({ apiFetch, t, onMessage, onRefresh, config, f
testAccount,
testAllAccounts,
deleteAllSessions,
updateAccountProxy,
}
}