fix: 统一对话密码锁键为发送方加对方不含 IP

This commit is contained in:
Nixevol
2026-09-30 16:23:25 +08:00
parent b7c8b6ffd6
commit e294b5db71
17 changed files with 449 additions and 32 deletions
+27 -3
View File
@@ -89,14 +89,38 @@ func (l *MemoryLoginLocks) Fail(key auth.LockKey) (bool, time.Duration) {
return false, 0
}
// ClearEndpoint 实现 auth.LoginLocks。
// ClearEndpoint 实现 auth.LoginLocks:只清登录锁定。
func (l *MemoryLoginLocks) ClearEndpoint(endpointID string) {
l.mu.Lock()
defer l.mu.Unlock()
for k := range l.entries {
// kind|endpoint|peer|ip
parts := splitLockKey(k)
if len(parts) >= 2 && parts[1] == endpointID {
if len(parts) != 4 {
continue
}
kind, ep := auth.LockKind(parts[0]), parts[1]
if ep != endpointID {
continue
}
if kind == auth.LockLoginEndpointIP || kind == auth.LockLoginEndpoint {
delete(l.entries, k)
}
}
}
// ClearAllForEndpoint 实现 auth.LoginLocks。
func (l *MemoryLoginLocks) ClearAllForEndpoint(endpointID string) {
l.mu.Lock()
defer l.mu.Unlock()
if endpointID == "" {
return
}
for k := range l.entries {
parts := splitLockKey(k)
if len(parts) != 4 {
continue
}
if parts[1] == endpointID || parts[2] == endpointID {
delete(l.entries, k)
}
}