clash/constant/rule.go
2020-07-27 11:57:55 +08:00

53 lines
750 B
Go

package constant
// Rule Type
const (
Domain RuleType = iota
DomainSuffix
DomainKeyword
GEOIP
IPCIDR
SrcIPCIDR
SrcPort
DstPort
Process
MATCH
)
type RuleType int
func (rt RuleType) String() string {
switch rt {
case Domain:
return "Domain"
case DomainSuffix:
return "DomainSuffix"
case DomainKeyword:
return "DomainKeyword"
case GEOIP:
return "GeoIP"
case IPCIDR:
return "IPCIDR"
case SrcIPCIDR:
return "SrcIPCIDR"
case SrcPort:
return "SrcPort"
case DstPort:
return "DstPort"
case Process:
return "Process"
case MATCH:
return "Match"
default:
return "Unknown"
}
}
type Rule interface {
RuleType() RuleType
Match(metadata *Metadata) bool
Adapter() string
Payload() string
ShouldResolveIP() bool
}