mirror of
https://github.com/SagerNet/sing-box.git
synced 2026-04-11 17:47:20 +10:00
41 lines
708 B
Go
41 lines
708 B
Go
package adapter
|
|
|
|
import (
|
|
C "github.com/sagernet/sing-box/constant"
|
|
|
|
"github.com/miekg/dns"
|
|
)
|
|
|
|
type HeadlessRule interface {
|
|
Match(metadata *InboundContext) bool
|
|
String() string
|
|
}
|
|
|
|
type Rule interface {
|
|
HeadlessRule
|
|
SimpleLifecycle
|
|
Type() string
|
|
Action() RuleAction
|
|
}
|
|
|
|
type DNSRule interface {
|
|
Rule
|
|
LegacyPreMatch(metadata *InboundContext) bool
|
|
WithAddressLimit() bool
|
|
MatchAddressLimit(metadata *InboundContext, response *dns.Msg) bool
|
|
}
|
|
|
|
type RuleAction interface {
|
|
Type() string
|
|
String() string
|
|
}
|
|
|
|
func IsFinalAction(action RuleAction) bool {
|
|
switch action.Type() {
|
|
case C.RuleActionTypeSniff, C.RuleActionTypeResolve, C.RuleActionTypeEvaluate:
|
|
return false
|
|
default:
|
|
return true
|
|
}
|
|
}
|