Documentation
¶
Overview ¶
Package crowdsec provides a CrowdSec stream bouncer that maintains a local decision cache for IP reputation checks.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bouncer ¶
type Bouncer struct {
// contains filtered or unexported fields
}
Bouncer wraps a CrowdSec StreamBouncer, maintaining a local cache of active decisions for fast IP lookups. It implements restrict.CrowdSecChecker.
func NewBouncer ¶
NewBouncer creates a bouncer but does not start the stream.
func (*Bouncer) CheckIP ¶
func (b *Bouncer) CheckIP(addr netip.Addr) *restrict.CrowdSecDecision
CheckIP looks up addr in the local decision cache. Returns nil if no active decision exists for the address.
Prefix lookups are O(1): instead of scanning all stored prefixes, we probe the map for every possible containing prefix of the address (at most 33 for IPv4, 129 for IPv6).
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages a single shared Bouncer instance with reference counting. The bouncer starts when the first service acquires it and stops when the last service releases it.
func NewRegistry ¶
NewRegistry creates a registry. The bouncer is not started until Acquire is called.
func (*Registry) Acquire ¶
Acquire registers svcID as a consumer and starts the bouncer if this is the first consumer. Returns the shared Bouncer (which implements the restrict package's CrowdSecChecker interface). Returns nil if not Available.