mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2024-11-15 13:41:23 +08:00
9b89ff9f2d
rules: - SUB-RULE,(AND,((NETWORK,TCP),(DOMAIN-KEYWORD,google))),TEST2 - SUB-RULE,(GEOIP,!CN),TEST1 - MATCH,DIRECT sub-rules: TEST2: - MATCH,Proxy TEST1: - RULE-SET,Local,DIRECT,no-resolve - GEOSITE,CN,Domestic - GEOIP,CN,Domestic - MATCH,Proxy
48 lines
834 B
Go
48 lines
834 B
Go
package common
|
|
|
|
import (
|
|
"strings"
|
|
|
|
C "github.com/Dreamacro/clash/constant"
|
|
)
|
|
|
|
type Process struct {
|
|
*Base
|
|
adapter string
|
|
process string
|
|
nameOnly bool
|
|
}
|
|
|
|
func (ps *Process) RuleType() C.RuleType {
|
|
return C.Process
|
|
}
|
|
|
|
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
|
|
}
|