Commit 80b22a50 authored by Miek Gieben's avatar Miek Gieben

middleware/whois: hook it up

Hook it up properly by adding it to the directives list. And add
the Target to the SRV record to actually return valid DNS messages.
parent 30fd2245
......@@ -92,4 +92,5 @@ var directives = []string{
"etcd",
"kubernetes",
"proxy",
"whoami",
}
......@@ -29,11 +29,11 @@ func (wh Whoami) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
switch state.Family() {
case 1:
rr = new(dns.A)
rr.(*dns.A).Hdr = dns.RR_Header{Name: state.QName(), Rrtype: state.QType(), Class: state.QClass()}
rr.(*dns.A).Hdr = dns.RR_Header{Name: state.QName(), Rrtype: dns.TypeA, Class: state.QClass()}
rr.(*dns.A).A = net.ParseIP(ip).To4()
case 2:
rr = new(dns.AAAA)
rr.(*dns.AAAA).Hdr = dns.RR_Header{Name: state.QName(), Rrtype: state.QType(), Class: state.QClass()}
rr.(*dns.AAAA).Hdr = dns.RR_Header{Name: state.QName(), Rrtype: dns.TypeAAAA, Class: state.QClass()}
rr.(*dns.AAAA).AAAA = net.ParseIP(ip)
}
......@@ -41,10 +41,12 @@ func (wh Whoami) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
srv.Hdr = dns.RR_Header{Name: "_" + state.Proto() + "." + state.QName(), Rrtype: dns.TypeSRV, Class: state.QClass()}
port, _ := strconv.Atoi(state.Port())
srv.Port = uint16(port)
srv.Target = "."
a.Extra = append(a.Extra, rr)
a.Extra = append(a.Extra, srv)
a.Extra = []dns.RR{rr, srv}
state.SizeAndDo(a)
w.WriteMsg(a)
return 0, nil
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment