From b0549a8e5bab6f6cbfd52c29c0b20a2d29d14570 Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Tue, 25 Sep 2018 18:22:41 +0300 Subject: [PATCH 1/4] web UI -- Fix description of hosts rule syntax, it's other way around --- client/src/components/Filters/UserRules.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/components/Filters/UserRules.js b/client/src/components/Filters/UserRules.js index c748c3bc..bfd87b89 100644 --- a/client/src/components/Filters/UserRules.js +++ b/client/src/components/Filters/UserRules.js @@ -44,7 +44,7 @@ export default class UserRules extends Component { domain and all its subdomains
  • - example.org 127.0.0.1 - AdGuard DNS will now return + 127.0.0.1 example.org - AdGuard DNS will now return 127.0.0.1 address for the example.org domain (but not its subdomains).
  • From bd0fa4cc4f9351ad12b0e89b04f346f31fc7a1e1 Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Tue, 25 Sep 2018 18:23:02 +0300 Subject: [PATCH 2/4] Fix 'index out of range' panic when adding a filter URL that has empty line in contents --- control.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/control.go b/control.go index 45b339af..340f8479 100644 --- a/control.go +++ b/control.go @@ -1148,7 +1148,7 @@ func (filter *filter) update(now time.Time) (bool, error) { d := dnsfilter.New() for _, line := range lines { line = strings.TrimSpace(line) - if line[0] == '!' { + if len(line) > 0 && line[0] == '!' { if m := filterTitle.FindAllStringSubmatch(line, -1); len(m) > 0 && len(m[0]) >= 2 && !seenTitle { log.Printf("Setting filter title to %s\n", m[0][1]) filter.Name = m[0][1] From 620212ad37a217fa5a283c20178a6bce738f0de6 Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Tue, 25 Sep 2018 18:34:01 +0300 Subject: [PATCH 3/4] coredns -- don't try to be smart and replace 127.0.0.1 with NXDOMAIN yet -- need research on that first --- coredns_plugin/coredns_plugin.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/coredns_plugin/coredns_plugin.go b/coredns_plugin/coredns_plugin.go index 78c9bb9a..0000156c 100644 --- a/coredns_plugin/coredns_plugin.go +++ b/coredns_plugin/coredns_plugin.go @@ -384,7 +384,8 @@ func (p *plug) serveDNSInternal(ctx context.Context, w dns.ResponseWriter, r *dn // is it in hosts? if val, ok := p.hosts[host]; ok { // it is, if it's a loopback host, reply with NXDOMAIN - if val.IsLoopback() { + // TODO: research if it's better than 127.0.0.1 + if false && val.IsLoopback() { rcode, err := writeNXdomain(ctx, w, r) if err != nil { return rcode, dnsfilter.Result{}, err From 119d38fa8e8b5c5193fe20ad215a6daac833354b Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Tue, 25 Sep 2018 18:34:34 +0300 Subject: [PATCH 4/4] Add trace() for debugging --- helpers.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/helpers.go b/helpers.go index a7e60f77..f28b9ea7 100644 --- a/helpers.go +++ b/helpers.go @@ -3,6 +3,7 @@ package main import ( "bufio" "errors" + "fmt" "io" "net/http" "path" @@ -246,3 +247,17 @@ func _Func() string { f := runtime.FuncForPC(pc[0]) return path.Base(f.Name()) } + +func trace(format string, args ...interface{}) { + pc := make([]uintptr, 10) // at least 1 entry needed + runtime.Callers(2, pc) + f := runtime.FuncForPC(pc[0]) + var buf strings.Builder + buf.WriteString(fmt.Sprintf("%s(): ", path.Base(f.Name()))) + text := fmt.Sprintf(format, args...) + buf.WriteString(text) + if len(text) == 0 || text[len(text)-1] != '\n' { + buf.WriteRune('\n') + } + fmt.Print(buf.String()) +}