splitrt

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package splitrt contains the split routing.

Index

Constants

This section is empty.

Variables

View Source
var (
	// RoutingTable is the routing table.
	RoutingTable = "42111"

	// RulePriority1 is the first routing rule priority. It must be unique,
	// higher than the local rule, lower than the main and default rules,
	// lower than the second routing rule priority.
	RulePriority1 = "2111"

	// RulePriority2 is the second routing rule priority. It must be unique,
	// higher than the local rule, lower than the main and default rules,
	// higher than the first routing rule priority.
	RulePriority2 = "2112"

	// FirewallMark is the firewall mark used for split routing.
	FirewallMark = RoutingTable
)

Functions

func Cleanup

func Cleanup(ctx context.Context, config *Config)

Cleanup cleans up old configuration after a failed shutdown.

Types

type Addresses

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

Addresses is a set of addresses.

func NewAddresses

func NewAddresses() *Addresses

NewAddresses returns new Addresses.

func (*Addresses) Add

func (a *Addresses) Add(addr *addrmon.Update)

Add adds address info in addr to addresses.

func (*Addresses) Get

func (a *Addresses) Get(index int) (addrs []*net.IPNet)

Get returns the addresses of the device identified by index.

func (*Addresses) Remove

func (a *Addresses) Remove(addr *addrmon.Update)

Remove removes address info in addr from addresses.

type Config added in v0.1.0

type Config struct {
	RoutingTable  string
	RulePriority1 string
	RulePriority2 string
	FirewallMark  string
}

Config is a split routing configuration.

func NewConfig added in v0.1.0

func NewConfig() *Config

NewConfig returns a new split routing configuration.

func (*Config) Valid added in v0.1.0

func (c *Config) Valid() bool

Valid returns whether the split routing configuration is valid.

type Devices

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

Devices is a set of devices.

func NewDevices

func NewDevices() *Devices

NewDevices returns new Devices.

func (*Devices) Add

func (d *Devices) Add(dev *devmon.Update)

Add adds device info in dev to devices.

func (*Devices) GetAll

func (d *Devices) GetAll() []int

GetAll returns all device indexes.

func (*Devices) GetReal

func (d *Devices) GetReal() []int

GetReal returns device indexes of all real devices.

func (*Devices) GetVirtual

func (d *Devices) GetVirtual() []int

GetVirtual returns device indexes of all virtual devices.

func (*Devices) Remove

func (d *Devices) Remove(dev *devmon.Update)

Remove removes device info in dev from devices.

type Excludes

type Excludes struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Excludes contains split Excludes.

func NewExcludes

func NewExcludes() *Excludes

NewExcludes returns new split excludes.

func (*Excludes) AddDynamic

func (e *Excludes) AddDynamic(ctx context.Context, address *net.IPNet, ttl uint32)

AddDynamic adds a dynamic entry to the split excludes.

func (*Excludes) AddStatic

func (e *Excludes) AddStatic(ctx context.Context, address *net.IPNet)

AddStatic adds a static entry to the split excludes.

func (*Excludes) RemoveStatic added in v1.0.0

func (e *Excludes) RemoveStatic(ctx context.Context, address *net.IPNet)

RemoveStatic removes a static entry from the split excludes.

func (*Excludes) Start

func (e *Excludes) Start()

Start starts periodic cleanup of the split excludes.

func (*Excludes) Stop

func (e *Excludes) Stop()

Stop stops periodic cleanup of the split excludes.

type SplitRouting

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

SplitRouting is a split routing configuration.

func NewSplitRouting

func NewSplitRouting(config *Config, vpnconfig *vpnconfig.Config) *SplitRouting

NewSplitRouting returns a new SplitRouting.

func (*SplitRouting) DNSReports

func (s *SplitRouting) DNSReports() chan *dnsproxy.Report

DNSReports returns the channel for dns reports.

func (*SplitRouting) Start

func (s *SplitRouting) Start() error

Start starts split routing.

func (*SplitRouting) Stop

func (s *SplitRouting) Stop()

Stop stops split routing.

Jump to

Keyboard shortcuts

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