mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 19:56:51 +08:00
Merge from remote branch
This commit is contained in:
commit
6e9d837a7d
|
@ -102,6 +102,7 @@ func (f *fetcher) Update() (interface{}, bool, error) {
|
||||||
hash := md5.Sum(buf)
|
hash := md5.Sum(buf)
|
||||||
if bytes.Equal(f.hash[:], hash[:]) {
|
if bytes.Equal(f.hash[:], hash[:]) {
|
||||||
f.updatedAt = &now
|
f.updatedAt = &now
|
||||||
|
os.Chtimes(f.vehicle.Path(), now, now)
|
||||||
return nil, true, nil
|
return nil, true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,13 +109,13 @@ func (t *DomainTrie) search(node *Node, parts []string) *Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
if c := node.getChild(parts[len(parts)-1]); c != nil {
|
if c := node.getChild(parts[len(parts)-1]); c != nil {
|
||||||
if n := t.search(c, parts[:len(parts)-1]); n != nil {
|
if n := t.search(c, parts[:len(parts)-1]); n != nil && n.Data != nil {
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if c := node.getChild(wildcard); c != nil {
|
if c := node.getChild(wildcard); c != nil {
|
||||||
if n := t.search(c, parts[:len(parts)-1]); n != nil {
|
if n := t.search(c, parts[:len(parts)-1]); n != nil && n.Data != nil {
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,3 +97,11 @@ func TestTrie_Boundary(t *testing.T) {
|
||||||
assert.NotNil(t, tree.Insert("..dev", localIP))
|
assert.NotNil(t, tree.Insert("..dev", localIP))
|
||||||
assert.Nil(t, tree.Search("dev"))
|
assert.Nil(t, tree.Search("dev"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTrie_WildcardBoundary(t *testing.T) {
|
||||||
|
tree := New()
|
||||||
|
tree.Insert("+.*", localIP)
|
||||||
|
tree.Insert("stun.*.*.*", localIP)
|
||||||
|
|
||||||
|
assert.NotNil(t, tree.Search("example.com"))
|
||||||
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ package trie
|
||||||
|
|
||||||
// Node is the trie's node
|
// Node is the trie's node
|
||||||
type Node struct {
|
type Node struct {
|
||||||
Data interface{}
|
|
||||||
children map[string]*Node
|
children map[string]*Node
|
||||||
|
Data interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Node) getChild(s string) *Node {
|
func (n *Node) getChild(s string) *Node {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user