router

package
v1.8.1-1 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RouteServerDefault = &Route{
		Destination: EgressDirect,
		MatchType:   TypeDefault,
	}
	RouteDefault = &Route{
		Destination: EgressProxy,
		MatchType:   TypeDefault,
	}
	RouteBlockIPv6 = &Route{
		Sources: []string{
			"::/0",
		},
		Destination: EgressBlock,
		MatchType:   TypeCIDR,
	}
)

Functions

func AddToFirstRoute

func AddToFirstRoute(r *Route)

func AddToLastRoute

func AddToLastRoute(r *Route)

func GenerateCache

func GenerateCache() error

func GetRoute

func GetRoute(dst string) (transport.Transport, error)

func SetRoutes

func SetRoutes(r Routes)

Types

type Egress

type Egress string
const (
	EgressDirect    Egress = "direct"
	EgressProxy     Egress = "proxy"
	EgressForward   Egress = "forward"
	EgressBlock     Egress = "block"
	EgressBlackHole Egress = "blackhole"
)

func (Egress) GetTransport

func (e Egress) GetTransport() (transport.Transport, error)

type MatchCache

type MatchCache struct {
	RegexS []*regexp.Regexp
	CIDRs  []*net.IPNet
}

type Route

type Route struct {
	Sources     []string `json:"src"`
	Ext         string   `json:"path,omitempty"`
	Destination Egress   `json:"dst"`
	MatchType   Type     `json:"type"`
	// contains filtered or unexported fields
}

func (*Route) GenerateCache

func (r *Route) GenerateCache() error

func (*Route) Match

func (r *Route) Match(dst string) bool

type Routes

type Routes []*Route

func (Routes) GenerateCache

func (r Routes) GenerateCache() error

func (Routes) GetRoute

func (r Routes) GetRoute(dst string) (transport.Transport, error)

type RoutesTable

type RoutesTable map[string]Egress

type Type

type Type string
const (
	TypeExact   Type = "exact"
	TypeDomain  Type = "domain"
	TypeCIDR    Type = "cidr"
	TypeRegex   Type = "regex"
	TypeDefault Type = "default"
)

Jump to

Keyboard shortcuts

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