feat: support uid rule

eg. UID,1000/5000-6000,Proxy
This commit is contained in:
adlyq
2022-04-22 16:27:51 +08:00
parent 0cb5270452
commit 3d6aea4c1e
6 changed files with 106 additions and 6 deletions

View File

@@ -2,12 +2,11 @@ package process
import (
"errors"
"github.com/Dreamacro/clash/common/nnip"
C "github.com/Dreamacro/clash/constant"
"net"
"net/netip"
"runtime"
"github.com/Dreamacro/clash/common/nnip"
C "github.com/Dreamacro/clash/constant"
)
var (
@@ -25,6 +24,14 @@ func FindProcessName(network string, srcIP netip.Addr, srcPort int) (string, err
return findProcessName(network, srcIP, srcPort)
}
func FindUid(network string, srcIP netip.Addr, srcPort int) (int32, error) {
_, uid, err := resolveSocketByNetlink(network, srcIP, srcPort)
if err != nil {
return -1, err
}
return uid, nil
}
func ShouldFindProcess(metadata *C.Metadata) bool {
if runtime.GOOS == "android" {
return false