fix: remove automatic retry when doh fails

This commit is contained in:
ohaiibuzzle 2024-08-12 22:33:31 +07:00
parent e9de332163
commit c8c18a4651

View File

@ -93,16 +93,13 @@ func dohLookup(domain string) (string, error) {
dnsUpstream := util.GetConfig().DnsAddr dnsUpstream := util.GetConfig().DnsAddr
client := GetDoHClient(*dnsUpstream) client := GetDoHClient(*dnsUpstream)
// try up to 3 times resp, err := client.Resolve(ctx, domain, []uint16{dns.TypeA, dns.TypeAAAA})
for i := 0; i < 3; i++ { if err == nil {
resp, err := client.Resolve(ctx, domain, []uint16{dns.TypeA, dns.TypeAAAA}) if len(resp) == 0 { // yes this happens
if err == nil { return "", errors.New("no record found(doh)")
if len(resp) == 0 { // yes this happens
return "", errors.New("no record found(doh)")
}
return resp[0], nil
} }
return resp[0], nil
} }
return "", errors.New("could not resolve the domain(doh)") return "", errors.New("could not resolve the domain(doh)")