🍱 fix lint

This commit is contained in:
maxlerebourg
2026-07-31 14:39:09 +02:00
parent 6b0518859d
commit 1ba556e918
3 changed files with 6 additions and 2 deletions
+1
View File
@@ -75,6 +75,7 @@ linters:
- mnd - mnd
- exportloopref - exportloopref
- contextcheck - contextcheck
- intrange # not supported by yaegi
issues: issues:
exclude-use-default: false exclude-use-default: false
max-same-issues: 0 max-same-issues: 0
+1 -1
View File
@@ -330,7 +330,7 @@ func New(_ context.Context, next http.Handler, config *configuration.Config, nam
// ServeHTTP principal function of plugin. // ServeHTTP principal function of plugin.
// //
//nolint:nestif //nolint:nestif,gocognit
func (bouncer *Bouncer) ServeHTTP(rw http.ResponseWriter, req *http.Request) { func (bouncer *Bouncer) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
if !bouncer.enabled { if !bouncer.enabled {
bouncer.next.ServeHTTP(rw, req) bouncer.next.ServeHTTP(rw, req)
+4 -1
View File
@@ -27,7 +27,7 @@ const (
CacheMiss = "cache:miss" CacheMiss = "cache:miss"
// CacheUnreachable error string when cache is unreachable. // CacheUnreachable error string when cache is unreachable.
CacheUnreachable = "cache:unreachable" CacheUnreachable = "cache:unreachable"
// cidrPrefix store all cidr within the same key // cidrPrefix store all cidr within the same key.
cidrPrefix = "cidr:" cidrPrefix = "cidr:"
) )
@@ -149,6 +149,7 @@ func (c *Client) Set(key string, value string, duration int64) {
c.cache.set(key, value, duration) c.cache.set(key, value, duration)
} }
// DeleteCIDR removes a CIDR decision from the cache.
func (c *Client) DeleteCIDR(cidr string) { func (c *Client) DeleteCIDR(cidr string) {
cidr = ip.NormalizeCIDR(cidr) cidr = ip.NormalizeCIDR(cidr)
if cidr == "" { if cidr == "" {
@@ -158,6 +159,7 @@ func (c *Client) DeleteCIDR(cidr string) {
c.log.Debug(fmt.Sprintf("cache:DeleteCIDR cidr:%v", cidr)) c.log.Debug(fmt.Sprintf("cache:DeleteCIDR cidr:%v", cidr))
} }
// GetCIDR checks if an IP matches a CIDR decision in the cache.
func (c *Client) GetCIDR(ipStr string) (string, error) { func (c *Client) GetCIDR(ipStr string) (string, error) {
keys := ip.CIDRKeys(ipStr) keys := ip.CIDRKeys(ipStr)
if keys == nil { if keys == nil {
@@ -172,6 +174,7 @@ func (c *Client) GetCIDR(ipStr string) (string, error) {
return "", errors.New(CacheMiss) return "", errors.New(CacheMiss)
} }
// SetCIDR stores a CIDR decision in the cache.
func (c *Client) SetCIDR(cidr, value string, duration int64) { func (c *Client) SetCIDR(cidr, value string, duration int64) {
cidr = ip.NormalizeCIDR(cidr) cidr = ip.NormalizeCIDR(cidr)
if cidr == "" { if cidr == "" {