route

package
v0.0.0-...-a9387a1 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package route handle route table for darwin/linux.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRouteItemNotFound = logex.Define("route item '%v' not found")
	ErrRouteItemExists   = logex.Define("route item '%v' is exists")
	ErrRouteItemContains = logex.Define("route item '%v' contains by '%v'")
)

Functions

func FormatCIDR

func FormatCIDR(cidr string) string

Types

type EphemeralItem

type EphemeralItem struct {
	*Item
	Expired time.Time
}

type EphemeralItems

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

func NewEphemeralItems

func NewEphemeralItems() *EphemeralItems

func (*EphemeralItems) Add

func (e *EphemeralItems) Add(i *EphemeralItem)

func (*EphemeralItems) Find

func (e *EphemeralItems) Find(cidr string) *list.Element

func (*EphemeralItems) GetFront

func (e *EphemeralItems) GetFront() *EphemeralItem

func (*EphemeralItems) Len

func (e *EphemeralItems) Len() int

func (*EphemeralItems) Match

func (e *EphemeralItems) Match(ipnet *net.IPNet) *EphemeralItem

func (*EphemeralItems) Remove

func (e *EphemeralItems) Remove(cidr string) *EphemeralItem

type Item

type Item struct {
	CIDR    string
	Comment string
	IPNet   *net.IPNet
}

one line "CIDR\tCOMMENT"

func NewItem

func NewItem(ipnet *net.IPNet, comment string) *Item

func NewItemCIDR

func NewItemCIDR(cidr string, comment string) (*Item, error)

func (Item) Match

func (i Item) Match(target *net.IPNet) bool

func (Item) String

func (i Item) String() string

type Items

type Items []Item

func (*Items) Append

func (is *Items) Append(i *Item)

func (Items) Find

func (is Items) Find(cidr string) int

func (*Items) Len

func (is *Items) Len() int

func (Items) Less

func (is Items) Less(i, j int) bool

func (Items) Match

func (is Items) Match(ipnet *net.IPNet) *Item

func (*Items) Remove

func (is *Items) Remove(cidr string) *Item

func (*Items) Sort

func (is *Items) Sort()

func (Items) Swap

func (is Items) Swap(i, j int)

type Route

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

func NewRoute

func NewRoute(f *flow.Flow, devName string) *Route

func (*Route) AddEphemeralItem

func (r *Route) AddEphemeralItem(i *EphemeralItem) error

func (*Route) AddItem

func (r *Route) AddItem(i *Item) error

func (*Route) DeleteRoute

func (r *Route) DeleteRoute(cidr string) error

func (*Route) GetEphemeralItems

func (r *Route) GetEphemeralItems() []EphemeralItem

func (*Route) GetItems

func (r *Route) GetItems() Items

func (*Route) Load

func (r *Route) Load(fp string) error

func (*Route) Match

func (r *Route) Match(ipnet *net.IPNet) *Item

func (*Route) PersistEphemeralItem

func (r *Route) PersistEphemeralItem(cidr string) error

func (*Route) RemoveEphemeralItem

func (r *Route) RemoveEphemeralItem(cidr string) error

func (*Route) RemoveItem

func (r *Route) RemoveItem(cidr string) error

func (*Route) Save

func (r *Route) Save(fp string) error

func (*Route) SetRoute

func (r *Route) SetRoute(cidr string) error

Jump to

Keyboard shortcuts

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