defip

package module
v0.1.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoIP = fmt.Errorf("could not find IP matching provided kind")

ErrNoIP indicates that the library could not obtain an IP matching the provided kind.

Functions

func FindDefaultIP

func FindDefaultIP(kind NetRouteKind) (*netip.Addr, error)

FindDefaultIP attempts to find an IP of given NetRouteKind that's most likely connected to wider network. Returns ErrNoIP in case no IP with the given kind can be detected.

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 netip.Addr
	Flags       string
	Netif       string
	Gateway     netip.Addr
}

func (NetRoute) HasFlags

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

type NetRouteKind

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

func (NetRouteKind) String

func (n NetRouteKind) String() string

type NetRouteList

type NetRouteList []NetRoute

func FindRoutes

func FindRoutes() (NetRouteList, error)

FindRoutes returns a list of detected routes to default gateways

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