rule_engine

package
v1.33.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2026 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BuiltInProxyRule, _  = newBuiltIn("*", constants.PolicyProxy)
	BuiltInRejectRule, _ = newBuiltIn("*", constants.PolicyReject)
)
View Source
var ErrNotFound = errors.New("not found")

Functions

func GetRuleIds

func GetRuleIds() ([]string, error)

Types

type DnsMap added in v1.32.2

type DnsMap struct {
	RuleType constants.RuleType `json:"ruleType"`
	Payload  string             `json:"payload"`

	Policy constants.Policy `json:"policy"`
	// contains filtered or unexported fields
}

func NewDnsMapRule added in v1.32.2

func NewDnsMapRule(payload string, policy constants.Policy) (*DnsMap, error)

func (DnsMap) ExchangeContext added in v1.32.2

func (d DnsMap) ExchangeContext(_ context.Context, r *D.Msg) (*D.Msg, error)

func (DnsMap) GetIp added in v1.32.2

func (d DnsMap) GetIp() (net.IP, error)

func (DnsMap) GetPolicy added in v1.32.2

func (d DnsMap) GetPolicy() constants.Policy

func (DnsMap) Match added in v1.32.2

func (d DnsMap) Match(value string) bool

func (DnsMap) Type added in v1.32.2

func (d DnsMap) Type() constants.RuleType

func (DnsMap) Valid added in v1.32.2

func (d DnsMap) Valid() bool

func (DnsMap) Value added in v1.32.2

func (d DnsMap) Value() string

type Domain

type Domain struct {
	RuleType constants.RuleType `json:"ruleType"`
	Payload  string             `json:"payload"`
	Policy   constants.Policy   `json:"policy"`
}

func NewDomainRule

func NewDomainRule(ruleType constants.RuleType, payload string, policy constants.Policy) (*Domain, error)

func (Domain) GetPolicy

func (d Domain) GetPolicy() constants.Policy

func (Domain) Match

func (d Domain) Match(value string) bool

func (Domain) Type

func (d Domain) Type() constants.RuleType

func (Domain) Valid

func (d Domain) Valid() bool

func (Domain) Value

func (d Domain) Value() string

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

func New

func New(name string, extraRules []string) (*Engine, error)

func (*Engine) AddCache

func (e *Engine) AddCache(value string, rule Rule)

func (*Engine) Match

func (e *Engine) Match(value string, types []constants.RuleType) (Rule, error)

type IpCidr

type IpCidr struct {
	RuleType constants.RuleType `json:"ruleType"`
	Payload  string             `json:"payload"`

	Policy constants.Policy `json:"policy"`
	// contains filtered or unexported fields
}

func NewIpCidrRule

func NewIpCidrRule(payload string, policy constants.Policy) (*IpCidr, error)

func (IpCidr) GetPolicy

func (i IpCidr) GetPolicy() constants.Policy

func (IpCidr) Match

func (i IpCidr) Match(value string) bool

func (IpCidr) Type

func (i IpCidr) Type() constants.RuleType

func (IpCidr) Valid

func (i IpCidr) Valid() bool

func (IpCidr) Value

func (i IpCidr) Value() string

type Process

type Process struct {
	RuleType constants.RuleType `json:"ruleType"`
	Payload  string             `json:"payload"`
	Policy   constants.Policy   `json:"policy"`
}

func NewProcessRule

func NewProcessRule(ruleType constants.RuleType, payload string, policy constants.Policy) (*Process, error)

func (Process) GetPolicy

func (p Process) GetPolicy() constants.Policy

func (Process) Match

func (p Process) Match(value string) bool

func (Process) Type

func (p Process) Type() constants.RuleType

func (Process) Valid

func (p Process) Valid() bool

func (Process) Value

func (p Process) Value() string

type Rule

type Rule interface {
	Match(value string) bool
	Value() string
	GetPolicy() constants.Policy
	Type() constants.RuleType
	Valid() bool
}

func Parse

func Parse(name string, extraRules []string) ([]Rule, error)

func ParseItem

func ParseItem(rawRuleType, value, rawPolicy string) (Rule, error)

func ParseRawValue

func ParseRawValue(line string) (Rule, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL