Documentation ¶
Overview ¶
Package system provides a portable interface to low-level system networking operations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrLinkChange = errors.New("link state change")
ErrLinkChange is a sentinel value which indicates a link state change.
var ErrLinkNotReady = errors.New("link not ready")
ErrLinkNotReady is a sentinel which indicates an interface is not ready for use with a Dialer listener.
Functions ¶
This section is empty.
Types ¶
type Addresser ¶ added in v0.3.3
type Addresser interface { AddressesByIndex(index int) ([]IP, error) LoopbackRoutes() ([]Route, error) }
An Addresser is a type that can fetch IP address and route information from the operating system.
TODO(mdlayher): this name is a bit awkward with the inclusion of Routes. Reconsider.
func NewAddresser ¶ added in v0.3.3
func NewAddresser() Addresser
NewAddresser creates an Addresser which executes real rtnetlink requests.
func NewNetAddresser ¶ added in v0.3.3
func NewNetAddresser() Addresser
NewNetAddresser creates an Addresser which uses package net functions.
type Conn ¶
type Conn interface { ReadFrom() (ndp.Message, *ipv6.ControlMessage, netip.Addr, error) SetReadDeadline(t time.Time) error WriteTo(m ndp.Message, cm *ipv6.ControlMessage, dst netip.Addr) error }
A Conn abstracts IPv6 NDP socket operations for purposes of testing.
type DialContext ¶
type DialContext struct { Conn Conn Interface *net.Interface IP netip.Addr // contains filtered or unexported fields }
A DialContext stores data used in the context of a Dialer.Dial closure.
type Dialer ¶
type Dialer struct { // DialFunc specifies a function which will override the default dialing // logic to produce an arbitrary DialContext. DialFunc should only be // set in tests. DialFunc func() (*DialContext, error) // contains filtered or unexported fields }
A Dialer can create Conns which can be reinitialized on certain errors.
func (*Dialer) Dial ¶
func (d *Dialer) Dial(ctx context.Context, fn func(ctx context.Context, dctx *DialContext) error) error
Dial creates a Conn and invokes fn with a populated DialContext for the caller's use. If fn returns an error which is considered retryable, Dial will attempt to re-dial the Conn and invoke fn again.
type DialerMode ¶ added in v0.2.7
type DialerMode int
A DialerMode specifies a mode of operation for the Dialer.
const ( Advertise DialerMode Monitor )
Possible DialerMode values.
type IP ¶ added in v0.3.3
type IP struct { // The IP address of an interface. Note that address is not actually a // "prefix" but instead an IP address and its associated CIDR mask, which // may be in non-canonical form such as 2001:db8::1/64. Address netip.Prefix // Interface flags fetched from the operating system which are used for // address preference logic. Deprecated, ManageTemporaryAddresses, StablePrivacy, Temporary, Tentative bool // Reports whether the operating system treats this address as valid // forever, as is the case for static addresses. ValidForever bool }
An IP is an IP address and its associated operating system-specific metadata.
type Route ¶ added in v1.1.0
type Route struct { // A destination route for an interface. Prefix netip.Prefix // The index of the network interface which contains this route. Index int // The NDP preference value for a particular route. Preference ndp.Preference }
A Route is an destination route and its associated operating system-specific metadata.
type State ¶
type State interface { IPv6Autoconf(iface string) (bool, error) IPv6Forwarding(iface string) (bool, error) SetIPv6Autoconf(iface string, enable bool) error }
State is a type which can manipulate the low-level IPv6 parameters of a system.
type TestState ¶
type TestState struct { // Global settings for any interface name. Autoconf, Forwarding bool Error error // Alternatively, you may configure parameters individually on a // per-interface basis. Note that these configurations will override any // global configurations set above. Interfaces map[string]TestStateInterface }
A TestState is a State which is primarily useful in tests.
func (TestState) IPv6Autoconf ¶
IPv6Autoconf implements State.
func (TestState) IPv6Forwarding ¶
IPv6Forwarding implements State.
type TestStateInterface ¶
type TestStateInterface struct {
Autoconf, Forwarding bool
}
A TestStateInterface sets the State configuration for a simulated network interface.