This commit is contained in:
Elizabeth Hunt 2024-05-12 14:20:47 -07:00
parent bbdf98d88a
commit cd324e1d48
Signed by untrusted user who does not match committer: simponic
GPG Key ID: 2909B9A7FF6213EE
2 changed files with 10 additions and 6 deletions

View File

@ -9,7 +9,7 @@ import (
"log" "log"
) )
const MAX_RECURSION = 15 const MAX_RECURSION = 10
type DnsHandler struct { type DnsHandler struct {
DnsResolvers []string DnsResolvers []string
@ -44,9 +44,9 @@ func (h *DnsHandler) resolveExternal(domain string, qtype uint16) ([]dns.RR, err
return in.Answer, nil 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 { for _, answer := range answers {
if answer.Header().Name == domain && answer.Header().Rrtype == qtype { if answer.Header().Rrtype == qtype {
return true return true
} }
} }
@ -117,13 +117,13 @@ func (h *DnsHandler) resolveDNS(domain string, qtype uint16, maxDepth int) ([]dn
} }
answers = append(answers, externalAnswers...) answers = append(answers, externalAnswers...)
if resultSetFound(externalAnswers, domain, qtype) { if resultSetFound(answers, qtype) {
return answers, false, nil return answers, false, nil
} }
for _, answer := range externalAnswers { for _, answer := range externalAnswers {
cname, ok := answer.(*dns.CNAME) cname, cnameCastErr := answer.(*dns.CNAME)
if !ok { if !cnameCastErr {
continue continue
} }

View File

@ -60,7 +60,11 @@ func main() {
log.Fatal(err) log.Fatal(err)
} }
}() }()
}
if argv.Dns || argv.Server {
select {} select {}
} }
log.Println("no services started")
} }