From 1faa1729440249de77d920c5d38eacd6d2983d78 Mon Sep 17 00:00:00 2001 From: Skyxim Date: Sun, 29 May 2022 18:12:43 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E8=B0=83=E6=95=B4uid=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E5=88=A4=E6=96=AD=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rule/common/uid.go | 5 +++++ rule/logic/common.go | 7 +------ rule/parser.go | 7 +------ rule/provider/parse.go | 7 +------ 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/rule/common/uid.go b/rule/common/uid.go index 00f0c3d8..d5321581 100644 --- a/rule/common/uid.go +++ b/rule/common/uid.go @@ -1,10 +1,12 @@ package common import ( + "fmt" "github.com/Dreamacro/clash/common/utils" "github.com/Dreamacro/clash/component/process" C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/log" + "runtime" "strconv" "strings" ) @@ -20,6 +22,9 @@ func NewUid(oUid, adapter string) (*Uid, error) { //if len(_uids) > 28 { // return nil, fmt.Errorf("%s, too many uid to use, maximum support 28 uid", errPayload.Error()) //} + if !(runtime.GOOS == "linux" || runtime.GOOS == "android") { + return nil, fmt.Errorf("uid rule not support this platform") + } var uidRange []utils.Range[int32] for _, u := range strings.Split(oUid, "/") { diff --git a/rule/logic/common.go b/rule/logic/common.go index 18bdddf8..4272b943 100644 --- a/rule/logic/common.go +++ b/rule/logic/common.go @@ -11,7 +11,6 @@ import ( "net/http" "os" "regexp" - "runtime" "strings" ) @@ -106,11 +105,7 @@ func parseRule(tp, payload string, params []string) (C.Rule, error) { noResolve := RC.HasNoResolve(params) 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") - } + parsed, parseErr = RC.NewUid(payload, "") case "IN-TYPE": parsed, parseErr = RC.NewInType(payload, "") case "NOT": diff --git a/rule/parser.go b/rule/parser.go index e82e3fda..660f1575 100644 --- a/rule/parser.go +++ b/rule/parser.go @@ -6,7 +6,6 @@ import ( RC "github.com/Dreamacro/clash/rule/common" "github.com/Dreamacro/clash/rule/logic" RP "github.com/Dreamacro/clash/rule/provider" - "runtime" ) func ParseRule(tp, payload, target string, params []string) (C.Rule, error) { @@ -43,11 +42,7 @@ func ParseRule(tp, payload, target string, params []string) (C.Rule, error) { case "NETWORK": 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") - } + parsed, parseErr = RC.NewUid(payload, target) case "IN-TYPE": parsed, parseErr = RC.NewInType(payload, target) case "AND": diff --git a/rule/provider/parse.go b/rule/provider/parse.go index f1604d46..ae53203b 100644 --- a/rule/provider/parse.go +++ b/rule/provider/parse.go @@ -7,7 +7,6 @@ import ( C "github.com/Dreamacro/clash/constant" P "github.com/Dreamacro/clash/constant/provider" RC "github.com/Dreamacro/clash/rule/common" - "runtime" "time" ) @@ -86,11 +85,7 @@ func parseRule(tp, payload, target string, params []string) (C.Rule, error) { case "NETWORK": 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") - } + parsed, parseErr = RC.NewUid(payload, target) case "IN-TYPE": parsed, parseErr = RC.NewInType(payload, target) default: