Skip to content

Commit

Permalink
feat: uid rule support for logic and rule-set
Browse files Browse the repository at this point in the history
  • Loading branch information
adlyq committed May 22, 2022
1 parent 948700e commit 79469fc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions rule/logic/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"net/http"
"os"
"regexp"
"runtime"
"strings"
)

Expand Down Expand Up @@ -104,6 +105,12 @@ func parseRule(tp, payload string, params []string) (C.Rule, error) {
case "RULE-SET":
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")
}
case "IN-TYPE":
parsed, parseErr = RC.NewInType(payload, "")
case "NOT":
Expand Down
7 changes: 7 additions & 0 deletions rule/provider/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
C "github.com/Dreamacro/clash/constant"
P "github.com/Dreamacro/clash/constant/provider"
RC "github.com/Dreamacro/clash/rule/common"
"runtime"
"time"
)

Expand Down Expand Up @@ -84,6 +85,12 @@ func parseRule(tp, payload, target string, params []string) (C.Rule, error) {
parsed, parseErr = RC.NewProcess(payload, target, false)
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")
}
case "IN-TYPE":
parsed, parseErr = RC.NewInType(payload, target)
default:
Expand Down

0 comments on commit 79469fc

Please sign in to comment.