mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-23 17:44:49 +00:00
Merge branch 'xilu0/main'
This commit is contained in:
@@ -212,6 +212,8 @@ class ApiKeyService {
|
|||||||
const keyData = await redis.findApiKeyByHash(hashedKey)
|
const keyData = await redis.findApiKeyByHash(hashedKey)
|
||||||
|
|
||||||
if (!keyData) {
|
if (!keyData) {
|
||||||
|
// ⚠️ 警告:映射表查找失败,可能是竞态条件或映射表损坏
|
||||||
|
logger.warn(`⚠️ API key not found in hash map: ${hashedKey.substring(0, 16)}... (possible race condition or corrupted hash map)`)
|
||||||
return { valid: false, error: 'API key not found' }
|
return { valid: false, error: 'API key not found' }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -714,10 +716,11 @@ class ApiKeyService {
|
|||||||
|
|
||||||
updatedData.updatedAt = new Date().toISOString()
|
updatedData.updatedAt = new Date().toISOString()
|
||||||
|
|
||||||
// 更新时不需要重新建立哈希映射,因为API Key本身没有变化
|
// 传递hashedKey以确保映射表一致性
|
||||||
await redis.setApiKey(keyId, updatedData)
|
// keyData.apiKey 存储的就是 hashedKey(见generateApiKey第123行)
|
||||||
|
await redis.setApiKey(keyId, updatedData, keyData.apiKey)
|
||||||
|
|
||||||
logger.success(`📝 Updated API key: ${keyId}`)
|
logger.success(`📝 Updated API key: ${keyId}, hashMap updated`)
|
||||||
|
|
||||||
return { success: true }
|
return { success: true }
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user