github.com/yaling888/clash@v1.53.0/constant/rule_extra.go (about) 1 package constant 2 3 import ( 4 "net/netip" 5 "strings" 6 ) 7 8 type RuleExtra struct { 9 Network NetWork 10 SourceIPs []*netip.Prefix 11 ProcessNames []string 12 } 13 14 func (re *RuleExtra) NotMatchNetwork(network NetWork) bool { 15 return re.Network != ALLNet && re.Network != network 16 } 17 18 func (re *RuleExtra) NotMatchSourceIP(srcIP netip.Addr) bool { 19 if re.SourceIPs == nil { 20 return false 21 } 22 23 for _, ips := range re.SourceIPs { 24 if ips.Contains(srcIP) { 25 return false 26 } 27 } 28 return true 29 } 30 31 func (re *RuleExtra) NotMatchProcessName(processName string) bool { 32 if re.ProcessNames == nil { 33 return false 34 } 35 36 for _, pn := range re.ProcessNames { 37 if strings.EqualFold(pn, processName) { 38 return false 39 } 40 } 41 return true 42 }