aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/main.go b/main.go
index 7f9f8b8..af00591 100644
--- a/main.go
+++ b/main.go
@@ -23,14 +23,14 @@ func main() {
ip := ipnet.IP
for ipnet.Contains(ip) {
if names, err := net.LookupAddr(ip.String()); err != nil {
- fmt.Fprintf(os.Stderr, "%s\t# PTR error: %s\n", ip, err)
+ printErr(ip, "PTR", err)
} else {
fmt.Printf("%s\t%s\n", ip, strings.Join(names, " "))
}
if *txt {
recs, err := net.LookupTXT(arpa(ip))
if err != nil {
- fmt.Fprintf(os.Stderr, "%s\t# TXT error: %s\n", ip, err)
+ printErr(ip, "TXT", err)
} else {
for _, rec := range recs {
fmt.Printf("%s\tTXT %q\n", ip, rec)
@@ -44,6 +44,12 @@ func main() {
}
}
+func printErr(ip net.IP, rrtype string, err error) {
+ if !strings.Contains(err.Error(), "no such host") {
+ fmt.Fprintf(os.Stderr, "%s\t# %s error: %s\n", ip, rrtype, err)
+ }
+}
+
// arpa returns the .in-addr.arpa or .ip6.arpa name corresponding with the given IP.
func arpa(ip net.IP) string {
if ip4 := ip.To4(); ip4 != nil {