mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-08-22 02:08:44 +00:00
chore: 调整uid系统判断位置
This commit is contained in:
parent
067c02aba1
commit
c7355510a2
4 changed files with 8 additions and 18 deletions
|
@ -1,10 +1,12 @@
|
||||||
package common
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"github.com/Dreamacro/clash/common/utils"
|
"github.com/Dreamacro/clash/common/utils"
|
||||||
"github.com/Dreamacro/clash/component/process"
|
"github.com/Dreamacro/clash/component/process"
|
||||||
C "github.com/Dreamacro/clash/constant"
|
C "github.com/Dreamacro/clash/constant"
|
||||||
"github.com/Dreamacro/clash/log"
|
"github.com/Dreamacro/clash/log"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
@ -20,6 +22,9 @@ func NewUid(oUid, adapter string) (*Uid, error) {
|
||||||
//if len(_uids) > 28 {
|
//if len(_uids) > 28 {
|
||||||
// return nil, fmt.Errorf("%s, too many uid to use, maximum support 28 uid", errPayload.Error())
|
// 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]
|
var uidRange []utils.Range[int32]
|
||||||
for _, u := range strings.Split(oUid, "/") {
|
for _, u := range strings.Split(oUid, "/") {
|
||||||
|
|
|
@ -11,7 +11,6 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -106,11 +105,7 @@ func parseRule(tp, payload string, params []string) (C.Rule, error) {
|
||||||
noResolve := RC.HasNoResolve(params)
|
noResolve := RC.HasNoResolve(params)
|
||||||
parsed, parseErr = provider.NewRuleSet(payload, "", noResolve)
|
parsed, parseErr = provider.NewRuleSet(payload, "", noResolve)
|
||||||
case "UID":
|
case "UID":
|
||||||
if runtime.GOOS == "linux" || runtime.GOOS == "android" {
|
|
||||||
parsed, parseErr = RC.NewUid(payload, "")
|
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":
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
RC "github.com/Dreamacro/clash/rule/common"
|
RC "github.com/Dreamacro/clash/rule/common"
|
||||||
"github.com/Dreamacro/clash/rule/logic"
|
"github.com/Dreamacro/clash/rule/logic"
|
||||||
RP "github.com/Dreamacro/clash/rule/provider"
|
RP "github.com/Dreamacro/clash/rule/provider"
|
||||||
"runtime"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func ParseRule(tp, payload, target string, params []string) (C.Rule, error) {
|
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":
|
case "NETWORK":
|
||||||
parsed, parseErr = RC.NewNetworkType(payload, target)
|
parsed, parseErr = RC.NewNetworkType(payload, target)
|
||||||
case "UID":
|
case "UID":
|
||||||
if runtime.GOOS == "linux" || runtime.GOOS == "android" {
|
|
||||||
parsed, parseErr = RC.NewUid(payload, target)
|
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)
|
||||||
case "AND":
|
case "AND":
|
||||||
|
|
|
@ -7,7 +7,6 @@ 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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -86,11 +85,7 @@ func parseRule(tp, payload, target string, params []string) (C.Rule, error) {
|
||||||
case "NETWORK":
|
case "NETWORK":
|
||||||
parsed, parseErr = RC.NewNetworkType(payload, target)
|
parsed, parseErr = RC.NewNetworkType(payload, target)
|
||||||
case "UID":
|
case "UID":
|
||||||
if runtime.GOOS == "linux" || runtime.GOOS == "android" {
|
|
||||||
parsed, parseErr = RC.NewUid(payload, target)
|
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:
|
||||||
|
|
Loading…
Reference in a new issue