feat: GEOIP,IP-ASN,IP-CIDR,IP-CIDR6 and IP-SUFFIX in rules support ,src option

keep the same writing style as `RULE-SET`
This commit is contained in:
wwqgtxx
2024-08-30 00:04:28 +08:00
parent 763a127287
commit 38fd37108b
2 changed files with 23 additions and 21 deletions

View File

@@ -8,8 +8,12 @@ import (
var (
errPayload = errors.New("payloadRule error")
noResolve = "no-resolve"
src = "src"
)
// params
var (
NoResolve = "no-resolve"
Src = "src"
)
type Base struct {
@@ -25,10 +29,12 @@ func (b *Base) ShouldResolveIP() bool {
func (b *Base) ProviderNames() []string { return nil }
func HasNoResolve(params []string) bool {
return slices.Contains(params, noResolve)
}
func HasSrc(params []string) bool {
return slices.Contains(params, src)
func ParseParams(params []string) (isSrc bool, noResolve bool) {
isSrc = slices.Contains(params, Src)
if isSrc {
noResolve = true
} else {
noResolve = slices.Contains(params, NoResolve)
}
return
}