feat: uid rule support for logic and rule-set

This commit is contained in:
adlyq 2022-05-22 13:07:07 +08:00
parent 948700eed6
commit 79469fc8d6
2 changed files with 14 additions and 0 deletions

View file

@ -11,6 +11,7 @@ import (
"net/http" "net/http"
"os" "os"
"regexp" "regexp"
"runtime"
"strings" "strings"
) )
@ -104,6 +105,12 @@ func parseRule(tp, payload string, params []string) (C.Rule, error) {
case "RULE-SET": case "RULE-SET":
noResolve := RC.HasNoResolve(params) noResolve := RC.HasNoResolve(params)
parsed, parseErr = provider.NewRuleSet(payload, "", noResolve) parsed, parseErr = provider.NewRuleSet(payload, "", noResolve)
case "UID":
if runtime.GOOS == "linux" || runtime.GOOS == "android" {
parsed, parseErr = RC.NewUid(payload, "")
} else {
parseErr = fmt.Errorf("uid rule not support this platform")
}
case "IN-TYPE": case "IN-TYPE":
parsed, parseErr = RC.NewInType(payload, "") parsed, parseErr = RC.NewInType(payload, "")
case "NOT": case "NOT":

View file

@ -7,6 +7,7 @@ import (
C "github.com/Dreamacro/clash/constant" C "github.com/Dreamacro/clash/constant"
P "github.com/Dreamacro/clash/constant/provider" P "github.com/Dreamacro/clash/constant/provider"
RC "github.com/Dreamacro/clash/rule/common" RC "github.com/Dreamacro/clash/rule/common"
"runtime"
"time" "time"
) )
@ -84,6 +85,12 @@ func parseRule(tp, payload, target string, params []string) (C.Rule, error) {
parsed, parseErr = RC.NewProcess(payload, target, false) parsed, parseErr = RC.NewProcess(payload, target, false)
case "NETWORK": case "NETWORK":
parsed, parseErr = RC.NewNetworkType(payload, target) parsed, parseErr = RC.NewNetworkType(payload, target)
case "UID":
if runtime.GOOS == "linux" || runtime.GOOS == "android" {
parsed, parseErr = RC.NewUid(payload, target)
} else {
parseErr = fmt.Errorf("uid rule not support this platform")
}
case "IN-TYPE": case "IN-TYPE":
parsed, parseErr = RC.NewInType(payload, target) parsed, parseErr = RC.NewInType(payload, target)
default: default: