Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Interfaces = func() ([]HardwareInterface, error) { ifaces := []HardwareInterface{} interfaces, err := net.Interfaces() if err != nil { return ifaces, err } virtual := virtualInterfaces("/sys/devices/virtual/net/") for _, i := range interfaces { if i.Flags&net.FlagUp != 0 && bytes.Compare(i.HardwareAddr, nil) != 0 { if stringInSlice(i.Name, virtual) { continue } ifaces = append(ifaces, HardwareInterface{i.Name, i.HardwareAddr.String()}) } } return ifaces, nil }
Interfaces fetches the list of network interfaces
Functions ¶
Types ¶
type AccessPoint ¶
type AccessPoint struct {
Password string `yaml:"password,omitempty"`
}
AccessPoint defines the credentials for a WiFi access point
type Ethernet ¶
type Ethernet struct { Use bool `yaml:"-"` Name string `yaml:"-"` DHCP4 string `yaml:"dhcp4,omitempty"` Addresses []string `yaml:"addresses,omitempty"` NameServers map[string][]string `yaml:"nameservers,omitempty"` Gateway4 string `yaml:"gateway4,omitempty"` AccessPoints map[string]AccessPoint `yaml:"access-points,omitempty"` }
Ethernet defines a single interface
type HardwareInterface ¶
HardwareInterface represents a hardware network interface
type NMService ¶
type NMService interface { Apply() error Current() *NetplanYAML Store(ethernet Ethernet) error }
NMService is the interface for the netplan service
type NetManager ¶
type NetManager struct {
// contains filtered or unexported fields
}
NetManager implements actions for managing network manager
func NewNetworkManager ¶
func NewNetworkManager(dBus dbus.Service) *NetManager
NewNetworkManager creates a network manager service
func (*NetManager) Apply ¶
func (np *NetManager) Apply() error
Apply applies the network manager configuration using dbus
func (*NetManager) Current ¶
func (np *NetManager) Current() *NetplanYAML
Current returns the current network manager settings
func (*NetManager) Store ¶
func (np *NetManager) Store(ethernet Ethernet) error
Store stores the updated network settings
type Netplan ¶
type Netplan struct {
// contains filtered or unexported fields
}
Netplan implements actions for managing netplan
func NewNetplan ¶
NewNetplan creates a netplan object from a config file
func (*Netplan) Current ¶
func (np *Netplan) Current() *NetplanYAML
Current returns the current netplan settings
type NetplanService ¶
type NetplanService interface { Apply() error Current() *NetplanYAML Store(ethernet Ethernet) error }
NetplanService is the interface for the netplan service
type NetplanYAML ¶
type NetplanYAML struct {
Network Network `yaml:"network"`
}
NetplanYAML defines the structure of the netplan YAML file
type Network ¶
type Network struct { Version int `yaml:"version"` Renderer string `yaml:"renderer,omitempty"` Ethernets map[string]Ethernet `yaml:"ethernets,omitempty"` WiFis map[string]Ethernet `yaml:"wifis,omitempty"` }
Network defines then network subsection of the netplan YAML