Add etcd middleware

This middleware acts in the same way as SkyDNS. We might add options
to allow it to be behave different, but for now it will suffice.

A Corefile like:
.:1053 {
    etcd miek.nl
    proxy . 8.8.8.8:53
}
will perform lookup in etcd and proxy everything not miek.nl to Google
for further resolution.

The internal etcd forwarding *also* uses the proxy infrastructure,
meaning you get health check and such for (almost) free
This commit is contained in:
Miek Gieben
2016-03-20 17:44:58 +00:00
parent 15518b5b6f
commit 8f9f2cd1ab
19 changed files with 1575 additions and 8 deletions

View File

@@ -83,6 +83,30 @@ func (s State) Family() int {
return 2
}
// Do returns if the request has the DO (DNSSEC OK) bit set.
func (s State) Do() bool {
if o := s.Req.IsEdns0(); o != nil {
return o.Do()
}
return false
}
// UDPSize returns if UDP buffer size advertised in the requests OPT record.
// Or when the request was over TCP, we return the maximum allowed size of 64K.
func (s State) Size() int {
if s.Proto() == "tcp" {
return dns.MaxMsgSize
}
if o := s.Req.IsEdns0(); o != nil {
s := o.UDPSize()
if s < dns.MinMsgSize {
s = dns.MinMsgSize
}
return int(s)
}
return dns.MinMsgSize
}
// Type returns the type of the question as a string.
func (s State) Type() string {
return dns.Type(s.Req.Question[0].Qtype).String()