Documentation
¶
Index ¶
- Constants
- func AppArmorProfile() string
- func CanonicalNetworkAddress(address string) string
- func CanonicalNetworkAddressFromAddressAndPort(address string, port int) string
- func CheckTrustState(cert x509.Certificate, trustedCerts map[string]x509.Certificate, ...) (bool, string)
- func CompareConfigs(config1, config2 map[string]string, exclude []string) error
- func CompareVersions(version1, version2 [2]int) (int, error)
- func CopyConfig(config map[string]string) map[string]string
- func EtagCheck(r *http.Request, data interface{}) error
- func EtagHash(data interface{}) (string, error)
- func FilesystemDetect(path string) (string, error)
- func GenerateSequenceInt64(begin, end, step int) ([]int64, error)
- func GetArchitectures() ([]int, error)
- func GetExecPath() string
- func GetIdmapSet() *idmap.IdmapSet
- func GetListeners(start int) []net.Listener
- func GetStableRandomGenerator(seed string) (*rand.Rand, error)
- func GetStableRandomInt64FromList(seed int64, list []int64) (int64, error)
- func HTTPClient(certificate string, proxy proxyFunc) (*http.Client, error)
- func HasFilesystem(filesystem string) bool
- func HugepagesPath() (string, error)
- func InMemoryNetwork() (net.Listener, func() net.Conn)
- func IsAddressCovered(address1, address2 string) bool
- func IsJSONRequest(r *http.Request) bool
- func IsRecursionRequest(r *http.Request) bool
- func ListenAddresses(value string) ([]string, error)
- func LoadCert(dir string) (*shared.CertInfo, error)
- func LoadClusterCert(dir string) (*shared.CertInfo, error)
- func LoadModule(module string) error
- func LoadServerCert(dir string) (*shared.CertInfo, error)
- func NetworkInterfaceAddress() string
- func PasswordCheck(secret string, password string) error
- func RuntimeLiblxcVersionAtLeast(major int, minor int, micro int) bool
- func ServerTLSConfig(cert *shared.CertInfo) *tls.Config
- func SplitNTrimSpace(s string, sep string, n int, nilIfEmpty bool) []string
- func SysctlGet(path string) (string, error)
- func SysctlSet(parts ...string) error
- func WriteCert(dir, prefix string, cert, key, ca []byte) error
- func WriteJSON(w http.ResponseWriter, body interface{}, debug bool) error
- type ContextAwareRequest
Constants ¶
const ( FilesystemSuperMagicTmpfs = 0x01021994 FilesystemSuperMagicExt4 = 0xEF53 FilesystemSuperMagicXfs = 0x58465342 FilesystemSuperMagicNfs = 0x6969 FilesystemSuperMagicZfs = 0x2fc12fc1 )
Filesystem magic numbers
const (
// FilesystemSuperMagicBtrfs is the 64bit magic for Btrfs
FilesystemSuperMagicBtrfs = 0x9123683E
)
const SystemdListenFDsStart = 3
SystemdListenFDsStart is the number of the first file descriptor that might have been opened by systemd when socket activation is enabled. It's always 3 in real-world usage (i.e. the first file descriptor opened after stdin, stdout and stderr), so this constant should always be the value passed to GetListeners, except for unit tests.
Variables ¶
This section is empty.
Functions ¶
func AppArmorProfile ¶
func AppArmorProfile() string
AppArmorProfile returns the current apparmor profile.
func CanonicalNetworkAddress ¶
CanonicalNetworkAddress parses the given network address and returns a string of the form "host:port", possibly filling it with the default port if it's missing.
func CanonicalNetworkAddressFromAddressAndPort ¶
CanonicalNetworkAddressFromAddressAndPort returns a network address from separate address and port values. The address accepts values such as "[::]", "::" and "localhost".
func CheckTrustState ¶
func CheckTrustState(cert x509.Certificate, trustedCerts map[string]x509.Certificate, networkCert *shared.CertInfo, trustCACertificates bool) (bool, string)
CheckTrustState checks whether the given client certificate is trusted (i.e. it has a valid time span and it belongs to the given list of trusted certificates).
func CompareConfigs ¶
CompareConfigs compares two config maps and returns an error if they differ.
func CompareVersions ¶
CompareVersions the versions of two LXD nodes.
A version consists of the version the node's schema and the number of API extensions it supports.
Return 0 if they equal, 1 if the first version is greater than the second and 2 if the second is greater than the first.
Return an error if inconsistent versions are detected, for example the first node's schema is greater than the second's, but the number of extensions is smaller.
func CopyConfig ¶
CopyConfig creates a new map with a copy of the given config.
func EtagCheck ¶
EtagCheck validates the hash of the current state with the hash provided by the client
func FilesystemDetect ¶
FilesystemDetect returns the filesystem on which the passed-in path sits.
func GenerateSequenceInt64 ¶
GenerateSequenceInt64 returns a sequence within a given range with given steps.
func GetArchitectures ¶
GetArchitectures returns the list of supported architectures.
func GetListeners ¶
GetListeners returns the socket-activated network listeners, if any.
The 'start' parameter must be SystemdListenFDsStart, except in unit tests, see the docstring of SystemdListenFDsStart below.
func GetStableRandomGenerator ¶
GetStableRandomGenerator returns a stable random generator. Uses the FNV-1a hash algorithm to convert the seed string into an int64 for use as seed to the non-cryptographic random number generator.
func GetStableRandomInt64FromList ¶
GetStableRandomInt64FromList returns a stable random value from a given list.
func HTTPClient ¶
HTTPClient returns an http.Client using the given certificate and proxy.
func HasFilesystem ¶
HasFilesystem checks whether a given filesystem is already supported by the kernel. Note that if the filesystem is a module, you may need to load it first.
func HugepagesPath ¶
HugepagesPath attempts to locate the mount point of the hugepages filesystem.
func InMemoryNetwork ¶
InMemoryNetwork creates a fully in-memory listener and dial function.
Each time the dial function is invoked a new pair of net.Conn objects will be created using net.Pipe: the listener's Accept method will unblock and return one end of the pipe and the other end will be returned by the dial function.
func IsAddressCovered ¶
IsAddressCovered detects if network address1 is actually covered by address2, in the sense that they are either the same address or address2 is specified using a wildcard with the same port of address1.
func IsJSONRequest ¶
IsJSONRequest returns true if the content type of the HTTP request is JSON.
func IsRecursionRequest ¶
IsRecursionRequest checks whether the given HTTP request is marked with the "recursion" flag in its form values.
func ListenAddresses ¶
ListenAddresses returns a list of host:port combinations at which this machine can be reached
func LoadCert ¶
LoadCert reads the LXD server certificate from the given var dir.
If a cluster certificate is found it will be loaded instead. If neither a server or cluster certfificate exists, a new server certificate will be generated.
func LoadClusterCert ¶
LoadClusterCert reads the LXD cluster certificate from the given var dir.
If a cluster certificate doesn't exist, a new one is generated.
func LoadModule ¶
LoadModule loads the kernel module with the given name, by invoking modprobe.
func LoadServerCert ¶
LoadServerCert reads the LXD server certificate from the given var dir.
func NetworkInterfaceAddress ¶
func NetworkInterfaceAddress() string
NetworkInterfaceAddress returns the first global unicast address of any of the system network interfaces. Return the empty string if none is found.
func PasswordCheck ¶
PasswordCheck validates the provided password against the encoded secret
func RuntimeLiblxcVersionAtLeast ¶
RuntimeLiblxcVersionAtLeast checks if the system's liblxc matches the provided version requirement
func ServerTLSConfig ¶
ServerTLSConfig returns a new server-side tls.Config generated from the give certificate info.
func SplitNTrimSpace ¶
SplitNTrimSpace returns result of strings.SplitN() and then strings.TrimSpace() on each element. Accepts nilIfEmpty argument which if true, will return nil slice if s is empty (after trimming space).
func SysctlSet ¶
SysctlSet writes a value to a sysctl file in /proc/sys. Requires an even number of arguments as key/value pairs. E.g. SysctlSet("path1", "value1", "path2", "value2")