MCPcopy
hub / github.com/AdguardTeam/dnsproxy / middleware

Struct middleware

ratelimit/ratelimit.go:19–30  ·  view source on GitHub ↗

middleware implements [proxy.Middleware] with rate limiting functionality.

Source from the content-addressed store, hash-verified

17
18// middleware implements [proxy.Middleware] with rate limiting functionality.
19type middleware struct {
20 buckets *gocache.Cache
21 logger *slog.Logger
22
23 // mu protects buckets.
24 mu *sync.Mutex
25
26 allowlistAddrs netutil.SliceSubnetSet
27 ratelimit uint
28 subnetLenIPv4 uint
29 subnetLenIPv6 uint
30}
31
32// NewMiddleware returns middleware with rate limiting functionality. c must be
33// valid.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected