Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1

Merged
merged 3 commits into from Dec 23, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 8 additions & 22 deletions check-soa.go
@@ -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 (
Expand All @@ -18,7 +13,6 @@ import (
"net"
"os"
"sort"
"strings"
"time"
)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
Expand Down