mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
chore: clean up code
This commit is contained in:
parent
179bc6ecdf
commit
947d9d4560
|
@ -370,9 +370,6 @@ func match(metadata *C.Metadata) (C.Proxy, C.Rule, error) {
|
|||
resolved = true
|
||||
}
|
||||
|
||||
var processUid int32
|
||||
process := ""
|
||||
processPath := ""
|
||||
foundProcess := false
|
||||
for _, rule := range rules {
|
||||
if !resolved && shouldResolveIP(rule, metadata) {
|
||||
|
@ -392,19 +389,13 @@ func match(metadata *C.Metadata) (C.Proxy, C.Rule, error) {
|
|||
if err != nil {
|
||||
log.Debugln("[Process] find process %s: %v", metadata.String(), err)
|
||||
} else {
|
||||
process = filepath.Base(path)
|
||||
processPath = path
|
||||
processUid = uid
|
||||
metadata.Process = filepath.Base(path)
|
||||
metadata.ProcessPath = path
|
||||
metadata.Uid = &uid
|
||||
foundProcess = true
|
||||
}
|
||||
}
|
||||
|
||||
if foundProcess {
|
||||
metadata.Uid = &processUid
|
||||
metadata.Process = process
|
||||
metadata.ProcessPath = processPath
|
||||
}
|
||||
|
||||
if rule.Match(metadata) {
|
||||
adapter, ok := proxies[rule.Adapter()]
|
||||
if !ok {
|
||||
|
@ -421,21 +412,6 @@ func match(metadata *C.Metadata) (C.Proxy, C.Rule, error) {
|
|||
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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user