mirror of
https://github.com/coredns/coredns.git
synced 2025-11-11 06:22:24 -05:00
middleware/proxy: fix except keyword (#505)
Fix the except keyword usage - the config would allow it, but it was
not enforced in the code.
Turns out that **FROM** was also not enforced, fix both, by (basically)
copying the code from Caddy.
Update the README and tests.
Locally test as well, shows that this works:
~~~
.:1053 {
proxy miek.nl 8.8.8.8:53 {
except a.miek.nl
}
proxy a.miek.nl 8.8.4.4:53
errors stdout
log stdout
}
~~~
And gives the desired results, not having a proxy line for `a.miek.nl`
results in a SERVFAIL (as expected).
Fixes #502
This commit is contained in:
@@ -16,7 +16,7 @@ func NewLookup(hosts []string) Proxy {
|
||||
p := Proxy{Next: nil}
|
||||
|
||||
upstream := &staticUpstream{
|
||||
from: "",
|
||||
from: ".",
|
||||
Hosts: make([]*UpstreamHost, len(hosts)),
|
||||
Policy: &Random{},
|
||||
Spray: nil,
|
||||
@@ -71,7 +71,11 @@ func (p Proxy) Forward(state request.Request) (*dns.Msg, error) {
|
||||
}
|
||||
|
||||
func (p Proxy) lookup(state request.Request) (*dns.Msg, error) {
|
||||
for _, upstream := range *p.Upstreams {
|
||||
upstream := p.match(state)
|
||||
if upstream == nil {
|
||||
return nil, errInvalidDomain
|
||||
}
|
||||
for {
|
||||
start := time.Now()
|
||||
|
||||
// Since Select() should give us "up" hosts, keep retrying
|
||||
@@ -106,5 +110,4 @@ func (p Proxy) lookup(state request.Request) (*dns.Msg, error) {
|
||||
}
|
||||
return nil, errUnreachable
|
||||
}
|
||||
return nil, errUnreachable
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user