rule.go 583 B

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