From 191d8306062692a204603eda2ea307ed8c726598 Mon Sep 17 00:00:00 2001 From: Kevin Wallace Date: Fri, 22 Feb 2019 00:30:03 -0800 Subject: catch NXDOMAIN-related errors on OSX, too Maybe time to move off of the stdlib dns library. This error handling sucks. --- main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index af00591..ca024a9 100644 --- a/main.go +++ b/main.go @@ -45,7 +45,10 @@ func main() { } func printErr(ip net.IP, rrtype string, err error) { - if !strings.Contains(err.Error(), "no such host") { + // the error types here are awful and this feels like it might + // accidentally catch some non-NXDOMAIN errors + if !strings.HasSuffix(err.Error(), "no such host") && + !strings.HasSuffix(err.Error(), "nodename nor servname provided, or not known") { fmt.Fprintf(os.Stderr, "%s\t# %s error: %s\n", ip, rrtype, err) } } -- cgit v1.2.3