2022-01-22 22:10:45 +08:00
|
|
|
package common
|
2018-06-10 22:50:03 +08:00
|
|
|
|
|
|
|
import (
|
2023-11-03 21:01:45 +08:00
|
|
|
C "github.com/metacubex/mihomo/constant"
|
2018-06-10 22:50:03 +08:00
|
|
|
)
|
|
|
|
|
2019-02-18 21:53:57 +08:00
|
|
|
type Match struct {
|
2022-03-13 01:21:23 +08:00
|
|
|
*Base
|
|
|
|
adapter string
|
2018-06-10 22:50:03 +08:00
|
|
|
}
|
|
|
|
|
2019-02-18 21:53:57 +08:00
|
|
|
func (f *Match) RuleType() C.RuleType {
|
|
|
|
return C.MATCH
|
2018-06-10 22:50:03 +08:00
|
|
|
}
|
|
|
|
|
feat: support sub-rule, eg.
rules:
- SUB-RULE,(AND,((NETWORK,TCP),(DOMAIN-KEYWORD,google))),TEST2
- SUB-RULE,(GEOIP,!CN),TEST1
- MATCH,DIRECT
sub-rules:
TEST2:
- MATCH,Proxy
TEST1:
- RULE-SET,Local,DIRECT,no-resolve
- GEOSITE,CN,Domestic
- GEOIP,CN,Domestic
- MATCH,Proxy
2022-09-06 17:30:35 +08:00
|
|
|
func (f *Match) Match(metadata *C.Metadata) (bool, string) {
|
|
|
|
return true, f.adapter
|
2018-06-10 22:50:03 +08:00
|
|
|
}
|
|
|
|
|
2019-02-18 21:53:57 +08:00
|
|
|
func (f *Match) Adapter() string {
|
2018-06-10 22:50:03 +08:00
|
|
|
return f.adapter
|
|
|
|
}
|
|
|
|
|
2019-02-18 21:53:57 +08:00
|
|
|
func (f *Match) Payload() string {
|
2018-06-20 22:41:02 +08:00
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2022-03-13 01:21:23 +08:00
|
|
|
func NewMatch(adapter string) *Match {
|
2019-02-18 21:53:57 +08:00
|
|
|
return &Match{
|
2022-03-13 01:21:23 +08:00
|
|
|
Base: &Base{},
|
|
|
|
adapter: adapter,
|
2018-06-10 22:50:03 +08:00
|
|
|
}
|
|
|
|
}
|
2022-03-13 01:21:23 +08:00
|
|
|
|
feat: support sub-rule, eg.
rules:
- SUB-RULE,(AND,((NETWORK,TCP),(DOMAIN-KEYWORD,google))),TEST2
- SUB-RULE,(GEOIP,!CN),TEST1
- MATCH,DIRECT
sub-rules:
TEST2:
- MATCH,Proxy
TEST1:
- RULE-SET,Local,DIRECT,no-resolve
- GEOSITE,CN,Domestic
- GEOIP,CN,Domestic
- MATCH,Proxy
2022-09-06 17:30:35 +08:00
|
|
|
//var _ C.Rule = (*Match)(nil)
|