mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-23 08:55:23 +00:00
feat: 添加Claude账户403错误处理和封禁状态支持
- 新增Claude账户403错误自动检测和处理机制 - 区分Claude账户401未授权和403封禁两种错误状态 - 支持非流式和流式请求中的401/403错误处理 - 优化Claude账户错误处理代码,减少重复逻辑 - 支持前端显示不同的Claude账户错误状态和颜色 - 完善Claude账户异常Webhook通知错误码区分
This commit is contained in:
@@ -636,6 +636,32 @@ class UnifiedClaudeScheduler {
|
||||
}
|
||||
}
|
||||
|
||||
// 🚫 标记账户为被封锁状态(403错误)
|
||||
async markAccountBlocked(accountId, accountType, sessionHash = null) {
|
||||
try {
|
||||
// 只处理claude-official类型的账户,不处理claude-console和gemini
|
||||
if (accountType === 'claude-official') {
|
||||
await claudeAccountService.markAccountBlocked(accountId, sessionHash)
|
||||
|
||||
// 删除会话映射
|
||||
if (sessionHash) {
|
||||
await this._deleteSessionMapping(sessionHash)
|
||||
}
|
||||
|
||||
logger.warn(`🚫 Account ${accountId} marked as blocked due to 403 error`)
|
||||
} else {
|
||||
logger.info(
|
||||
`ℹ️ Skipping blocked marking for non-Claude OAuth account: ${accountId} (${accountType})`
|
||||
)
|
||||
}
|
||||
|
||||
return { success: true }
|
||||
} catch (error) {
|
||||
logger.error(`❌ Failed to mark account as blocked: ${accountId} (${accountType})`, error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
// 🚫 标记Claude Console账户为封锁状态(模型不支持)
|
||||
async blockConsoleAccount(accountId, reason) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user