diff --git a/hcdns/server.go b/hcdns/server.go index 0fe412b..385c2ef 100644 --- a/hcdns/server.go +++ b/hcdns/server.go @@ -9,7 +9,7 @@ import ( "log" ) -const MAX_RECURSION = 15 +const MAX_RECURSION = 10 type DnsHandler struct { DnsResolvers []string @@ -44,9 +44,9 @@ func (h *DnsHandler) resolveExternal(domain string, qtype uint16) ([]dns.RR, err return in.Answer, nil } -func resultSetFound(answers []dns.RR, domain string, qtype uint16) bool { +func resultSetFound(answers []dns.RR, qtype uint16) bool { for _, answer := range answers { - if answer.Header().Name == domain && answer.Header().Rrtype == qtype { + if answer.Header().Rrtype == qtype { return true } } @@ -117,13 +117,13 @@ func (h *DnsHandler) resolveDNS(domain string, qtype uint16, maxDepth int) ([]dn } answers = append(answers, externalAnswers...) - if resultSetFound(externalAnswers, domain, qtype) { + if resultSetFound(answers, qtype) { return answers, false, nil } for _, answer := range externalAnswers { - cname, ok := answer.(*dns.CNAME) - if !ok { + cname, cnameCastErr := answer.(*dns.CNAME) + if !cnameCastErr { continue } diff --git a/main.go b/main.go index e92f777..fd703f0 100644 --- a/main.go +++ b/main.go @@ -60,7 +60,11 @@ func main() { log.Fatal(err) } }() + } + if argv.Dns || argv.Server { select {} } + + log.Println("no services started") }