Compile fixes and make it work

This commit is contained in:
Miek Gieben 2016-11-10 12:58:40 +00:00
parent d383f279a0
commit 9328a8e7a4
6 changed files with 9 additions and 3 deletions

View file

@ -75,7 +75,7 @@ func (a Auto) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (i
return xfr.ServeDNS(ctx, w, r)
}
answer, ns, extra, result := z.Lookup(qname, state.QType(), state.Do())
answer, ns, extra, result := z.Lookup(state, qname)
m := new(dns.Msg)
m.SetReply(r)

View file

@ -147,7 +147,7 @@ func autoParse(c *caddy.Controller) (Auto, error) {
case "upstream":
args := c.RemainingArgs()
if len(args) == 0 {
return a, false, c.ArgErr()
return a, c.ArgErr()
}
for i := 0; i < len(args); i++ {
h, p, e := net.SplitHostPort(args[i])

View file

@ -39,6 +39,7 @@ func TestAutoParse(t *testing.T) {
directory /tmp (.*) bliep
transfer to 127.0.0.1
transfer to 127.0.0.2
upstream 8.8.8.8
}`,
false, "/tmp", "bliep", `(.*)`, []string{"127.0.0.1:53", "127.0.0.2:53"},
},

View file

@ -136,6 +136,8 @@ var exernalTestCases = []test.Case{
Qname: "external.example.org.", Qtype: dns.TypeA,
Answer: []dns.RR{
test.CNAME("external.example.org. 1800 CNAME www.example.net."),
// magic 303 TTL that says: don't check TTL.
test.A("www.example.net. 303 IN A 93.184.216.34"),
},
},
}

View file

@ -339,10 +339,12 @@ func cnameForType(targets []dns.RR, origQtype uint16) []dns.RR {
func (z *Zone) externalLookup(state request.Request, target string, qtype uint16) []dns.RR {
m, e := z.Proxy.Lookup(state, target, qtype)
if e != nil || m == nil {
if e != nil {
println(e.Error())
// TODO(miek): debugMsg for this as well? Log?
return nil
}
println(m.String())
return m.Answer
}

View file

@ -75,6 +75,7 @@ func (p Proxy) lookup(state request.Request, r *dns.Msg) (*dns.Msg, error) {
// hosts until timeout (or until we get a nil host).
for time.Now().Sub(start) < tryDuration {
host := upstream.Select()
println(host.Name)
if host == nil {
return nil, errUnreachable
}