chore: cleanup dns policy match code

This commit is contained in:
wwqgtxx
2024-08-15 20:04:24 +08:00
parent 4c10d42fbf
commit 92ec5f2236
9 changed files with 241 additions and 420 deletions

View File

@@ -19,10 +19,7 @@ func (d *DomainSet) RuleType() C.RuleType {
}
func (d *DomainSet) Match(metadata *C.Metadata) (bool, string) {
if d.domainSet == nil {
return false, ""
}
return d.domainSet.Has(metadata.RuleHost()), d.adapter
return d.domainStrategy.Match(metadata), d.adapter
}
func (d *DomainSet) Adapter() string {

View File

@@ -0,0 +1,40 @@
package provider
import (
"github.com/metacubex/mihomo/component/cidr"
C "github.com/metacubex/mihomo/constant"
)
type IpCidrSet struct {
*ipcidrStrategy
adapter string
}
func (d *IpCidrSet) ProviderNames() []string {
return nil
}
func (d *IpCidrSet) RuleType() C.RuleType {
return C.IpCidrSet
}
func (d *IpCidrSet) Match(metadata *C.Metadata) (bool, string) {
return d.ipcidrStrategy.Match(metadata), d.adapter
}
func (d *IpCidrSet) Adapter() string {
return d.adapter
}
func (d *IpCidrSet) Payload() string {
return ""
}
func NewIpCidrSet(cidrSet *cidr.IpCidrSet, adapter string) *IpCidrSet {
return &IpCidrSet{
ipcidrStrategy: &ipcidrStrategy{cidrSet: cidrSet},
adapter: adapter,
}
}
var _ C.Rule = (*IpCidrSet)(nil)