gateway

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindDefaultGateways

func FindDefaultGateways() ([]netip.Addr, error)

FindDefaultGateways returns a list of addresses of all gateways used by default routes, both IPv4 and IPv6.

func FindDefaultIPs

func FindDefaultIPs() ([]netip.Addr, error)

FindDefaultIPs returns a list of IPs associated to all interfaces using a default gateway.

func FindDefaultInterfaces

func FindDefaultInterfaces() ([]string, error)

FindDefaultInterfaces returns a slice of strings containing the name of interfaces using a default gateway.

func PickDefaultInterface

func PickDefaultInterface() (string, error)

PickDefaultInterface picks the interface with most IPs based on the result of FindDefaultInterfaces.

Types

type ErrCantParse

type ErrCantParse struct{}

ErrCantParse is returned if the route table is garbage.

func (*ErrCantParse) Error

func (*ErrCantParse) Error() string

type ErrInvalidRouteFileFormat

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

ErrInvalidRouteFileFormat is returned if the format of /proc/net/route is unexpected on Linux systems. Please raise an issue.

func (*ErrInvalidRouteFileFormat) Error

func (e *ErrInvalidRouteFileFormat) Error() string

type ErrNotImplemented

type ErrNotImplemented struct{}

ErrNotImplemented is returned if your operating system is not supported by this package. Please raise an issue to request support.

func (*ErrNotImplemented) Error

func (*ErrNotImplemented) Error() string

type NetRoute

type NetRoute struct {
	Kind        NetRouteKind
	Destination string
	Flags       string
	Netif       string
	Gateway     string
}

func (NetRoute) HasFlags

func (n NetRoute) HasFlags(flags ...string) bool

type NetRouteKind

type NetRouteKind uint8
const (
	NetRouteKindV4 NetRouteKind = iota + 1
	NetRouteKindV6
)

type NetRouteList

type NetRouteList []NetRoute

func (NetRouteList) FindDefaults

func (n NetRouteList) FindDefaults(kind NetRouteKind) []NetRoute

Jump to

Keyboard shortcuts

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