Merge pull request #35 in DNS/adguard-dns from bugfix/343 to master
* commit '119d38fa8e8b5c5193fe20ad215a6daac833354b': Add trace() for debugging coredns -- don't try to be smart and replace 127.0.0.1 with NXDOMAIN yet -- need research on that first Fix 'index out of range' panic when adding a filter URL that has empty line in contents web UI -- Fix description of hosts rule syntax, it's other way around
This commit is contained in:
commit
afd1fe21f6
|
@ -44,7 +44,7 @@ export default class UserRules extends Component {
|
||||||
domain and all its subdomains
|
domain and all its subdomains
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<code>example.org 127.0.0.1</code> - AdGuard DNS will now return
|
<code>127.0.0.1 example.org</code> - AdGuard DNS will now return
|
||||||
127.0.0.1 address for the example.org domain (but not its subdomains).
|
127.0.0.1 address for the example.org domain (but not its subdomains).
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
|
|
@ -1148,7 +1148,7 @@ func (filter *filter) update(now time.Time) (bool, error) {
|
||||||
d := dnsfilter.New()
|
d := dnsfilter.New()
|
||||||
for _, line := range lines {
|
for _, line := range lines {
|
||||||
line = strings.TrimSpace(line)
|
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 {
|
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])
|
log.Printf("Setting filter title to %s\n", m[0][1])
|
||||||
filter.Name = m[0][1]
|
filter.Name = m[0][1]
|
||||||
|
|
|
@ -384,7 +384,8 @@ func (p *plug) serveDNSInternal(ctx context.Context, w dns.ResponseWriter, r *dn
|
||||||
// is it in hosts?
|
// is it in hosts?
|
||||||
if val, ok := p.hosts[host]; ok {
|
if val, ok := p.hosts[host]; ok {
|
||||||
// it is, if it's a loopback host, reply with NXDOMAIN
|
// 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)
|
rcode, err := writeNXdomain(ctx, w, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return rcode, dnsfilter.Result{}, err
|
return rcode, dnsfilter.Result{}, err
|
||||||
|
|
15
helpers.go
15
helpers.go
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
"path"
|
||||||
|
@ -246,3 +247,17 @@ func _Func() string {
|
||||||
f := runtime.FuncForPC(pc[0])
|
f := runtime.FuncForPC(pc[0])
|
||||||
return path.Base(f.Name())
|
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())
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue