MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / RecordFailure

Method RecordFailure

core/init/auth/ip_tracker.go:94–120  ·  view source on GitHub ↗
(ip string)

Source from the content-addressed store, hash-verified

92}
93
94func (t *IPTracker) RecordFailure(ip string) {
95 t.mu.Lock()
96 defer t.mu.Unlock()
97
98 if record, exists := t.records[ip]; exists {
99 if !t.prepareRecordUnsafe(ip, record) {
100 t.removeIPUnsafe(ip)
101 } else {
102 record.FailedCount++
103 record.LastUpdate = time.Now()
104 if record.FailedCount >= MaxFailedAttempts {
105 record.LockedUntil = time.Now().Add(LockDuration)
106 }
107 return
108 }
109 }
110
111 if len(t.records) >= MaxIPCount {
112 t.removeOldestUnsafe()
113 }
114
115 t.records[ip] = &IPRecord{
116 FailedCount: 1,
117 LastUpdate: time.Now(),
118 }
119 t.ipOrder = append(t.ipOrder, ip)
120}
121
122func (t *IPTracker) Clear(ip string) {
123 t.mu.Lock()

Callers 2

LoginMethod · 0.45
MFALoginMethod · 0.45

Calls 3

prepareRecordUnsafeMethod · 0.95
removeIPUnsafeMethod · 0.95
removeOldestUnsafeMethod · 0.95

Tested by

no test coverage detected