network

package
v0.0.0-...-05f81da Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RequiredBundle the bundle needed to use NetworkManager
	RequiredBundle = "NetworkManager"

	// IPv4 identifies the addr version as ipv4
	IPv4 = iota

	// IPv6 identifies the addr version as ipv6
	IPv6

	// PreInstallConf is the name of the pre-installation message file
	PreInstallConf = "pre-install-msg.yaml"
	// PostInstallConf is the name of the pre-installation message file
	PostInstallConf = "post-install-msg.yaml"
	// PreGuiInstallConf is the name of the pre-installation message file
	PreGuiInstallConf = "pre-gui-install-msg.yaml"
	// PostGuiInstallConf is the name of the pre-installation message file
	PostGuiInstallConf = "post-gui-install-msg.yaml"
)

Variables

This section is empty.

Functions

func Apply

func Apply(root string, ifaces []*Interface) error

Apply apply the configurations of a set of interfaces to the running system Determines the network manage type to generate the correct files

func CheckURL

func CheckURL(url string) error

CheckURL tests if the given URL is accessible

func CopyNetworkInterfaces

func CopyNetworkInterfaces(rootDir string) error

CopyNetworkInterfaces transfer the user defined network interface files to the target installation media

func DownloadInstallerMessage

func DownloadInstallerMessage(header string, installConf string) string

DownloadInstallerMessage pulls down a message from a URL Intended for getting a message to display before or after the installation process

func EnablePacDiscovery

func EnablePacDiscovery(rootDir string) error

EnablePacDiscovery turns on the pacdiscovery service Normally this service is enabled by a DHCP lease path, but it must be manually enabled if we set a static IP

func FetchRemoteConfigFile

func FetchRemoteConfigFile(url string) (string, error)

FetchRemoteConfigFile given an config url fetches it from the network. This function currently supports only http/https protocol. After success return the local file path.

func IsNetworkManagerActive

func IsNetworkManagerActive() bool

IsNetworkManagerActive is used to check if we are using systemd.networkd or NetworkManager to manage the wired connections. Clear Linux OS change from system.networkd to NetworkManager in April 2019 build ?????

func IsValidDomainName

func IsValidDomainName(domain string) string

IsValidDomainName returns error message or nil if is valid

func IsValidIP

func IsValidIP(str string) string

IsValidIP returns empty string if IP address is valid

func IsValidURI

func IsValidURI(uri string, allowInsecureHTTP bool) bool

IsValidURI checks for valid URIs that use the HTTPS or FILE protocol

func Restart

func Restart() error

Restart restarts the network services

func VerifyConnectivity

func VerifyConnectivity() error

VerifyConnectivity tests if the network configuration is working

Types

type Addr

type Addr struct {
	IP      string
	NetMask string
	Version int
}

Addr wraps the net' package Addr struct

func (*Addr) VersionString

func (a *Addr) VersionString() string

VersionString returns a string representation for a given addr version (ipv4/ipv6)

type Interface

type Interface struct {
	Name        string
	Addrs       []*Addr
	DHCP        bool
	Gateway     string `json:"gateway,omitempty"`
	DNSServer   string
	DNSDomain   string
	UserDefined bool
	Metric      uint32 `json:"metric,omitempty"`
}

Interface is a network interface representation and wraps the net' package Interface struct

func Interfaces

func Interfaces() ([]*Interface, error)

Interfaces lists all available network interfaces

func (*Interface) AddAddr

func (i *Interface) AddAddr(IP string, NetMask string, Version int)

AddAddr adds a new interface set with the provided arguments to a given Interface

func (*Interface) ApplyNetworkD

func (i *Interface) ApplyNetworkD(root string) error

ApplyNetworkD does apply the interface configuration to the running system using systemd.networkd

func (*Interface) ApplyNetworkManager

func (i *Interface) ApplyNetworkManager(root string) error

ApplyNetworkManager does apply the interface configuration to the running system using Network Manager

func (*Interface) GetDNSInfo

func (i *Interface) GetDNSInfo() (string, string, error)

GetDNSInfo returns the DNS Server and Domain

func (*Interface) GetGateway

func (i *Interface) GetGateway() (string, error)

GetGateway returns the best gateway for the interface

func (*Interface) HasIPv4Addr

func (i *Interface) HasIPv4Addr() bool

HasIPv4Addr will lookup an addr with Version set to ipv4

func (*Interface) IsUserDefined

func (i *Interface) IsUserDefined() bool

IsUserDefined returns true if the configuration was interactively defined by the user

func (*Interface) MarshalYAML

func (i *Interface) MarshalYAML() (interface{}, error)

MarshalYAML marshals Interface into YAML format

func (*Interface) UnmarshalYAML

func (i *Interface) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals Interface from YAML format

type LangString

type LangString struct {
	Default string `yaml:"default,omitempty"`
	EnUs    string `yaml:"en_US,omitempty"`
}

LangString hold strings for each translated language and one for default if the current language is unavailable

type Messenger

type Messenger struct {
	Messages []*LangString `yaml:"install-msg,omitempty"`
}

Messenger is an array of language string used to create an end user message for display

Jump to

Keyboard shortcuts

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