Match package_name in process_path rule on Android
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/sagernet/sing-box/adapter"
|
"github.com/sagernet/sing-box/adapter"
|
||||||
|
C "github.com/sagernet/sing-box/constant"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ RuleItem = (*ProcessPathItem)(nil)
|
var _ RuleItem = (*ProcessPathItem)(nil)
|
||||||
@@ -25,10 +26,20 @@ func NewProcessPathItem(processNameList []string) *ProcessPathItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *ProcessPathItem) Match(metadata *adapter.InboundContext) bool {
|
func (r *ProcessPathItem) Match(metadata *adapter.InboundContext) bool {
|
||||||
if metadata.ProcessInfo == nil || metadata.ProcessInfo.ProcessPath == "" {
|
if metadata.ProcessInfo == nil {
|
||||||
return false
|
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 {
|
func (r *ProcessPathItem) String() string {
|
||||||
|
|||||||
Reference in New Issue
Block a user