rule.go 606 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. UpdateGeosite() error
  14. Action() RuleAction
  15. }
  16. type DNSRule interface {
  17. Rule
  18. WithAddressLimit() bool
  19. MatchAddressLimit(metadata *InboundContext) bool
  20. }
  21. type RuleAction interface {
  22. Type() string
  23. String() string
  24. }
  25. func IsFinalAction(action RuleAction) bool {
  26. switch action.Type() {
  27. case C.RuleActionTypeSniff, C.RuleActionTypeResolve:
  28. return false
  29. default:
  30. return true
  31. }
  32. }