Skip to content

Commit

Permalink
fix query error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Matchlighter committed Feb 16, 2022
1 parent ca2fdc4 commit c405060
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions cmd/sparse_dns/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,15 @@ func syncResolve(req *dns.Msg) (*dns.Msg, time.Duration, error) {
if err != nil || (resolved != nil && resolved.Truncated) {
resolved, rtt, err = tcpClient.Exchange(req, addr)
}
if (dns.RcodeToString[resolved.Rcode] != "NOERROR") {
continue
if (err != nil) {
return nil, 0, err
}
if err == nil {
if (dns.RcodeToString[resolved.Rcode] == "SERVFAIL") {
break
}
if (dns.RcodeToString[resolved.Rcode] == "NOERROR") {
break
}
}

if err != nil {
return nil, 0, err
}

return resolved, rtt, nil
Expand Down

0 comments on commit c405060

Please sign in to comment.