util

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const IPv4Mask = 4

Variables

This section is empty.

Functions

func CreateEdgeMeshDevice

func CreateEdgeMeshDevice(deviceName, deviceIP string) error

func GetInterfaceIP

func GetInterfaceIP(name string) (net.IP, error)

GetInterfaceIP get net interface ipv4 address

func HTTPRequestToBytes added in v1.15.0

func HTTPRequestToBytes(req *http.Request) ([]byte, error)

HTTPRequestToBytes transforms http.Request to bytes

func IsClosedError

func IsClosedError(err error) bool

func IsEOFError

func IsEOFError(err error) bool

func IsStreamResetError

func IsStreamResetError(err error) bool

func IsTimeoutError

func IsTimeoutError(err error) bool

func IsTooManyFDsError

func IsTooManyFDsError(err error) bool

func ProxyConn

func ProxyConn(in, out net.Conn)

ProxyConn proxies data bi-directionally between in and out.

func ProxyConnUDP

func ProxyConnUDP(inConn net.Conn, udpConn *net.UDPConn)

Types

type NetifManager

type NetifManager struct {
	netlink.Handle
	Addrs []*netlink.Addr
}

NetifManager copy and update from https://github.com/kubernetes/dns/blob/1.21.0/pkg/netif/netif.go

func NewNetifManager

func NewNetifManager(ips []net.IP) *NetifManager

NewNetifManager returns a new instance of NetifManager with the ip address set to the provided values These ip addresses will be bound to any devices created by this instance.

func (*NetifManager) AddBridgeDevice

func (m *NetifManager) AddBridgeDevice(name string) error

AddBridgeDevice creates a bridge device with the given name. It also binds the ip address of the NetifManager instance to this device. This function returns an error if the device exists or if address binding fails.

func (*NetifManager) EnsureBridgeDevice

func (m *NetifManager) EnsureBridgeDevice(name string) (bool, error)

EnsureBridgeDevice checks for the presence of the given bridge device and creates one if it does not exist. Returns a boolean to indicate if this device was found and error if any.

func (*NetifManager) RemoveBridgeDevice

func (m *NetifManager) RemoveBridgeDevice(name string) error

RemoveBridgeDevice deletes the bridge device with the given name.

func (*NetifManager) SetupBridgeDevice

func (m *NetifManager) SetupBridgeDevice(name string) error

SetupBridgeDevice setup the bridge device with the given name.

Jump to

Keyboard shortcuts

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