Crazy sekai overturns the small pond

This commit is contained in:
世界
2024-10-21 23:38:34 +08:00
parent 253b41936e
commit 8304295c48
139 changed files with 2866 additions and 1559 deletions

View File

@@ -0,0 +1,43 @@
package rule
import (
"strings"
"github.com/sagernet/sing-box/adapter"
)
var _ RuleItem = (*ProcessPathItem)(nil)
type ProcessPathItem struct {
processes []string
processMap map[string]bool
}
func NewProcessPathItem(processNameList []string) *ProcessPathItem {
rule := &ProcessPathItem{
processes: processNameList,
processMap: make(map[string]bool),
}
for _, processName := range processNameList {
rule.processMap[processName] = true
}
return rule
}
func (r *ProcessPathItem) Match(metadata *adapter.InboundContext) bool {
if metadata.ProcessInfo == nil || metadata.ProcessInfo.ProcessPath == "" {
return false
}
return r.processMap[metadata.ProcessInfo.ProcessPath]
}
func (r *ProcessPathItem) String() string {
var description string
pLen := len(r.processes)
if pLen == 1 {
description = "process_path=" + r.processes[0]
} else {
description = "process_path=[" + strings.Join(r.processes, " ") + "]"
}
return description
}