MCPcopy Create free account
hub / github.com/0xUnixIO/pulse / recordFailure

Method recordFailure

internal/auth/auth.go:265–279  ·  view source on GitHub ↗
(ip string)

Source from the content-addressed store, hash-verified

263}
264
265func (m *Manager) recordFailure(ip string) {
266 m.failMu.Lock()
267 defer m.failMu.Unlock()
268 now := time.Now()
269 a, ok := m.failures[ip]
270 if !ok || now.After(a.windowEnd) {
271 m.failures[ip] = &loginAttempt{count: 1, windowEnd: now.Add(loginWindow)}
272 return
273 }
274 a.count++
275 if a.count >= maxLoginFailures {
276 // 超限后将窗口延长为锁定时长
277 a.windowEnd = now.Add(loginLockDuration)
278 }
279}
280
281func (m *Manager) clearFailures(ip string) {
282 m.failMu.Lock()

Callers 2

HandleLoginMethod · 0.95
LoginFromRequestMethod · 0.95

Calls 1

AddMethod · 0.80

Tested by

no test coverage detected