mirror of
https://github.com/SagerNet/sing-box.git
synced 2026-05-13 13:57:05 +00:00
Match package_name in process_path rule on Android
This commit is contained in:
parent
0045103d14
commit
9ac1e2ff32
1 changed files with 13 additions and 2 deletions
|
|
@ -4,6 +4,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/sagernet/sing-box/adapter"
|
||||
C "github.com/sagernet/sing-box/constant"
|
||||
)
|
||||
|
||||
var _ RuleItem = (*ProcessPathItem)(nil)
|
||||
|
|
@ -25,10 +26,20 @@ func NewProcessPathItem(processNameList []string) *ProcessPathItem {
|
|||
}
|
||||
|
||||
func (r *ProcessPathItem) Match(metadata *adapter.InboundContext) bool {
|
||||
if metadata.ProcessInfo == nil || metadata.ProcessInfo.ProcessPath == "" {
|
||||
if metadata.ProcessInfo == nil {
|
||||
return false
|
||||
}
|
||||
return r.processMap[metadata.ProcessInfo.ProcessPath]
|
||||
if metadata.ProcessInfo.ProcessPath != "" && r.processMap[metadata.ProcessInfo.ProcessPath] {
|
||||
return true
|
||||
}
|
||||
if C.IsAndroid {
|
||||
for _, packageName := range metadata.ProcessInfo.AndroidPackageNames {
|
||||
if r.processMap[packageName] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (r *ProcessPathItem) String() string {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue