netutils

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: MIT Imports: 16 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddIntToIP

func AddIntToIP(ip net.IP, ordinal uint64) net.IP

Adds the ordinal IP to the current array 192.168.0.0 + 53 => 192.168.0.53

func DefaultGateway

func DefaultGateway(cidr string) (string, error)

func DeleteInterfaceIfExists

func DeleteInterfaceIfExists(ctx context.Context, nsfd netns.NsHandle, ifname string) error

func ForwardConnection added in v0.5.3

func ForwardConnection(ctx context.Context, srcSocket net.Conn, ns, ip, port string) error

func GenerateIfaceName

func GenerateIfaceName(nlh netlink.Handler, prefix string, len int) (string, error)

GenerateIfaceName returns an interface name using the passed in prefix and the length of random bytes. The api ensures that the there are is no interface which exists with that name.

func GenerateRandomName added in v1.0.1

func GenerateRandomName(prefix string, size int) (string, error)

GenerateRandomName returns a new name joined with a prefix. This size specified is used to truncate the randomly generated value

func ParseAddr

func ParseAddr(s string) (*netlink.Addr, error)

ParseAddr parses the string representation of an address in the form $ip/$netmask $label. The label portion is optional From "github.com/vishvananda/netlink"

func ToCIDR added in v0.4.4

func ToCIDR(ip net.IP, mask net.IPMask) string

Types

type Conn added in v0.5.3

type Conn interface {
	Write([]byte) (int, error)
	Read([]byte) (int, error)
	Close() error
	CloseWrite() error
}

Jump to

Keyboard shortcuts

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