mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-02-27 01:07:10 +00:00
feat: support fake-ip-filter-mode: rule mode (#2469)
This commit is contained in:
@@ -4,13 +4,29 @@ import (
|
||||
C "github.com/metacubex/mihomo/constant"
|
||||
)
|
||||
|
||||
const (
|
||||
UseFakeIP = "fake-ip"
|
||||
UseRealIP = "real-ip"
|
||||
)
|
||||
|
||||
type Skipper struct {
|
||||
Host []C.DomainMatcher
|
||||
Mode C.FilterMode
|
||||
Rules []C.Rule
|
||||
Host []C.DomainMatcher
|
||||
Mode C.FilterMode
|
||||
}
|
||||
|
||||
// ShouldSkipped return if domain should be skipped
|
||||
func (p *Skipper) ShouldSkipped(domain string) bool {
|
||||
if len(p.Rules) > 0 {
|
||||
metadata := &C.Metadata{Host: domain}
|
||||
for _, rule := range p.Rules {
|
||||
if matched, action := rule.Match(metadata, C.RuleMatchHelper{}); matched {
|
||||
return action == UseRealIP
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
should := p.shouldSkipped(domain)
|
||||
if p.Mode == C.FilterWhiteList {
|
||||
return !should
|
||||
|
||||
Reference in New Issue
Block a user