Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompilationError ¶
func (*CompilationError) Error ¶
func (e *CompilationError) Error() string
type CompiledRuleSet ¶
type CompiledRuleSet[O Outbound] interface { Match(host HostInfo, proto Protocol, port uint16) (O, net.IP) }
func Compile ¶
func Compile[O Outbound](rules []TextRule, outbounds map[string]O, cacheSize int, geoLoader GeoLoader, ) (CompiledRuleSet[O], error)
Compile compiles TextRules into a CompiledRuleSet. Names in the outbounds map MUST be in all lower case. geoipFunc is a function that returns the GeoIP database needed by the GeoIP matcher. It will be called every time a GeoIP matcher is used during compilation, but won't be called if there is no GeoIP rule. We use a function here so that database loading is on-demand (only required if used by rules).
type InvalidSyntaxError ¶
func (*InvalidSyntaxError) Error ¶
func (e *InvalidSyntaxError) Error() string
type TextRule ¶
type TextRule struct { Outbound string Address string ProtoPort string HijackAddress string LineNum int }
TextRule is the struct representation of a (non-comment) line parsed from an ACL file. A line can be parsed into a TextRule as long as it matches one of the following patterns:
outbound(address) outbound(address,protoPort) outbound(address,protoPort,hijackAddress)
It does not check whether any of the fields is valid - it's up to the compiler to do so.