utils

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RandomIP

func RandomIP(network net.IPNet) net.IP

Generate a random IP address within the network

func RemoveRoute

func RemoveRoute(network string, gateway string) error

func RunCmd

func RunCmd(name string, cmdStr ...string) ([]byte, error)

func SetRoute

func SetRoute(network string, gateway string) error

func SetupNAT

func SetupNAT() error

nat rules

Types

type HostRoute

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

host route tables

var RouteTable *HostRoute

func (*HostRoute) RemoveRoute

func (h *HostRoute) RemoveRoute(target string) error

delete route

func (*HostRoute) SetRoute

func (h *HostRoute) SetRoute(target, gateway string) error

set route

func (*HostRoute) Start

func (h *HostRoute) Start() error

refresh route

type IPMapping

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

ip to ip mapping

func NewIPMapping

func NewIPMapping(expire func(net.IP) error) *IPMapping

create an ip to ip mapping

func (*IPMapping) Delete

func (c *IPMapping) Delete(ip net.IP)

delete value

func (*IPMapping) Get

func (c *IPMapping) Get(ip net.IP) *net.IP

get value

func (*IPMapping) Put

func (c *IPMapping) Put(ip1, ip2 net.IP)

put value

type IPPool

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

ip pool

func NewIPPool

func NewIPPool(network net.IPNet) *IPPool

create ip pool

func (*IPPool) Alloc

func (p *IPPool) Alloc() (net.IP, error)

alloc new ip

func (*IPPool) Free

func (p *IPPool) Free(ip net.IP)

free ip

Jump to

Keyboard shortcuts

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