fix: 统一对话密码锁键为发送方加对方不含 IP
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user