mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 02:33:14 -04:00
Use dns.IsSubDomain (#112)
For the match function use the proper thing from go dns. Fix all callers and tests to use this. Fixes: #107
This commit is contained in:
@@ -238,6 +238,9 @@ func (u *staticUpstream) Select() *UpstreamHost {
|
||||
|
||||
func (u *staticUpstream) IsAllowedPath(name string) bool {
|
||||
for _, ignoredSubDomain := range u.IgnoredSubDomains {
|
||||
if dns.Name(name) == dns.Name(u.From()) {
|
||||
return true
|
||||
}
|
||||
if middleware.Name(name).Matches(ignoredSubDomain + u.From()) {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ func TestAllowedPaths(t *testing.T) {
|
||||
for i, test := range tests {
|
||||
isAllowed := upstream.IsAllowedPath(test.name)
|
||||
if test.expected != isAllowed {
|
||||
t.Errorf("Test %d: expected %v found %v", i+1, test.expected, isAllowed)
|
||||
t.Errorf("Test %d: expected %v found %v for %s", i+1, test.expected, isAllowed, test.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user