utils

package
v0.0.0-...-b4be9a7 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UNKNOW_IP = "UNKNOW_IP"
)

Variables

This section is empty.

Functions

func AddMulticastRouteToIface

func AddMulticastRouteToIface(cidr string, ifaceIdx int) error
func AsignAddrToLink(name, addr string, up bool) error

func ConvertBytes

func ConvertBytes(bytes uint64) string

func DelLinkByName

func DelLinkByName(name string) error

func GetLinkStatsByName

func GetLinkStatsByName(name string, linkMsg []LinkMessages) (uint64, uint64, string, string)

func GetMacFromIP

func GetMacFromIP(ip net.IP) net.HardwareAddr

func IdxFromString

func IdxFromString(step int, str string) int

func IsIPConflictErr

func IsIPConflictErr(err error) bool

func IsRouteNotExist

func IsRouteNotExist(err error) bool

func IsRunOutOfIP

func IsRunOutOfIP(err error) bool

func IsTapNotExist

func IsTapNotExist(err error) bool

func IsUnauthedErr

func IsUnauthedErr(err error) bool

func IsUnsupportedPkt

func IsUnsupportedPkt(err error) bool

func NewTap

func NewTap(br string) (*water.Interface, error)

func ParseRoutesStream

func ParseRoutesStream(data []byte) map[string]string

func RandStr

func RandStr(n int) string

func SetLinkMaster

func SetLinkMaster(iface, br string) error

func SetMacToTap

func SetMacToTap(name, ip string) error

When create tap interface, the mac address will change when a endpoint close then reconnect to it, if there is another endpoint try to access this endpoint, the ip neigh entry is still the old, it must waiting for the ip neigh entry staled maybe we can generate mac address according the ip address

func SyncRoutesForIface

func SyncRoutesForIface(ifaceName, ip string, routes map[string]string) error

func ValidateDHCPRange

func ValidateDHCPRange(ipRange string) (net.IP, int)

func ValidateIPv4Addr

func ValidateIPv4Addr(addr string) bool

func ValidateIPv4WithNetmask

func ValidateIPv4WithNetmask(addr string) bool

func ValidateKey

func ValidateKey(key string) bool

func ValidatePasswd

func ValidatePasswd(passwd string) bool

func ValidatePort

func ValidatePort(port int) bool

func ValidateUsername

func ValidateUsername(name string) bool

Types

type LinkMessages

type LinkMessages struct {
	InterfaceName string
	RX_SIZE       string
	TX_SIZE       string
	RX_PKT        uint64
	TX_PKT        uint64
}

func GetLinkStats

func GetLinkStats() []LinkMessages

Jump to

Keyboard shortcuts

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