network

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMaskSizeOutOfLimit = errors.New("net mask size out of limit")
)

Functions

func AddSystemRoute

func AddSystemRoute(network string, dev string) error

AddSystemRoute @Description: @param network @param dev

Types

type IRouter

type IRouter interface {
	//
	// Route
	// @Description:
	// @param ip
	// @return interface{}
	//
	Route(ip net.IP) string
	//
	// Add
	// @Description: Add("192.168.1.0/24"[dst cidr],"10.1.1.2"[client])
	// @param dst destination cidr
	// @param tunnel tunnel mark
	// @return error
	//
	Add(dst string, tunnel string) error
	//
	// Delete
	// @Description:
	// @param dst  dst destination cidr
	//
	Delete(dst string)
}

IRouter @Description:

type RouteRecord

type RouteRecord struct {
	DeviceName string
	Network    string
	Deployed   bool
	Err        error
}

RouteRecord @Description:

func (*RouteRecord) Deploy

func (r *RouteRecord) Deploy()

Deploy @Description: @receiver r

type RouteTable

type RouteTable struct {
	Length int
	// contains filtered or unexported fields
}

RouteTable @Description:

func NewRouteTable

func NewRouteTable(autoRank bool, minimumMaskSize int) *RouteTable

NewRouteTable @Description: @return *RouteTable

func (*RouteTable) Add

func (r *RouteTable) Add(dst string, uuid string) error

Add @Description: 若已存在则会更新路由表 @receiver r @param dst @param uuid @return error

func (*RouteTable) Delete

func (r *RouteTable) Delete(dst string)

Delete @Description: @receiver r @param dst

func (*RouteTable) DeleteById added in v0.1.1

func (r *RouteTable) DeleteById(id string)

DeleteById @Description: @receiver r @param dst

func (*RouteTable) GetByName

func (r *RouteTable) GetByName(name string) *TableNode

GetByName @Description: @receiver r @param name @return *TableNode

func (*RouteTable) ListByName

func (r *RouteTable) ListByName() []string

ListByName @Description: @receiver r @return []string

func (*RouteTable) Print

func (r *RouteTable) Print()

Print @Description: @receiver r

func (*RouteTable) Route

func (r *RouteTable) Route(ip net.IP) string

Route @Description: @receiver r @param ip @return string

type SystemRouteTable

type SystemRouteTable struct {
	DeviceName string
	Records    map[string]*RouteRecord
	// contains filtered or unexported fields
}

SystemRouteTable @Description:

func NewSystemRouteTable

func NewSystemRouteTable(devName string) *SystemRouteTable

NewSystemRouteTable @Description: @return *SystemRouteTable

func (*SystemRouteTable) DeployAll

func (t *SystemRouteTable) DeployAll()

DeployAll @Description: @receiver t

type TableNode

type TableNode struct {
	Name   string
	Net    *net.IPNet
	Target string
	Next   *TableNode
	Last   *TableNode
	// contains filtered or unexported fields
}

TableNode @Description:

func NewTableNode

func NewTableNode(dst string, uuid string) (node *TableNode, err error)

NewTableNode @Description: @param dst @param tunnel @return node @return err

func NewTableNodeWithLimit

func NewTableNodeWithLimit(dst string, uuid string, minimumMaskSize int) (node *TableNode, err error)

NewTableNodeWithLimit @Description: @param dst @param tunnel @return node @return err

Directories

Path Synopsis
pool

Jump to

Keyboard shortcuts

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