Feature: process condition for rules
This commit is contained in:
@ -2,6 +2,7 @@ package constant
|
||||
|
||||
import (
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/Dreamacro/clash/component/geodata/router"
|
||||
)
|
||||
@ -9,8 +10,9 @@ import (
|
||||
var TunBroadcastAddr = net.IPv4(198, 18, 255, 255)
|
||||
|
||||
type RuleExtra struct {
|
||||
Network NetWork
|
||||
SourceIPs []*net.IPNet
|
||||
Network NetWork
|
||||
SourceIPs []*net.IPNet
|
||||
ProcessNames []string
|
||||
}
|
||||
|
||||
func (re *RuleExtra) NotMatchNetwork(network NetWork) bool {
|
||||
@ -30,6 +32,19 @@ func (re *RuleExtra) NotMatchSourceIP(srcIP net.IP) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (re *RuleExtra) NotMatchProcessName(processName string) bool {
|
||||
if re.ProcessNames == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, pn := range re.ProcessNames {
|
||||
if strings.EqualFold(pn, processName) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
type RuleGeoSite interface {
|
||||
GetDomainMatcher() *router.DomainMatcher
|
||||
}
|
||||
|
Reference in New Issue
Block a user