Permalink
Browse files

use net.JoinHostPort

  • Loading branch information...
1 parent c6d50e5 commit 3e4edb13855d8c4016768796b2892aa83eda1933 @miekg miekg committed Dec 23, 2012
Showing with 2 additions and 8 deletions.
  1. +2 −8 check-soa.go
View
@@ -13,7 +13,6 @@ import (
"net"
"os"
"sort"
- "strings"
"time"
)
@@ -88,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
@@ -142,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)
}

3 comments on commit 3e4edb1

Owner

bortzmeyer commented on 3e4edb1 Dec 26, 2012

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.

Contributor

miekg replied Dec 26, 2012

Contributor

miekg replied Dec 26, 2012

Please sign in to comment.