Documentation
¶
Overview ¶
Package dnsbl2 provides a Caddy HTTP request matcher backed by DNS blocklists.
Index ¶
- type MatchDNSBL
- func (MatchDNSBL) CaddyModule() caddy.ModuleInfo
- func (m *MatchDNSBL) Cleanup() error
- func (m *MatchDNSBL) Match(r *http.Request) bool
- func (m *MatchDNSBL) MatchWithError(r *http.Request) (bool, error)
- func (m *MatchDNSBL) Provision(ctx caddy.Context) error
- func (m *MatchDNSBL) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
- func (m *MatchDNSBL) Validate() error
- type Provider
- type ProviderHealthCheck
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MatchDNSBL ¶
type MatchDNSBL struct {
// Providers is the shorthand list of DNSBL zones where any A record matches.
Providers []string `json:"providers,omitempty"`
// ProviderConfigs contains DNSBL zones with provider-specific settings.
ProviderConfigs []Provider `json:"provider_configs,omitempty"`
// Timeout limits the total time spent checking all providers for a request.
// The default is 2 seconds.
Timeout caddy.Duration `json:"timeout,omitempty"`
// Resolvers is an optional list of DNS resolver IP addresses with optional
// ports. The operating system configuration is used by default.
Resolvers []string `json:"resolvers,omitempty"`
// CacheSize is the maximum number of DNS responses retained in memory. The
// default is 4096.
CacheSize int `json:"cache_size,omitempty"`
// CacheMaxTTL caps the TTL of cached DNS responses. The default is 1 hour.
CacheMaxTTL caddy.Duration `json:"cache_max_ttl,omitempty"`
// MaxConcurrent limits active DNS queries. Queries above the limit fail
// open. The default is 64.
MaxConcurrent int `json:"max_concurrent,omitempty"`
// contains filtered or unexported fields
}
MatchDNSBL matches requests whose client IP is listed by at least one DNSBL provider.
func (MatchDNSBL) CaddyModule ¶
func (MatchDNSBL) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (*MatchDNSBL) Cleanup ¶
func (m *MatchDNSBL) Cleanup() error
Cleanup stops background health checks and active DNS lookups.
func (*MatchDNSBL) Match ¶
func (m *MatchDNSBL) Match(r *http.Request) bool
Match reports whether the request matches. It is retained for compatibility with Caddy versions that use caddyhttp.RequestMatcher.
func (*MatchDNSBL) MatchWithError ¶
func (m *MatchDNSBL) MatchWithError(r *http.Request) (bool, error)
MatchWithError reports whether the request's client IP is listed by any configured provider. DNS errors fail open and do not match.
func (*MatchDNSBL) Provision ¶
func (m *MatchDNSBL) Provision(ctx caddy.Context) error
Provision prepares the matcher for use.
func (*MatchDNSBL) UnmarshalCaddyfile ¶
func (m *MatchDNSBL) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
UnmarshalCaddyfile implements caddyfile.Unmarshaler. Syntax:
dnsbl2 {
providers <zones...>
provider <zone> {
answers <IPv4 addresses...>
health_check {
positive <IP address>
negative <IP address>
interval <duration>
}
}
timeout <duration>
resolvers <IP addresses...>
cache_size <entries>
cache_max_ttl <duration>
max_concurrent <queries>
}
func (*MatchDNSBL) Validate ¶
func (m *MatchDNSBL) Validate() error
Validate validates the matcher configuration.
type Provider ¶
type Provider struct {
// Zone is the DNSBL zone to query.
Zone string `json:"zone"`
// Answers limits matches to these IPv4 answers. Any A record matches when
// Answers is empty.
Answers []string `json:"answers,omitempty"`
// HealthCheck periodically verifies positive and negative control entries.
HealthCheck *ProviderHealthCheck `json:"health_check,omitempty"`
}
Provider configures a DNSBL zone and its accepted A record answers.
type ProviderHealthCheck ¶
type ProviderHealthCheck struct {
// Positive is an IP address that must be listed. It defaults to the first
// configured answer, or 127.0.0.2 when any answer is accepted.
Positive string `json:"positive,omitempty"`
// Negative is an IP address that must not be listed. It defaults to
// 127.0.0.1.
Negative string `json:"negative,omitempty"`
// Interval is the time between checks. It defaults to 5 minutes.
Interval caddy.Duration `json:"interval,omitempty"`
}
ProviderHealthCheck configures RFC 5782 control queries for a provider.