netctl

package
v0.0.0-...-cb67616 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPath = "/etc/vinyl/network.d"

DefautPath is the directory in which we look for profiles, should one not be specified

Variables

View Source
var (
	// ResolvFile is the location of dns resolver config
	ResolvFile = "/etc/resolv.conf"

	// Verbose allows us to log calls, operations
	Verbose = false
)

Functions

This section is empty.

Types

type Address

type Address struct {
	Address       string `toml:"address,omitempty"`
	AddressParsed net.IP `toml:"-"`

	Netmask       string     `toml:"netmask,omitempty"`
	NetmaskParsed net.IPMask `toml:"-"`

	Gateway       string `toml:"gateway,omitempty"`
	GatewayParsed net.IP `toml:"-"`

	// Enable needs to be true in order to configure
	Enable bool `toml:"enable,omitempty"`

	// DHCP true means Address/ Netmask/ Gateway can be ignored
	// (if set, they're ignored anyway)
	DHCP bool `toml:"dhcp,omitempty"`
}

Address holds the configuration necessary for setting an interface's IP address, including both manual and dhcp settings

func (*Address) Parse

func (a *Address) Parse()

Parse will turn various user specified components of an Address into net.IP/net.IPMask types

type Netctl

type Netctl struct {
	Profiles []Profile
}

Netctl provides access to the files at /etc/vinyl/network which govern network connections on vinyl systems

func New

func New(p string) (n Netctl, err error)

New returns a new Netctl

func NewDefaults

func NewDefaults() (Netctl, error)

NewDefaults calls New with all of the default values

func (Netctl) Profile

func (n Netctl) Profile(iface string) (p Profile, err error)

Profile returns the configured profile for this interface

type Profile

type Profile struct {
	Interface string  `toml:"interface"`
	IPv4      Address `toml:",omitempty"`
	IPv6      Address `toml:",omitempty"`
	// contains filtered or unexported fields
}

Profile contains configuration and data for an interface

func NewProfile

func NewProfile() Profile

NewProfile returns a Profile with initial defaults set

func (Profile) BringUp

func (p Profile) BringUp() (err error)

BringUp uses netlink to bring an interface up

func (Profile) Down

func (p Profile) Down() (err error)

Down will bring an interface down

func (*Profile) PopulateFromDHCP

func (p *Profile) PopulateFromDHCP(idx int, a *Address) (err error)

PopulateFromDHCP accepts an index (where 0 is IPv4, and 1 is IPv6) and a pointer to an Address. It will:

1. Bring up the interface 2. Request either an IPv4 address or an IPv6 address (from index) 3. Update address with this data 4. Take the interface back down (to allow netlink to control the iface) 5. Return

func (Profile) SetAddress

func (p Profile) SetAddress(a Address) (err error)

SetAddress uses netlink to set the address of an interface

func (Profile) SetGateway

func (p Profile) SetGateway(a Address) (err error)

SetGateway uses netlink to set the gateway of an interface

func (Profile) Up

func (p Profile) Up() (err error)

Up will bring an interface up

func (Profile) UpLoopback

func (p Profile) UpLoopback() (err error)

UpLoopback brings a loopback device up

Jump to

Keyboard shortcuts

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