Merge pull request #53 in DNS/adguard-dns from bugfix/shoult_not_happen_spam to master
* commit '3a7a80f15f0180836077b4f63e504a659133adbb': coredns plugin -- fix SHOULD NOT HAPPEN spam when incoming request is for root servers Makefile -- update pprof plugin to survive coredns reloads
This commit is contained in:
commit
16fd1359cd
2
Makefile
2
Makefile
|
@ -32,6 +32,8 @@ coredns: coredns_plugin/*.go dnsfilter/*.go
|
||||||
cd $(GOPATH)/src/github.com/coredns/coredns && perl -p -i.bak -e 's/^(trace|route53|federation|kubernetes|etcd):.*//' plugin.cfg
|
cd $(GOPATH)/src/github.com/coredns/coredns && perl -p -i.bak -e 's/^(trace|route53|federation|kubernetes|etcd):.*//' plugin.cfg
|
||||||
cd $(GOPATH)/src/github.com/coredns/coredns && grep -q '^dnsfilter:' plugin.cfg || perl -p -i.bak -e 's|^log:log|log:log\ndnsfilter:github.com/AdguardTeam/AdguardDNS/coredns_plugin|' plugin.cfg
|
cd $(GOPATH)/src/github.com/coredns/coredns && grep -q '^dnsfilter:' plugin.cfg || perl -p -i.bak -e 's|^log:log|log:log\ndnsfilter:github.com/AdguardTeam/AdguardDNS/coredns_plugin|' plugin.cfg
|
||||||
grep '^dnsfilter:' $(GOPATH)/src/github.com/coredns/coredns/plugin.cfg ## used to check that plugin.cfg was successfully edited by sed
|
grep '^dnsfilter:' $(GOPATH)/src/github.com/coredns/coredns/plugin.cfg ## used to check that plugin.cfg was successfully edited by sed
|
||||||
|
perl -0777 -p -i.bak -e 's/pprofOnce.Do\(func\(\) {(.*)}\)/\1/ms' $(GOPATH)/src/github.com/coredns/coredns/plugin/pprof/setup.go
|
||||||
|
perl -0777 -p -i.bak -e 's/c.OnShutdown/c.OnRestart/' $(GOPATH)/src/github.com/coredns/coredns/plugin/pprof/setup.go
|
||||||
cd $(GOPATH)/src/github.com/coredns/coredns && GOPATH=$(GOPATH) GOOS=$(NATIVE_GOOS) GOARCH=$(NATIVE_GOARCH) go generate
|
cd $(GOPATH)/src/github.com/coredns/coredns && GOPATH=$(GOPATH) GOOS=$(NATIVE_GOOS) GOARCH=$(NATIVE_GOARCH) go generate
|
||||||
cd $(GOPATH)/src/github.com/coredns/coredns && GOPATH=$(GOPATH) go get -v -d .
|
cd $(GOPATH)/src/github.com/coredns/coredns && GOPATH=$(GOPATH) go get -v -d .
|
||||||
cd $(GOPATH)/src/github.com/coredns/coredns && GOPATH=$(GOPATH) go build -o $(mkfile_dir)/coredns
|
cd $(GOPATH)/src/github.com/coredns/coredns && GOPATH=$(GOPATH) go build -o $(mkfile_dir)/coredns
|
||||||
|
|
|
@ -446,8 +446,15 @@ func (p *plug) serveDNSInternal(ctx context.Context, w dns.ResponseWriter, r *dn
|
||||||
return rcode, dnsfilter.Result{}, err
|
return rcode, dnsfilter.Result{}, err
|
||||||
}
|
}
|
||||||
return rcode, result, err
|
return rcode, result, err
|
||||||
|
case dnsfilter.FilteredInvalid:
|
||||||
|
// return NXdomain
|
||||||
|
rcode, err := p.writeNXdomain(ctx, w, r)
|
||||||
|
if err != nil {
|
||||||
|
return rcode, dnsfilter.Result{}, err
|
||||||
|
}
|
||||||
|
return rcode, result, err
|
||||||
default:
|
default:
|
||||||
log.Printf("SHOULD NOT HAPPEN -- got unknown reason for filtering: %T %v %s", result.Reason, result.Reason, result.Reason.String())
|
log.Printf("SHOULD NOT HAPPEN -- got unknown reason for filtering host \"%s\": %v, %+v", host, result.Reason, result)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch result.Reason {
|
switch result.Reason {
|
||||||
|
@ -457,7 +464,7 @@ func (p *plug) serveDNSInternal(ctx context.Context, w dns.ResponseWriter, r *dn
|
||||||
case dnsfilter.NotFilteredNotFound:
|
case dnsfilter.NotFilteredNotFound:
|
||||||
// do nothing, pass through to lower code
|
// do nothing, pass through to lower code
|
||||||
default:
|
default:
|
||||||
log.Printf("SHOULD NOT HAPPEN -- got unknown reason for not filtering: %T %v %s", result.Reason, result.Reason, result.Reason.String())
|
log.Printf("SHOULD NOT HAPPEN -- got unknown reason for not filtering host \"%s\": %v, %+v", host, result.Reason, result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,9 +148,9 @@ func (r Reason) Matched() bool {
|
||||||
|
|
||||||
// CheckHost tries to match host against rules, then safebrowsing and parental if they are enabled
|
// CheckHost tries to match host against rules, then safebrowsing and parental if they are enabled
|
||||||
func (d *Dnsfilter) CheckHost(host string) (Result, error) {
|
func (d *Dnsfilter) CheckHost(host string) (Result, error) {
|
||||||
// sometimes DNS clients will try to resolve ".", which in turns transforms into "" when it reaches here
|
// sometimes DNS clients will try to resolve ".", which is a request to get root servers
|
||||||
if host == "" {
|
if host == "" {
|
||||||
return Result{Reason: FilteredInvalid}, nil
|
return Result{Reason: NotFilteredNotFound}, nil
|
||||||
}
|
}
|
||||||
host = strings.ToLower(host)
|
host = strings.ToLower(host)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue