-
Notifications
You must be signed in to change notification settings - Fork 0
/
process.go
51 lines (40 loc) · 883 Bytes
/
process.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package common
import (
"strings"
C "github.com/devsolux/clash-meta/constant"
)
type Process struct {
*Base
adapter string
process string
nameOnly bool
}
func (ps *Process) RuleType() C.RuleType {
if ps.nameOnly {
return C.Process
}
return C.ProcessPath
}
func (ps *Process) Match(metadata *C.Metadata) (bool, string) {
if ps.nameOnly {
return strings.EqualFold(metadata.Process, ps.process), ps.adapter
}
return strings.EqualFold(metadata.ProcessPath, ps.process), ps.adapter
}
func (ps *Process) Adapter() string {
return ps.adapter
}
func (ps *Process) Payload() string {
return ps.process
}
func (ps *Process) ShouldFindProcess() bool {
return true
}
func NewProcess(process string, adapter string, nameOnly bool) (*Process, error) {
return &Process{
Base: &Base{},
adapter: adapter,
process: process,
nameOnly: nameOnly,
}, nil
}