Documentation
¶
Overview ¶
Example ¶
macs, err := DefaultInterfaces(1 * time.Second) if err != nil { log.Printf("no interfaces with state UP") } log.Printf("mac addresses of interfaces with state UP: %v", macs)
Output:
Index ¶
- Variables
- func AddBool(fs *flag.FlagSet, opt *bool, short, long string, value bool)
- func AddInt(fs *flag.FlagSet, opt *int, short, long string, value int)
- func AddString(fs *flag.FlagSet, opt *string, short, long, value string)
- func AddStringS(fs *flag.FlagSet, opt *SliceFlag, short, long, value string)
- func ConstructURL(url, user, password string) (string, error)
- func DefaultInterfaces(waitForInterface time.Duration) ([]net.HardwareAddr, error)
- func MaxHost(network *net.IPNet) string
- func New(args []string, usage func(), set func(*flag.FlagSet)) *flag.FlagSet
- func ValidateHostAndGateway(optHostIP, optGateway string, optForce, optTryLastIPForGateway bool) (string, error)
- type SliceFlag
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var DefAllowedNetworks = "127.0.0.1/32"
var DefBondingMode = "balance-rr"
var DefDNS = "9.9.9.9,149.112.112.112"
var DefHostname = "localhost.local"
Defaults optionally set in Makefile, through -ldflags which makes it necessary to keep these as variables and not put them in a struct.
var DefPassword = "stboot"
var DefTemplateURL = "https://user:password@stpackage.example.org/os-stable.json"
var DefUser = "stboot"
Functions ¶
func AddStringS ¶
AddStringS adds a string-slice option to a flag set. If the default value is the empty string, then no value is appended to the list. If the default value contains one or more comma characters, it is split to multiple values.
Examples: - Default value "" would yield nil - Default value "foo" would yield []string{"foo"} - Default value "foo,bar" would yield []string{"foo", "bar"}
func ConstructURL ¶ added in v0.3.2
ConstructURL constructs a URL to an OS package server, replacing the first occurrence of "user:password" with the specified user and password.
func DefaultInterfaces ¶
func DefaultInterfaces(waitForInterface time.Duration) ([]net.HardwareAddr, error)
DefaultInterfaces outputs a list with one or more MAC addresses. The associated interfaces have state UP and a non-empty MAC address, and can thus be used as sane defaults. This corresponds to the network interface flags IFF_UP and IFF_RUNNING.
Interfaces are put into state UP on a best-effort level. If the appropriate permissions are lacking, an interface is simply skipped without any error.
Types ¶
type SliceFlag ¶
type SliceFlag struct { Values []string // contains filtered or unexported fields }
SliceFlag supports setting multiple string values by repeating an option. For example, "-e foo -e bar" is a list containing ["foo", "bar"]. It is also possible to set multiple values with comma-separation, e.g., "-e foo,bar".