Documentation
¶
Overview ¶
Package iptracker provides functionality to track and block IP addresses based on failed authentication attempts.
Index ¶
Constants ¶
const ( // BlockDuration is the duration for which an IP will be blocked after // exceeding the maximum number of failed attempts. BlockDuration = 10 * time.Minute )
Variables ¶
var Global = NewIPTracker()
Global instance of IPTracker for use across the application
Functions ¶
This section is empty.
Types ¶
type IPTracker ¶
type IPTracker struct {
// contains filtered or unexported fields
}
IPTracker tracks failed authentication attempts by IP address and provides functionality to block IPs that exceed a threshold.
func (*IPTracker) GetBlockedUntil ¶
GetBlockedUntil returns the time until which the given IP address is blocked. If the IP is not blocked, it returns the zero time.
func (*IPTracker) RecordFailedAttempt ¶
RecordFailedAttempt records a failed authentication attempt for the given IP address. If the number of failed attempts exceeds the threshold, the IP is blocked for the configured duration. Returns true if the IP is now blocked, false otherwise.