rule

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HigherPriority

func HigherPriority(a, b *config.Rule) *config.Rule

HigherPriority returns whichever rule has the higher Priority field. nil is treated as lower than any non-nil rule.

Types

type MatchType

type MatchType int

MatchType identifies whether a Query targets a domain or an IP address.

const (
	MatchTypeDomain MatchType = iota
	MatchTypeAddr
)

type Query

type Query struct {
	Type  MatchType
	Value string
}

Query is a lookup key passed to RuleSet.Search.

type RuleSet

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

RuleSet stores routing rules and resolves them by domain or CIDR.

Domain rules use specificity-based matching (exact > * > **). CIDR rules use longest-prefix matching. Priority resolves conflicts at Add time and breaks ties when both a domain and a CIDR rule match the same request.

func NewRuleSet

func NewRuleSet() *RuleSet

func (*RuleSet) Add

func (rs *RuleSet) Add(r *config.Rule) error

func (*RuleSet) Search

func (rs *RuleSet) Search(queries []Query) *config.Rule

Search returns the best matching rule for the given queries. When both a domain and a CIDR rule match, the higher-priority rule wins. The returned rule is a clone; nil is returned when nothing matches.

Jump to

Keyboard shortcuts

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