Documentation
¶
Overview ¶
Package config provides functions for reading the config.
Package config provides functions for reading the config.
Package config provides functions for reading the config.
Index ¶
- Constants
- Variables
- func CheckConfig()
- func Convert(h *Config, n *Node) (models.Host, models.Node)
- func ConvertOldNode(netmakerNode *models.LegacyNode) (*Node, *Config)
- func ConvertToNetmakerNode(node *Node, server *Server, host *Config) *models.LegacyNode
- func DeleteNode(k string)
- func DeleteServer(k string)
- func DeleteServerHostPeerCfg(server string)
- func FirewallHasChanged() bool
- func FormatBool(b bool) string
- func FormatName(name string) string
- func GetHostPeerList() (allPeers []wgtypes.PeerConfig)
- func GetNetclientInstallPath() string
- func GetNetclientPath() string
- func GetServers() (servers []string)
- func GetSystemNetworks() ([]string, error)
- func InCharSet(name string) bool
- func InitConfig(viper *viper.Viper)
- func IsHostInetGateway() bool
- func IsPidDead(pid int) bool
- func Lock(lockfile string) error
- func ModPort(host *Config) error
- func OldAuthenticate(node *Node, host *Config) (string, error)
- func ParseAccessToken(token string) (*models.AccessToken, error)
- func ParseBool(s string) bool
- func ReadNodeConfig() error
- func ReadServerConf() error
- func RemoveServerHostPeerCfg(serverName string)
- func SaveServer(name string, server Server) error
- func SetFirewall()
- func SetGUI(a, p string)
- func SetVersion(ver string)
- func ToIPNet(cidr string) net.IPNet
- func ToUDPAddr(address string) *net.UDPAddr
- func Unlock(lockfile string) error
- func UpdateHost(newHost *models.Host)
- func UpdateHostPeers(server string, peers []wgtypes.PeerConfig) (isHostInetGW bool)
- func UpdateNetclient(c Config)
- func UpdateNodeMap(k string, value Node)
- func UpdateServer(name string, server Server)
- func UpdateServerConfig(cfg *models.ServerConfig)
- func WriteGUIConfig() error
- func WriteNetclientConfig() error
- func WriteNodeConfig() error
- func WriteServerConfig() error
- type ClientConfig
- type Config
- type Gui
- type Node
- type NodeMap
- type OldNetmakerServerConfig
- type Server
- type TurnConfig
Constants ¶
const ( // LinuxAppDataPath - linux path LinuxAppDataPath = "/etc/netclient/" // MacAppDataPath - mac path MacAppDataPath = "/Applications/Netclient/" // WindowsAppDataPath - windows path WindowsAppDataPath = "C:\\Program Files (x86)\\Netclient\\" // Timeout timelimit for obtaining/releasing lockfile Timeout = time.Second * 5 // ConfigLockfile lockfile to control access to config file ConfigLockfile = "config.lck" // MaxNameLength maximum length of a node name MaxNameLength = 62 // DefaultListenPort default port for wireguard DefaultListenPort = 51821 // DefaultMTU default MTU for wireguard DefaultMTU = 1420 )
const GUILockFile = "gui.lock"
GUILockeFile lockfile for controlling access to gui config file on disk
const NodeLockfile = "netclient-nodes.lck"
NodeLockFile is name of lockfile for controlling access to node config file on disk
const ServerLockfile = "netclient-servers.lck"
ServerLockFile is a lockfile for controlling access to the server map file on disk
Variables ¶
var ( // Version - default version string Version = "dev" // GW4PeerDetected - indicates if an IPv4 gwPeer (0.0.0.0/0) was found GW4PeerDetected bool // GW4Addr - the peer's address for IPv4 gateways GW4Addr net.IPNet // GW6PeerDetected - indicates if an IPv6 gwPeer (::/0) was found, currently unused GW6PeerDetected bool // GW6Addr - the peer's address for IPv6 gateways GW6Addr net.IPNet // WgPublicListenPort - host's wireguard public listen port WgPublicListenPort int )
var ServerNodes map[string]struct{}
ServerNodes is a map of node names for a server
var Servers map[string]Server
Servers is map of servers indexed by server name
Functions ¶
func ConvertOldNode ¶
func ConvertOldNode(netmakerNode *models.LegacyNode) (*Node, *Config)
ConvertOldNode accepts a netmaker node struct and converts to the structs used by netclient
func ConvertToNetmakerNode ¶
func ConvertToNetmakerNode(node *Node, server *Server, host *Config) *models.LegacyNode
ConvertToNetmakerNode converts a netclient node to a netmaker node
func DeleteNode ¶
func DeleteNode(k string)
DeleteNode deletes the node from the nodemap for the specified network
func DeleteServer ¶
func DeleteServer(k string)
DeleteServer deletes the specified server name from the server map
func DeleteServerHostPeerCfg ¶
func DeleteServerHostPeerCfg(server string)
DeleteServerHostPeerCfg - deletes the host peers for the server
func FirewallHasChanged ¶ added in v0.19.0
func FirewallHasChanged() bool
FirewallHasChanged - checks if the firewall has changed
func FormatName ¶
FormatName ensures name is in character set and is proper length Sets name to blank on failure
func GetHostPeerList ¶
func GetHostPeerList() (allPeers []wgtypes.PeerConfig)
GetHostPeerList - gets the combined list of peers for the host
func GetNetclientInstallPath ¶
func GetNetclientInstallPath() string
GetNetclientInstallPath returns the full path where netclient should be installed based on OS
func GetNetclientPath ¶
func GetNetclientPath() string
GetNetclientPath - returns path to netclient config directory
func GetServers ¶
func GetServers() (servers []string)
GetServers - gets all the server names host has registered to.
func GetSystemNetworks ¶
GetSystemNetworks - get networks for older version (pre v0.18.0) of netclient
func InitConfig ¶
InitConfig reads in config file and ENV variables if set.
func IsHostInetGateway ¶ added in v0.18.7
func IsHostInetGateway() bool
IsHostInetGateway - checks, based on netclient memory, if current client is an internet gateway
func Lock ¶
Lock creates a lockfile with pid as contents if lockfile exists but belongs to defunct process the existing lockfile will be deleted and new one created if unable to create within TIMEOUT returns error
func OldAuthenticate ¶
OldAuthenticate authenticates with netmaker api to permit subsequent interactions with the api
func ParseAccessToken ¶
func ParseAccessToken(token string) (*models.AccessToken, error)
ParseAccessToken - decodes base64 encoded access token
func ReadServerConf ¶
func ReadServerConf() error
ReadServerConf reads the servers configuration file and populates the server map
func RemoveServerHostPeerCfg ¶ added in v0.18.4
func RemoveServerHostPeerCfg(serverName string)
RemoveServerHostPeerCfg - sets remove flag for all peers on the given server peers
func SaveServer ¶
SaveServer updates the server map with current server struct and writes map to disk
func SetFirewall ¶ added in v0.19.0
func SetFirewall()
setFirewall - determine and record firewall in use
func Unlock ¶
Unlock removes a lockfile if contents of lockfile match current pid also removes lockfile if owner process is no longer running will return TIMEOUT error if timeout exceeded
func UpdateHost ¶ added in v0.18.4
UpdateHost - update host with data from server
func UpdateHostPeers ¶
func UpdateHostPeers(server string, peers []wgtypes.PeerConfig) (isHostInetGW bool)
UpdateHostPeers - updates host peer map in the netclient config
func UpdateNetclient ¶
func UpdateNetclient(c Config)
UpdateNetcllient updates the in memory version of the host configuration
func UpdateNodeMap ¶
UpdateNodeMap updates the in memory nodemap for the specified network
func UpdateServer ¶
UpdateServer updates the in-memory server map
func UpdateServerConfig ¶
func UpdateServerConfig(cfg *models.ServerConfig)
UpdateServerConfig updates the in memory server map with values provided from netmaker server
func WriteGUIConfig ¶ added in v0.19.0
func WriteGUIConfig() error
WriteGUIConfiig writes the in memory gui configuration to disk
func WriteNetclientConfig ¶
func WriteNetclientConfig() error
WriteNetclientConfiig writes the in memory host configuration to disk
Types ¶
type ClientConfig ¶
type ClientConfig struct {
Server OldNetmakerServerConfig `yaml:"server"`
Node models.LegacyNode `yaml:"node"`
NetworkSettings models.Network `yaml:"networksettings"`
Network string `yaml:"network"`
Daemon string `yaml:"daemon"`
OperatingSystem string `yaml:"operatingsystem"`
AccessKey string `yaml:"accesskey"`
PublicIPService string `yaml:"publicipservice"`
SsoServer string `yaml:"sso"`
}
ClientConfig - struct for dealing with client configuration
func ReadConfig ¶
func ReadConfig(network string) (*ClientConfig, error)
ReadConfig - reads a config of a older version of client from disk for specified network
type Config ¶
type Config struct {
models.Host
PrivateKey wgtypes.Key `json:"privatekey" yaml:"privatekey"`
TrafficKeyPrivate []byte `json:"traffickeyprivate" yaml:"traffickeyprivate"`
HostPeers map[string][]wgtypes.PeerConfig `json:"peers" yaml:"peers"`
}
Config configuration for netclient and host as a whole
func Netclient ¶
func Netclient() *Config
Netclient returns a pointer to the im memory version of the host configuration
func ReadNetclientConfig ¶
ReadNetclientConfig reads the host configuration file and returns it as an instance.
type Gui ¶ added in v0.19.0
Gui - gui configuration
func ReadGUIConfig ¶ added in v0.19.0
ReadGUIConfig reads the host configuration file and returns it as an instance.
type Node ¶
type Node struct {
models.CommonNode
}
Node provides configuration of a node
func ConvertNode ¶
ConvertNode accepts a netmaker node struct and converts to the structs used by netclient
func GetNodesByServer ¶ added in v0.18.4
GetNodesByServer returns a copy of nodes that belong to a certain server
func (*Node) PrimaryAddress ¶
PrimaryAddress returns the primary address of a node
type NodeMap ¶
NodeMap is an in memory map of the all nodes indexed by network name
var Nodes NodeMap
Nodes provides a map of node configurations indexed by network name
type OldNetmakerServerConfig ¶
type OldNetmakerServerConfig struct {
CoreDNSAddr string `yaml:"corednsaddr"`
API string `yaml:"api"`
APIPort string `yaml:"apiport"`
ClientMode string `yaml:"clientmode"`
DNSMode string `yaml:"dnsmode"`
Version string `yaml:"version"`
MQPort string `yaml:"mqport"`
Server string `yaml:"server"`
Is_EE bool `yaml:"isee"`
}
OldNetmakerServerConfig - pre v0.18.0 server configuration
type Server ¶
type Server struct {
models.ServerConfig
Name string `json:"name" yaml:"name"`
MQID uuid.UUID `json:"mqid" yaml:"mqid"`
Nodes map[string]bool `json:"nodes" yaml:"nodes"`
AccessKey string `json:"accesskey" yaml:"accesskey"`
}
Server represents a server configuration
func ConvertOldServerCfg ¶
func ConvertOldServerCfg(cfg *models.ServerConfig) *Server
ConvertOldServerCfg converts a netmaker ServerConfig to netclient server struct
func ConvertServerCfg ¶
func ConvertServerCfg(cfg *OldNetmakerServerConfig) *Server
ConvertServerCfg converts a netmaker ServerConfig to netclient server struct
type TurnConfig ¶ added in v0.19.0
TurnConfig - struct to hold turn server config
func GetAllTurnConfigs ¶ added in v0.19.0
func GetAllTurnConfigs() (turnList []TurnConfig)
GetAllTurnConfigs - fetches all turn configs from all servers