Documentation ¶
Index ¶
- Variables
- func Parse(c *caddy.Controller, f *Filter) error
- type ActionConfig
- func (a ActionConfig) AddDomain(domain string)
- func (a ActionConfig) AddDomainList(url string) error
- func (a ActionConfig) AddHostsList(url string) error
- func (a ActionConfig) AddRegex(expr string) error
- func (a ActionConfig) AddRegexList(url string) error
- func (a ActionConfig) AddWildcard(wildcard string) error
- func (a ActionConfig) AddWildcardList(url string) error
- func (a ActionConfig) BuildDomains(domains map[string]bool)
- func (a ActionConfig) BuildHosts(domains map[string]bool)
- func (a ActionConfig) BuildRegExps(regexps map[string]*regexp.Regexp)
- func (a ActionConfig) BuildWildcards(wildcards map[string]bool)
- func (a ActionConfig) GetListLoader(uri string) (ListLoader, error)
- type ActionList
- type ActionType
- type FileListLoader
- type Filter
- type HTTPListLoader
- type ListLoader
- type RenderedResponse
- type RespAddress
- type RespNXDomain
- type RespNoData
- type Response
Constants ¶
This section is empty.
Variables ¶
var DNSNameRegexp = regexp.MustCompile(
`^([a-zA-Z0-9_]{1}[a-zA-Z0-9_-]{0,62}){1}(\.[a-zA-Z0-9_]{1}[a-zA-Z0-9_-]{0,62})*[\._]?$`,
)
DNSNameRegexp matches valid domain names. Sourced from https://github.com/asaskevich/govalidator; const DNSName
MIT Licensed, Copyright (c) 2014-2020 Alex Saskevich
var HostsRegexp = regexp.MustCompile(`\s+|\t+`)
HostsRegexp matches multiple spaces or tabspaces for cleaning up each entry
Functions ¶
Types ¶
type ActionConfig ¶
type ActionConfig struct { FileLoader FileListLoader HTTPLoader HTTPListLoader // contains filtered or unexported fields }
ActionConfig contains the raw domains, expressions and lists that are compiled and used by the Filter
func NewActionConfig ¶
func NewActionConfig(action ActionType) ActionConfig
NewActionConfig returns an action ready to accept configurations
func (ActionConfig) AddDomainList ¶
func (a ActionConfig) AddDomainList(url string) error
AddDomainList to match contents
func (ActionConfig) AddHostsList ¶ added in v0.2.0
func (a ActionConfig) AddHostsList(url string) error
AddHostsList to match contents
func (ActionConfig) AddRegexList ¶
func (a ActionConfig) AddRegexList(url string) error
AddRegexList to match contents
func (ActionConfig) AddWildcard ¶
func (a ActionConfig) AddWildcard(wildcard string) error
AddWildcard to match
func (ActionConfig) AddWildcardList ¶
func (a ActionConfig) AddWildcardList(url string) error
AddWildcardList to match contents
func (ActionConfig) BuildDomains ¶
func (a ActionConfig) BuildDomains(domains map[string]bool)
BuildDomains creates a map of unique domains from explicit declarations and lists
func (ActionConfig) BuildHosts ¶ added in v0.3.0
func (a ActionConfig) BuildHosts(domains map[string]bool)
func (ActionConfig) BuildRegExps ¶
func (a ActionConfig) BuildRegExps(regexps map[string]*regexp.Regexp)
BuildRegExps consolidates individual regular expressions then loads and compiles regular expressions from any configured lists
func (ActionConfig) BuildWildcards ¶ added in v0.3.0
func (a ActionConfig) BuildWildcards(wildcards map[string]bool)
func (ActionConfig) GetListLoader ¶ added in v0.2.2
func (a ActionConfig) GetListLoader(uri string) (ListLoader, error)
GetListLoader returns the ListLoader associated with the list's URL scheme
type ActionList ¶
type ActionList map[string]ListLoader
ActionList is list of URLs and the functions required to load them
type ActionType ¶
type ActionType int
ActionType represents the action taken upon domains, expressions, or lists
const ( // ActionTypeAllow represents a domain, expression, or list that will not // be filtered, regardless if the domain or expression is set to be blocked ActionTypeAllow ActionType = iota // ActionTypeBlock represents a domain, expression, or list that will be // filtered ActionTypeBlock )
type FileListLoader ¶ added in v0.2.2
type FileListLoader struct{}
FileListLoader retrieves lists from the local filesystem
func (FileListLoader) Load ¶ added in v0.2.2
func (FileListLoader) Load(path string) (io.ReadCloser, error)
Load implements ListLoader
type Filter ¶
Filter checks if requested domains are blocked then returns the configured response
func (*Filter) Build ¶
func (f *Filter) Build()
Build the domain and regular expression lists used to determine how domains are handled
func (*Filter) InitUpdate ¶
InitUpdate starts the update timer. This should only be run once on startup.
func (*Filter) Name ¶
Name implements the plugin.Handler interface Returns the name of the CoreDNS plugin, in this case "filter"
func (*Filter) OnShutdown ¶
OnShutdown cleans up the filter and prepares it for removal
type HTTPListLoader ¶ added in v0.2.2
HTTPListLoader retrieves lists from remote sources using HTTP/HTTPS
func (HTTPListLoader) Load ¶ added in v0.2.2
func (h HTTPListLoader) Load(path string) (io.ReadCloser, error)
Load implements ListLoader
type ListLoader ¶ added in v0.2.2
type ListLoader interface {
Load(string) (io.ReadCloser, error)
}
ListLoader contains the means to retrieve a list
type RenderedResponse ¶
type RenderedResponse struct { // RCode is the DNS message response code RCode int // Authoritative signals if a response is authoritative. // Useful for NXDOMAIN responses Authoritative bool // Answer records if there are any Answer []dns.RR }
RenderedResponse represents the information a response should return to the Filter.ServeDNS function
type RespAddress ¶
RespAddress implements Response Return address records for IPv4 (A) and IPv6 (AAAA)
func (RespAddress) Render ¶
func (r RespAddress) Render(qname string, qtype uint16) RenderedResponse
type RespNXDomain ¶
type RespNXDomain struct{}
RespNXDomain implements Response Returns a dummy SOA record and an NXDOMAIN error code
func (RespNXDomain) Render ¶
func (r RespNXDomain) Render(qname string, _ uint16) RenderedResponse
type RespNoData ¶
type RespNoData struct{}
RespNoData implements Response Returns no records
func (RespNoData) Render ¶
func (r RespNoData) Render(_ string, _ uint16) RenderedResponse
type Response ¶
type Response interface {
Render(qname string, qtype uint16) RenderedResponse
}
Response represents what ServeDNS expects to call