clash/constant/rule.go

50 lines
703 B
Go
Raw Normal View History

2018-06-10 14:50:03 +00:00
package constant
// Rule Type
const (
2018-09-09 07:01:46 +00:00
Domain RuleType = iota
DomainSuffix
2018-06-10 14:50:03 +00:00
DomainKeyword
GEOIP
IPCIDR
2019-05-09 13:00:29 +00:00
SrcIPCIDR
SrcPort
DstPort
2019-02-18 13:53:57 +00:00
MATCH
2018-06-10 14:50:03 +00:00
)
type RuleType int
2018-06-20 14:41:02 +00:00
func (rt RuleType) String() string {
switch rt {
2018-09-09 07:01:46 +00:00
case Domain:
return "Domain"
2018-06-20 14:41:02 +00:00
case DomainSuffix:
return "DomainSuffix"
case DomainKeyword:
return "DomainKeyword"
case GEOIP:
return "GeoIP"
2018-06-20 14:41:02 +00:00
case IPCIDR:
return "IPCIDR"
2019-05-09 13:00:29 +00:00
case SrcIPCIDR:
return "SrcIPCIDR"
case SrcPort:
return "SrcPort"
case DstPort:
return "DstPort"
2019-02-18 13:53:57 +00:00
case MATCH:
return "Match"
2018-06-20 14:41:02 +00:00
default:
2019-08-26 04:26:14 +00:00
return "Unknown"
2018-06-20 14:41:02 +00:00
}
}
2018-06-10 14:50:03 +00:00
type Rule interface {
RuleType() RuleType
Match(metadata *Metadata) bool
2018-06-10 14:50:03 +00:00
Adapter() string
2018-06-20 14:41:02 +00:00
Payload() string
NoResolveIP() bool
2018-06-10 14:50:03 +00:00
}