mihomo/constant/rule.go

64 lines
923 B
Go
Raw Normal View History

2018-06-10 22:50:03 +08:00
package constant
2021-10-15 14:11:14 +08:00
import "net"
2018-06-10 22:50:03 +08:00
// Rule Type
const (
2018-09-09 15:01:46 +08:00
Domain RuleType = iota
DomainSuffix
2018-06-10 22:50:03 +08:00
DomainKeyword
2021-07-01 22:49:29 +08:00
GEOSITE
2018-06-10 22:50:03 +08:00
GEOIP
IPCIDR
2019-05-09 21:00:29 +08:00
SrcIPCIDR
SrcPort
DstPort
2020-07-19 13:17:05 +08:00
Process
2021-10-15 14:11:14 +08:00
Script
2019-02-18 21:53:57 +08:00
MATCH
2018-06-10 22:50:03 +08:00
)
type RuleType int
2018-06-20 22:41:02 +08:00
func (rt RuleType) String() string {
switch rt {
2018-09-09 15:01:46 +08:00
case Domain:
return "Domain"
2018-06-20 22:41:02 +08:00
case DomainSuffix:
return "DomainSuffix"
case DomainKeyword:
return "DomainKeyword"
2021-07-01 22:49:29 +08:00
case GEOSITE:
return "GeoSite"
2018-06-20 22:41:02 +08:00
case GEOIP:
return "GeoIP"
2018-06-20 22:41:02 +08:00
case IPCIDR:
return "IPCIDR"
2019-05-09 21:00:29 +08:00
case SrcIPCIDR:
return "SrcIPCIDR"
case SrcPort:
return "SrcPort"
case DstPort:
return "DstPort"
2020-07-19 13:17:05 +08:00
case Process:
return "Process"
2021-10-15 14:11:14 +08:00
case Script:
return "Script"
2019-02-18 21:53:57 +08:00
case MATCH:
return "Match"
2018-06-20 22:41:02 +08:00
default:
2019-08-26 12:26:14 +08:00
return "Unknown"
2018-06-20 22:41:02 +08:00
}
}
2018-06-10 22:50:03 +08:00
type Rule interface {
RuleType() RuleType
Match(metadata *Metadata) bool
2018-06-10 22:50:03 +08:00
Adapter() string
2018-06-20 22:41:02 +08:00
Payload() string
ShouldResolveIP() bool
RuleExtra() *RuleExtra
2018-06-10 22:50:03 +08:00
}
2021-10-15 14:11:14 +08:00
var TunBroadcastAddr = net.IPv4(198, 18, 255, 255)