fix: domain-set wildcard match
This commit is contained in:
parent
e1af1abcc2
commit
d8db25ee89
2 changed files with 3 additions and 1 deletions
|
@ -105,7 +105,7 @@ func (ss *DomainSet) Has(key string) bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for ; ; nextBmIdx++ {
|
for ; ; nextBmIdx++ {
|
||||||
if ss.labels[nextBmIdx-nextNodeId] == domainStepByte {
|
if nextBmIdx-nextNodeId < len(ss.labels) && ss.labels[nextBmIdx-nextNodeId] == domainStepByte {
|
||||||
bmIdx = nextBmIdx
|
bmIdx = nextBmIdx
|
||||||
nodeId = nextNodeId
|
nodeId = nextNodeId
|
||||||
i = j
|
i = j
|
||||||
|
|
|
@ -65,6 +65,7 @@ func TestDomainSetWildcard(t *testing.T) {
|
||||||
"stun.*.*",
|
"stun.*.*",
|
||||||
"*.*.qq.com",
|
"*.*.qq.com",
|
||||||
"test.*.baidu.com",
|
"test.*.baidu.com",
|
||||||
|
"*.apple.com",
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, domain := range domainSet {
|
for _, domain := range domainSet {
|
||||||
|
@ -78,6 +79,7 @@ func TestDomainSetWildcard(t *testing.T) {
|
||||||
assert.True(t, set.Has("stun.ab.cd"))
|
assert.True(t, set.Has("stun.ab.cd"))
|
||||||
assert.False(t, set.Has("test.baidu.com"))
|
assert.False(t, set.Has("test.baidu.com"))
|
||||||
assert.False(t, set.Has("www.google.com"))
|
assert.False(t, set.Has("www.google.com"))
|
||||||
|
assert.False(t, set.Has("a.www.google.com"))
|
||||||
assert.False(t, set.Has("test.qq.com"))
|
assert.False(t, set.Has("test.qq.com"))
|
||||||
assert.False(t, set.Has("test.test.test.qq.com"))
|
assert.False(t, set.Has("test.test.test.qq.com"))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue