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++ {
|
||||
if ss.labels[nextBmIdx-nextNodeId] == domainStepByte {
|
||||
if nextBmIdx-nextNodeId < len(ss.labels) && ss.labels[nextBmIdx-nextNodeId] == domainStepByte {
|
||||
bmIdx = nextBmIdx
|
||||
nodeId = nextNodeId
|
||||
i = j
|
||||
|
|
|
@ -65,6 +65,7 @@ func TestDomainSetWildcard(t *testing.T) {
|
|||
"stun.*.*",
|
||||
"*.*.qq.com",
|
||||
"test.*.baidu.com",
|
||||
"*.apple.com",
|
||||
}
|
||||
|
||||
for _, domain := range domainSet {
|
||||
|
@ -78,6 +79,7 @@ func TestDomainSetWildcard(t *testing.T) {
|
|||
assert.True(t, set.Has("stun.ab.cd"))
|
||||
assert.False(t, set.Has("test.baidu.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.test.test.qq.com"))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue