Added refuseany (enabled by default)
Added ratelimit and refuseany to the config file (for manual editing only)
This commit is contained in:
Andrey Meshkov 2018-11-26 13:38:17 +03:00
parent a6c9210461
commit a0482fc201
3 changed files with 8 additions and 3 deletions

View File

@ -68,6 +68,8 @@ type coreDNSConfig struct {
ParentalSensitivity int `yaml:"parental_sensitivity"` ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL int `yaml:"blocked_response_ttl"` BlockedResponseTTL int `yaml:"blocked_response_ttl"`
QueryLogEnabled bool `yaml:"querylog_enabled"` QueryLogEnabled bool `yaml:"querylog_enabled"`
Ratelimit int `yaml:"-"`
RefuseAny bool `yaml:"-"`
Pprof string `yaml:"-"` Pprof string `yaml:"-"`
Cache string `yaml:"-"` Cache string `yaml:"-"`
Prometheus string `yaml:"-"` Prometheus string `yaml:"-"`
@ -102,6 +104,8 @@ var config = configuration{
SafeBrowsingEnabled: false, SafeBrowsingEnabled: false,
BlockedResponseTTL: 10, // in seconds BlockedResponseTTL: 10, // in seconds
QueryLogEnabled: true, QueryLogEnabled: true,
Ratelimit: 20,
RefuseAny: true,
BootstrapDNS: "8.8.8.8:53", BootstrapDNS: "8.8.8.8:53",
UpstreamDNS: defaultDNS, UpstreamDNS: defaultDNS,
Cache: "cache", Cache: "cache",
@ -253,7 +257,8 @@ const coreDNSConfigTemplate = `.:{{.Port}} {
{{end}} {{end}}
}{{end}} }{{end}}
{{.Pprof}} {{.Pprof}}
ratelimit {{if .RefuseAny}}refuseany{{end}}
{{if gt .Ratelimit 0}}ratelimit {{.Ratelimit}}{{end}}
hosts { hosts {
fallthrough fallthrough
} }

View File

@ -9,6 +9,7 @@ import (
_ "github.com/AdguardTeam/AdGuardHome/coredns_plugin" _ "github.com/AdguardTeam/AdGuardHome/coredns_plugin"
_ "github.com/AdguardTeam/AdGuardHome/coredns_plugin/ratelimit" _ "github.com/AdguardTeam/AdGuardHome/coredns_plugin/ratelimit"
_ "github.com/AdguardTeam/AdGuardHome/coredns_plugin/refuseany"
_ "github.com/AdguardTeam/AdGuardHome/upstream" _ "github.com/AdguardTeam/AdGuardHome/upstream"
"github.com/coredns/coredns/core/dnsserver" "github.com/coredns/coredns/core/dnsserver"
"github.com/coredns/coredns/coremain" "github.com/coredns/coredns/coremain"
@ -65,6 +66,7 @@ var directives = []string{
"prometheus", "prometheus",
"errors", "errors",
"log", "log",
"refuseany",
"ratelimit", "ratelimit",
"dnsfilter", "dnsfilter",
"dnstap", "dnstap",

View File

@ -27,8 +27,6 @@ func (p *plug) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (
q := r.Question[0] q := r.Question[0]
if q.Qtype == dns.TypeANY { if q.Qtype == dns.TypeANY {
log.Printf("Got request with type ANY, will respond with NOTIMP\n")
state := request.Request{W: w, Req: r, Context: ctx} state := request.Request{W: w, Req: r, Context: ctx}
rcode := dns.RcodeNotImplemented rcode := dns.RcodeNotImplemented