Support SkyDNS' stubzones

This implements stubzones in the same way as SkyDNS. This
also works with multiple configured domains and has tests.
Also add more configuration parameters for TLS and path prefix and
enabling stubzones.  Run StubUpdates as a startup command to keep up to
date with the list in etcd.
This commit is contained in:
Miek Gieben 2016-03-25 20:26:42 +00:00
parent a832ab696a
commit ebef64280a
8 changed files with 403 additions and 98 deletions

View file

@ -52,6 +52,9 @@ func New(hosts []string) Proxy {
return p
}
// Lookup will use name and tpe to forge a new message and will send that upstream. It will
// set any EDNS0 options correctly so that downstream will be able to process the reply.
// Lookup is not suitable for forwarding request. So Forward for that.
func (p Proxy) Lookup(state middleware.State, name string, tpe uint16) (*dns.Msg, error) {
req := new(dns.Msg)
req.SetQuestion(name, tpe)
@ -62,13 +65,17 @@ func (p Proxy) Lookup(state middleware.State, name string, tpe uint16) (*dns.Msg
return p.lookup(state, req)
}
func (p Proxy) Forward(state middleware.State) (*dns.Msg, error) {
return p.lookup(state, state.Req)
}
func (p Proxy) lookup(state middleware.State, r *dns.Msg) (*dns.Msg, error) {
var (
reply *dns.Msg
err error
)
for _, upstream := range p.Upstreams {
// allowed bla bla bla TODO(miek): fix full proxy spec from caddy
// allowed bla bla bla TODO(miek): fix full proxy spec from caddy?
start := time.Now()
// Since Select() should give us "up" hosts, keep retrying