acl

package
v0.0.0-...-0cae4bf Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompilationError

type CompilationError struct {
	LineNum int
	Message string
}

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 GeoLoader

type GeoLoader interface {
	LoadGeoIP() (map[string]*v2geo.GeoIP, error)
	LoadGeoSite() (map[string]*v2geo.GeoSite, error)
}

type HostInfo

type HostInfo struct {
	Name string
	IPv4 net.IP
	IPv6 net.IP
}

func (HostInfo) String

func (h HostInfo) String() string

type InvalidSyntaxError

type InvalidSyntaxError struct {
	Line    string
	LineNum int
}

func (*InvalidSyntaxError) Error

func (e *InvalidSyntaxError) Error() string

type Outbound

type Outbound interface {
	any
}

type Protocol

type Protocol int
const (
	ProtocolBoth Protocol = iota
	ProtocolTCP
	ProtocolUDP
)

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.

func ParseTextRules

func ParseTextRules(text string) ([]TextRule, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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