Feature: process condition for rules

This commit is contained in:
yaling888
2022-01-28 22:52:35 +08:00
parent d633e3d96e
commit 25e115d042
5 changed files with 46 additions and 7 deletions

View File

@ -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
}