chore: add sourceGeoIP and sourceIPASN to metadata

This commit is contained in:
wwqgtxx
2024-08-28 12:25:45 +08:00
parent 8483178524
commit 4fecf68b8b
17 changed files with 211 additions and 211 deletions

View File

@@ -35,7 +35,7 @@ type Pool struct {
offset netip.Addr
cycle bool
mux sync.Mutex
host []C.Rule
host []C.DomainMatcher
ipnet netip.Prefix
store store
}
@@ -66,8 +66,8 @@ func (p *Pool) LookBack(ip netip.Addr) (string, bool) {
// ShouldSkipped return if domain should be skipped
func (p *Pool) ShouldSkipped(domain string) bool {
for _, rule := range p.host {
if match, _ := rule.Match(&C.Metadata{Host: domain}); match {
for _, matcher := range p.host {
if matcher.MatchDomain(domain) {
return true
}
}
@@ -156,7 +156,7 @@ func (p *Pool) restoreState() {
type Options struct {
IPNet netip.Prefix
Host []C.Rule
Host []C.DomainMatcher
// Size sets the maximum number of entries in memory
// and does not work if Persistence is true

View File

@@ -10,7 +10,6 @@ import (
"github.com/metacubex/mihomo/component/profile/cachefile"
"github.com/metacubex/mihomo/component/trie"
C "github.com/metacubex/mihomo/constant"
RP "github.com/metacubex/mihomo/rules/provider"
"github.com/metacubex/bbolt"
"github.com/stretchr/testify/assert"
@@ -157,7 +156,7 @@ func TestPool_Skip(t *testing.T) {
pools, tempfile, err := createPools(Options{
IPNet: ipnet,
Size: 10,
Host: []C.Rule{RP.NewDomainSet(tree.NewDomainSet(), "")},
Host: []C.DomainMatcher{tree.NewDomainSet()},
})
assert.Nil(t, err)
defer os.Remove(tempfile)