Stub forward/proxy tests (#108)

Test the handling of EDNS0 payloads and forwarding to stubzones
servers.
This commit is contained in:
Miek Gieben 2016-04-12 21:30:08 +01:00
parent 9f651a397b
commit 27ff83e70f
9 changed files with 144 additions and 186 deletions

View file

@ -12,6 +12,7 @@ import (
"github.com/miekg/dns"
)
// New create a new proxy with the hosts in host and a Random policy.
func New(hosts []string) Proxy {
p := Proxy{Next: nil, Client: Clients()}
@ -31,7 +32,7 @@ func New(hosts []string) Proxy {
Fails: 0,
FailTimeout: upstream.FailTimeout,
Unhealthy: false,
ExtraHeaders: upstream.proxyHeaders,
ExtraHeaders: upstream.proxyHeaders, // TODO(miek): fixer the fix
CheckDown: func(upstream *staticUpstream) UpstreamHostDownFunc {
return func(uh *UpstreamHost) bool {
if uh.Unhealthy {
@ -80,6 +81,7 @@ func (p Proxy) lookup(state middleware.State, r *dns.Msg) (*dns.Msg, error) {
for time.Now().Sub(start) < tryDuration {
host := upstream.Select()
if host == nil {
// TODO(miek): if all HC fail, spray the targets.
return nil, errUnreachable
}