clash/rule/final.go

45 lines
672 B
Go
Raw Normal View History

2018-06-10 14:50:03 +00:00
package rules
import (
C "github.com/Dreamacro/clash/constant"
)
2019-02-18 13:53:57 +00:00
type Match struct {
2021-11-17 08:03:47 +00:00
adapter string
ruleExtra *C.RuleExtra
2018-06-10 14:50:03 +00:00
}
2019-02-18 13:53:57 +00:00
func (f *Match) RuleType() C.RuleType {
return C.MATCH
2018-06-10 14:50:03 +00:00
}
func (f *Match) Match(metadata *C.Metadata) bool {
2018-06-10 14:50:03 +00:00
return true
}
2019-02-18 13:53:57 +00:00
func (f *Match) Adapter() string {
2018-06-10 14:50:03 +00:00
return f.adapter
}
2019-02-18 13:53:57 +00:00
func (f *Match) Payload() string {
2018-06-20 14:41:02 +00:00
return ""
}
func (f *Match) ShouldResolveIP() bool {
return false
}
2021-11-17 08:03:47 +00:00
func (f *Match) RuleExtra() *C.RuleExtra {
return f.ruleExtra
}
func NewMatch(adapter string, ruleExtra *C.RuleExtra) *Match {
if ruleExtra.SourceIPs == nil {
ruleExtra = nil
}
2019-02-18 13:53:57 +00:00
return &Match{
2021-11-17 08:03:47 +00:00
adapter: adapter,
ruleExtra: ruleExtra,
2018-06-10 14:50:03 +00:00
}
}