2022-01-22 22:10:45 +08:00
|
|
|
package common
|
2019-10-28 00:02:23 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
2024-08-29 23:49:16 +08:00
|
|
|
|
|
|
|
"golang.org/x/exp/slices"
|
2019-10-28 00:02:23 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
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
|
|
|
errPayload = errors.New("payloadRule error")
|
2024-08-30 00:04:28 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
// params
|
|
|
|
var (
|
|
|
|
NoResolve = "no-resolve"
|
|
|
|
Src = "src"
|
2019-10-28 00:02:23 +08:00
|
|
|
)
|
|
|
|
|
2022-03-13 01:21:23 +08:00
|
|
|
type Base struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *Base) ShouldFindProcess() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2022-03-17 23:24:07 +08:00
|
|
|
func (b *Base) ShouldResolveIP() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2024-06-17 22:04:51 +08:00
|
|
|
func (b *Base) ProviderNames() []string { return nil }
|
|
|
|
|
2024-08-30 00:04:28 +08:00
|
|
|
func ParseParams(params []string) (isSrc bool, noResolve bool) {
|
|
|
|
isSrc = slices.Contains(params, Src)
|
|
|
|
if isSrc {
|
|
|
|
noResolve = true
|
|
|
|
} else {
|
|
|
|
noResolve = slices.Contains(params, NoResolve)
|
|
|
|
}
|
|
|
|
return
|
2019-10-28 00:02:23 +08:00
|
|
|
}
|