fix v6 ip presentation.
Also fix the parsing from /etc/resolv.conf and make it simpler in the process.
This commit is contained in:
parent
9159265f01
commit
ba40d60ce7
|
@ -1,7 +1,5 @@
|
|||
# TODO
|
||||
|
||||
* 'q' standardize ipv6 input with [::1]#53 ?
|
||||
* make example from chaos
|
||||
* Support for on-the-fly-signing
|
||||
* (Re)sign zonefiles
|
||||
* TLSA support
|
||||
|
@ -11,6 +9,6 @@
|
|||
|
||||
## Nice to have
|
||||
|
||||
* Speed, we can always go faster. A simple reflect server now hits 35/45K qps
|
||||
* Speed, we can always go faster. A simple reflect server now hits 45/50K qps
|
||||
* go test; only works correct on my machine
|
||||
* privatekey.Precompute() when signing?
|
||||
|
|
|
@ -32,7 +32,7 @@ func ClientConfigFromFile(conf string) (*ClientConfig, error) {
|
|||
}
|
||||
c := new(ClientConfig)
|
||||
b := bufio.NewReader(file)
|
||||
c.Servers = make([]string, 3)[0:0] // small, but the standard limit
|
||||
c.Servers = make([]string, 0)
|
||||
c.Search = make([]string, 0)
|
||||
c.Port = "53"
|
||||
c.Ndots = 1
|
||||
|
@ -45,21 +45,17 @@ func ClientConfigFromFile(conf string) (*ClientConfig, error) {
|
|||
}
|
||||
switch f[0] {
|
||||
case "nameserver": // add one name server
|
||||
a := c.Servers
|
||||
n := len(a)
|
||||
if len(f) > 1 && n < cap(a) {
|
||||
if len(f) > 1 {
|
||||
// One more check: make sure server name is
|
||||
// just an IP address. Otherwise we need DNS
|
||||
// to look it up.
|
||||
name := f[1]
|
||||
switch len(net.ParseIP(name)) {
|
||||
case 16:
|
||||
switch x := net.ParseIP(name); true {
|
||||
case x.To4() != nil:
|
||||
c.Servers = append(c.Servers, name)
|
||||
case x.To16() != nil:
|
||||
name = "[" + name + "]"
|
||||
fallthrough
|
||||
case 4:
|
||||
a = a[0 : n+1]
|
||||
a[n] = name
|
||||
c.Servers = a
|
||||
c.Servers = append(c.Servers, name)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
16
ex/q/q.go
16
ex/q/q.go
|
@ -105,9 +105,19 @@ Flags:
|
|||
qtype = dns.TypeA
|
||||
}
|
||||
|
||||
nameserver = dns.Fqdn(string([]byte(nameserver)[1:])) // chop off @
|
||||
nameserver += ":" + strconv.Itoa(*port)
|
||||
|
||||
nameserver = string([]byte(nameserver)[1:]) // chop off @
|
||||
if i := net.ParseIP(nameserver); i != nil {
|
||||
switch {
|
||||
case i.To4() != nil:
|
||||
// it's a v4 address
|
||||
nameserver += ":" + strconv.Itoa(*port)
|
||||
case i.To16() != nil:
|
||||
// v6 address
|
||||
nameserver = "[" + nameserver + "]:" + strconv.Itoa(*port)
|
||||
}
|
||||
} else {
|
||||
nameserver = dns.Fqdn(nameserver) + ":" + strconv.Itoa(*port)
|
||||
}
|
||||
// We use the async query handling, just to show how it is to be used.
|
||||
c := new(dns.Client)
|
||||
if *tcp {
|
||||
|
|
Loading…
Reference in New Issue