Documentation ¶
Index ¶
- func FindDefaultGateways() ([]netip.Addr, error)
- func FindDefaultIPs() ([]netip.Addr, error)
- func FindDefaultInterfaces() ([]string, error)
- func PickDefaultInterface() (string, error)
- type ErrCantParse
- type ErrInvalidRouteFileFormat
- type ErrNotImplemented
- type NetRoute
- type NetRouteKind
- type NetRouteList
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindDefaultGateways ¶
FindDefaultGateways returns a list of addresses of all gateways used by default routes, both IPv4 and IPv6.
func FindDefaultIPs ¶
FindDefaultIPs returns a list of IPs associated to all interfaces using a default gateway.
func FindDefaultInterfaces ¶
FindDefaultInterfaces returns a slice of strings containing the name of interfaces using a default gateway.
func PickDefaultInterface ¶
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 }
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