Fix q for ipv6

This commit is contained in:
Miek Gieben 2012-10-15 20:07:53 +02:00
parent 38af8973f7
commit d6a1321fdf
1 changed files with 4 additions and 4 deletions

View File

@ -110,8 +110,11 @@ Flags:
}
nameserver = string([]byte(nameserver)[1:]) // chop off @
// if the nameserver is from /etc/resolv.conf the [ and ] are already
// added, thereby breaking net.ParseIP. Check for this and don't
// fully qualify such a name
if nameserver[0] == '[' && nameserver[len(nameserver)-1] == ']' {
nameserver = nameserver[1:len(nameserver)-1]
nameserver = nameserver[1 : len(nameserver)-1]
}
if i := net.ParseIP(nameserver); i != nil {
switch {
@ -123,9 +126,6 @@ Flags:
nameserver = "[" + nameserver + "]:" + strconv.Itoa(*port)
}
} else {
// if the nameserver is from /etc/resolv.conf the [ and ] are already
// added, thereby breaking net.ParseIP. Check for this and don't
// fully qualify such a name
nameserver = dns.Fqdn(nameserver) + ":" + strconv.Itoa(*port)
}
// We use the async query handling, just to show how it is to be used.