Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fix v6 ip presentation.

Also fix the parsing from /etc/resolv.conf and make it simpler
in the process.
  • Loading branch information...
commit ba40d60ce77a3f3d67945211f530ea96560b0add 1 parent 9159265
Miek Gieben authored

Showing 3 changed files with 21 additions and 17 deletions. Show diff stats Hide diff stats

  1. +1 3 TODO.markdown
  2. +7 11 clientconfig.go
  3. +13 3 ex/q/q.go
4 TODO.markdown
Source Rendered
... ... @@ -1,7 +1,5 @@
1 1 # TODO
2 2
3   -* 'q' standardize ipv6 input with [::1]#53 ?
4   -* make example from chaos
5 3 * Support for on-the-fly-signing
6 4 * (Re)sign zonefiles
7 5 * TLSA support
@@ -11,6 +9,6 @@
11 9
12 10 ## Nice to have
13 11
14   -* Speed, we can always go faster. A simple reflect server now hits 35/45K qps
  12 +* Speed, we can always go faster. A simple reflect server now hits 45/50K qps
15 13 * go test; only works correct on my machine
16 14 * privatekey.Precompute() when signing?
18 clientconfig.go
@@ -32,7 +32,7 @@ func ClientConfigFromFile(conf string) (*ClientConfig, error) {
32 32 }
33 33 c := new(ClientConfig)
34 34 b := bufio.NewReader(file)
35   - c.Servers = make([]string, 3)[0:0] // small, but the standard limit
  35 + c.Servers = make([]string, 0)
36 36 c.Search = make([]string, 0)
37 37 c.Port = "53"
38 38 c.Ndots = 1
@@ -45,21 +45,17 @@ func ClientConfigFromFile(conf string) (*ClientConfig, error) {
45 45 }
46 46 switch f[0] {
47 47 case "nameserver": // add one name server
48   - a := c.Servers
49   - n := len(a)
50   - if len(f) > 1 && n < cap(a) {
  48 + if len(f) > 1 {
51 49 // One more check: make sure server name is
52 50 // just an IP address. Otherwise we need DNS
53 51 // to look it up.
54 52 name := f[1]
55   - switch len(net.ParseIP(name)) {
56   - case 16:
  53 + switch x := net.ParseIP(name); true {
  54 + case x.To4() != nil:
  55 + c.Servers = append(c.Servers, name)
  56 + case x.To16() != nil:
57 57 name = "[" + name + "]"
58   - fallthrough
59   - case 4:
60   - a = a[0 : n+1]
61   - a[n] = name
62   - c.Servers = a
  58 + c.Servers = append(c.Servers, name)
63 59 }
64 60 }
65 61
16 ex/q/q.go
@@ -105,9 +105,19 @@ Flags:
105 105 qtype = dns.TypeA
106 106 }
107 107
108   - nameserver = dns.Fqdn(string([]byte(nameserver)[1:])) // chop off @
109   - nameserver += ":" + strconv.Itoa(*port)
110   -
  108 + nameserver = string([]byte(nameserver)[1:]) // chop off @
  109 + if i := net.ParseIP(nameserver); i != nil {
  110 + switch {
  111 + case i.To4() != nil:
  112 + // it's a v4 address
  113 + nameserver += ":" + strconv.Itoa(*port)
  114 + case i.To16() != nil:
  115 + // v6 address
  116 + nameserver = "[" + nameserver + "]:" + strconv.Itoa(*port)
  117 + }
  118 + } else {
  119 + nameserver = dns.Fqdn(nameserver) + ":" + strconv.Itoa(*port)
  120 + }
111 121 // We use the async query handling, just to show how it is to be used.
112 122 c := new(dns.Client)
113 123 if *tcp {

0 comments on commit ba40d60

Please sign in to comment.
Something went wrong with that request. Please try again.