ip

package
v0.0.0-...-683b059 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package ip contains utility functions to wrap around the ip program.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddIPOption

type AddIPOption func(*addIPConfig)

AddIPOption is the option type for Runner.AddIP call.

func AddIPBroadcast

func AddIPBroadcast(broadcastIP net.IP) AddIPOption

AddIPBroadcast returns an AddIPOption setting broadcast IP.

type LinkState

type LinkState string

LinkState is the type for the interface state from ip command.

const (
	LinkStateUp      LinkState = "UP"
	LinkStateDown    LinkState = "DOWN"
	LinkStateUnknown LinkState = "UNKNOWN"
)

Possible link states from ip command.

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner contains methods rely on running "ip" command.

func NewRunner

func NewRunner(cmd cmd.Runner) *Runner

NewRunner creates an ip command utility runner.

func (*Runner) AddIP

func (r *Runner) AddIP(ctx context.Context, iface string, ip net.IP, maskLen int, ops ...AddIPOption) error

AddIP adds IPv4/IPv6 settings to iface.

func (r *Runner) AddLink(ctx context.Context, name, t string, extraArgs ...string) error

AddLink adds a virtual link of type t.

func (r *Runner) DeleteLink(ctx context.Context, name string) error

DeleteLink deletes a virtual link.

func (*Runner) Flags

func (r *Runner) Flags(ctx context.Context, iface string) ([]string, error)

Flags returns the flags of the interface.

func (*Runner) FlushIP

func (r *Runner) FlushIP(ctx context.Context, iface string) error

FlushIP flushes IP setting on iface.

func (*Runner) IsLinkUp

func (r *Runner) IsLinkUp(ctx context.Context, iface string) (bool, error)

IsLinkUp queries whether iface is currently up.

func (*Runner) LinkWithPrefix

func (r *Runner) LinkWithPrefix(ctx context.Context, prefix string) ([]string, error)

LinkWithPrefix shows the device names that start with prefix.

func (*Runner) MAC

func (r *Runner) MAC(ctx context.Context, iface string) (net.HardwareAddr, error)

MAC returns the MAC address of the interface.

func (*Runner) SetBridge

func (r *Runner) SetBridge(ctx context.Context, dev, br string) error

SetBridge adds the device into the bridge.

func (*Runner) SetLinkDown

func (r *Runner) SetLinkDown(ctx context.Context, iface string) error

SetLinkDown brings iface down.

func (*Runner) SetLinkUp

func (r *Runner) SetLinkUp(ctx context.Context, iface string) error

SetLinkUp brings iface up.

func (*Runner) SetMAC

func (r *Runner) SetMAC(ctx context.Context, iface string, mac net.HardwareAddr) error

SetMAC sets MAC address of iface with command "ip link set $iface address $mac.

func (*Runner) State

func (r *Runner) State(ctx context.Context, iface string) (LinkState, error)

State returns the operation state of the interface.

func (*Runner) UnsetBridge

func (r *Runner) UnsetBridge(ctx context.Context, dev string) error

UnsetBridge unsets the bridge of the device.

Jump to

Keyboard shortcuts

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