system

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: May 22, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package system provides a portable interface to low-level system networking operations.

Index

Constants

This section is empty.

Variables

View Source
var ErrLinkChange = errors.New("link state change")

ErrLinkChange is a sentinel value which indicates a link state change.

Functions

This section is empty.

Types

type Conn

type Conn interface {
	ReadFrom() (ndp.Message, *ipv6.ControlMessage, net.IP, error)
	SetReadDeadline(t time.Time) error
	WriteTo(m ndp.Message, cm *ipv6.ControlMessage, dst net.IP) error
}

A Conn abstracts IPv6 NDP socket operations for purposes of testing.

type DialContext

type DialContext struct {
	Conn      Conn
	Interface *net.Interface
	IP        net.IP
	// 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
	// contains filtered or unexported fields
}

A Dialer can create Conns which can be reinitialized on certain errors.

func NewDialer

func NewDialer(ll *log.Logger, iface string) *Dialer

NewDialer creates a Dialer using the specified logger and network interface.

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 State

type State interface {
	IPv6Autoconf(iface string) (bool, error)
	IPv6Forwarding(iface string) (bool, error)
}

State is a type which can manipulate the low-level IPv6 parameters of a system.

func NewState

func NewState() State

NewState creates State which directly manipulates the operating 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

func (ts TestState) IPv6Autoconf(iface string) (bool, error)

IPv6Autoconf implements State.

func (TestState) IPv6Forwarding

func (ts TestState) IPv6Forwarding(iface string) (bool, error)

IPv6Forwarding implements State.

type TestStateInterface

type TestStateInterface struct {
	Autoconf, Forwarding bool
}

A TestStateInterface sets the State configuration for a simulated network interface.

Jump to

Keyboard shortcuts

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