Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: bortzmeyer/check-soa
base: cf376e6f0a
...
head fork: bortzmeyer/check-soa
compare: 75ddc520e4
  • 4 commits
  • 1 file changed
  • 3 commit comments
  • 2 contributors
Showing with 8 additions and 22 deletions.
  1. +8 −22 check-soa.go
30 check-soa.go
View
@@ -1,13 +1,8 @@
-/*
-
-A simple program to have rapidly an idea of the health of a DNS
-zone. It queries each name server of the zone for the SOA record and
-displays the value of the serial number for each server.
-
-Stephane Bortzmeyer <bortzmeyer@nic.fr>
-
-*/
-
+// A simple program to have rapidly an idea of the health of a DNS
+// zone. It queries each name server of the zone for the SOA record and
+// displays the value of the serial number for each server.
+//
+// Stephane Bortzmeyer <bortzmeyer@nic.fr>
package main
import (
@@ -18,7 +13,6 @@ import (
"net"
"os"
"sort"
- "strings"
"time"
)
@@ -93,7 +87,7 @@ Tests:
for serverIndex := range conf.Servers {
server := conf.Servers[serverIndex]
result.nameserver = server
- r, rtt, err := localc.Exchange(localm, server+":"+conf.Port)
+ r, rtt, err := localc.Exchange(localm, net.JoinHostPort(server, conf.Port))
if r == nil {
result.r = nil
result.err = err
@@ -147,12 +141,7 @@ func soaQuery(mychan chan SOAreply, zone string, name string, server string) {
c.ReadTimeout = timeout
m.Question[0] = dns.Question{zone, dns.TypeSOA, dns.ClassINET}
nsAddressPort := ""
- if strings.ContainsAny(":", server) {
- /* IPv6 address */
- nsAddressPort = "[" + server + "]:53"
- } else {
- nsAddressPort = server + ":53"
- }
+ nsAddressPort = net.JoinHostPort(server, "53")
if *debug {
fmt.Printf("DEBUG Querying SOA from %s\n", nsAddressPort)
}
@@ -358,10 +347,7 @@ func main() {
flag.Usage()
os.Exit(0)
}
- zone := flag.Arg(0)
- if zone[len(zone)-1] != '.' {
- zone += "."
- }
+ zone := dns.Fqdn(flag.Arg(0))
conf, err = dns.ClientConfigFromFile("/etc/resolv.conf")
if conf == nil {
fmt.Printf("Cannot initialize the local resolver: %s\n", err)

Showing you all comments on commits in this comparison.

Stéphane Bortzmeyer
Owner

Does not work if the resolver in /etc/resolv.conf is an IPv6 litteral: "lookup [::1]: no such host". I switcged back to string concatenation.

Miek Gieben
Miek Gieben
Something went wrong with that request. Please try again.