rule.go 708 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package adapter
  2. import (
  3. C "github.com/sagernet/sing-box/constant"
  4. "github.com/miekg/dns"
  5. )
  6. type HeadlessRule interface {
  7. Match(metadata *InboundContext) bool
  8. String() string
  9. }
  10. type Rule interface {
  11. HeadlessRule
  12. SimpleLifecycle
  13. Type() string
  14. Action() RuleAction
  15. }
  16. type DNSRule interface {
  17. Rule
  18. LegacyPreMatch(metadata *InboundContext) bool
  19. WithAddressLimit() bool
  20. MatchAddressLimit(metadata *InboundContext, response *dns.Msg) bool
  21. }
  22. type RuleAction interface {
  23. Type() string
  24. String() string
  25. }
  26. func IsFinalAction(action RuleAction) bool {
  27. switch action.Type() {
  28. case C.RuleActionTypeSniff, C.RuleActionTypeResolve, C.RuleActionTypeEvaluate:
  29. return false
  30. default:
  31. return true
  32. }
  33. }