device

package
v0.0.0-...-851e5e8 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package device provides utilities for querying device information.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultGateway

func DefaultGateway(ipv6 bool) (net.Interface, error)

DefaultGateway returns network interface used as default gateway.

Linux generally has only a single default gateway. Although it can have more than one default gateway by using routing tables, only one is allowed per routing table.

func InterfacesAreEqual

func InterfacesAreEqual(a net.Interface, b net.Interface) bool

func InterfacesWithDefaultRoute

func InterfacesWithDefaultRoute(ignoreSet mapset.Set[string]) mapset.Set[string]

func ListPhysical

func ListPhysical() ([]net.Interface, error)

ListPhysical network interfaces found on the system.

All Linux systems have physical interfaces with one exception - containers. When system is properly virtualized, guest does not know that it is virtual so even though those interfaces are mapped to virtual interfaces on the host, guest does not know this, but containers know. This is because the kernel is shared between the host and the guest.

If the system has only virtual interfaces, return a virtual interface which is used as default gateway.

Types

type ListFunc

type ListFunc func() ([]net.Interface, error)

Jump to

Keyboard shortcuts

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