mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-01-09 10:49:35 +08:00
chore: clean up code
This commit is contained in:
parent
82107630ee
commit
0c913db308
@ -370,9 +370,6 @@ func match(metadata *C.Metadata) (C.Proxy, C.Rule, error) {
|
|||||||
resolved = true
|
resolved = true
|
||||||
}
|
}
|
||||||
|
|
||||||
var processUid int32
|
|
||||||
process := ""
|
|
||||||
processPath := ""
|
|
||||||
foundProcess := false
|
foundProcess := false
|
||||||
for _, rule := range rules {
|
for _, rule := range rules {
|
||||||
if !resolved && shouldResolveIP(rule, metadata) {
|
if !resolved && shouldResolveIP(rule, metadata) {
|
||||||
@ -392,19 +389,13 @@ func match(metadata *C.Metadata) (C.Proxy, C.Rule, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debugln("[Process] find process %s: %v", metadata.String(), err)
|
log.Debugln("[Process] find process %s: %v", metadata.String(), err)
|
||||||
} else {
|
} else {
|
||||||
process = filepath.Base(path)
|
metadata.Process = filepath.Base(path)
|
||||||
processPath = path
|
metadata.ProcessPath = path
|
||||||
processUid = uid
|
metadata.Uid = &uid
|
||||||
foundProcess = true
|
foundProcess = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if foundProcess {
|
|
||||||
metadata.Uid = &processUid
|
|
||||||
metadata.Process = process
|
|
||||||
metadata.ProcessPath = processPath
|
|
||||||
}
|
|
||||||
|
|
||||||
if rule.Match(metadata) {
|
if rule.Match(metadata) {
|
||||||
adapter, ok := proxies[rule.Adapter()]
|
adapter, ok := proxies[rule.Adapter()]
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -421,21 +412,6 @@ func match(metadata *C.Metadata) (C.Proxy, C.Rule, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
extra := rule.RuleExtra()
|
|
||||||
if extra != nil {
|
|
||||||
if extra.NotMatchNetwork(metadata.NetWork) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if extra.NotMatchSourceIP(metadata.SrcIP) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if extra.NotMatchProcessName(metadata.Process) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return adapter, rule, nil
|
return adapter, rule, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user