mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-12-13 15:57:15 +00:00
check init state of DomainMatcherGroup. fixes #1238
This commit is contained in:
parent
fca324a399
commit
899b1399ee
@ -39,6 +39,10 @@ func (g *DomainMatcherGroup) Add(domain string, value uint32) {
|
|||||||
|
|
||||||
func (g *DomainMatcherGroup) Match(domain string) uint32 {
|
func (g *DomainMatcherGroup) Match(domain string) uint32 {
|
||||||
current := g.root
|
current := g.root
|
||||||
|
if current == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
parts := breakDomain(domain)
|
parts := breakDomain(domain)
|
||||||
for i := len(parts) - 1; i >= 0; i-- {
|
for i := len(parts) - 1; i >= 0; i-- {
|
||||||
part := parts[i]
|
part := parts[i]
|
||||||
|
|||||||
@ -33,3 +33,11 @@ func TestDomainMatcherGroup(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestEmptyDomainMatcherGroup(t *testing.T) {
|
||||||
|
g := new(DomainMatcherGroup)
|
||||||
|
r := g.Match("v2ray.com")
|
||||||
|
if r != 0 {
|
||||||
|
t.Error("Expect 0, but ", r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user