mirror of
https://github.com/traefik/traefik.git
synced 2026-02-03 20:39:51 -05:00
Fix kubernetes findMatchingHostname improperly checking specificity
This commit is contained in:
parent
75ac25bb31
commit
7db4dcf299
2 changed files with 9 additions and 9 deletions
|
|
@ -1103,15 +1103,8 @@ func findMatchingHostname(h1, h2 gatev1.Hostname) gatev1.Hostname {
|
|||
return ""
|
||||
}
|
||||
|
||||
return lessWildcards(h1, h2)
|
||||
}
|
||||
|
||||
func lessWildcards(h1, h2 gatev1.Hostname) gatev1.Hostname {
|
||||
if strings.Count(string(h1), "*") > strings.Count(string(h2), "*") {
|
||||
return h2
|
||||
}
|
||||
|
||||
return h1
|
||||
// since h1 is a suffix of h2, we know h2 is the more specific host
|
||||
return h2
|
||||
}
|
||||
|
||||
func allowRoute(listener gatewayListener, routeNamespace, routeKind string) bool {
|
||||
|
|
|
|||
|
|
@ -7630,6 +7630,13 @@ func Test_findMatchingHostnames(t *testing.T) {
|
|||
want: []gatev1.Hostname{"toto.foo.com", "test.foo.com"},
|
||||
wantOk: true,
|
||||
},
|
||||
{
|
||||
desc: "Matching wildcard subsubdomain with listener wildcard subdomain",
|
||||
listenerHostname: ptr.To(gatev1.Hostname("*.foo.com")),
|
||||
routeHostnames: []gatev1.Hostname{"*.bar.foo.com"},
|
||||
want: []gatev1.Hostname{"*.bar.foo.com"},
|
||||
wantOk: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
|
|
|
|||
Loading…
Reference in a new issue