Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ConfigLoaded bool
ConfigLoaded indicates whether the configuration has been successfully loaded.
Functions ¶
func LoadConfig ¶
LoadConfig loads the application configuration from a JSON file.
Parameters:
- configPath: string - The path to the configuration JSON file.
Returns:
- error: An error if the configuration file cannot be loaded or parsed.
Types ¶
type Config ¶
type Config struct {
PrivateKey string `json:"private_key"` // Base64-encoded ECDSA private key
EndpointV4 string `json:"endpoint_v4"` // IPv4 address of the endpoint
EndpointV6 string `json:"endpoint_v6"` // IPv6 address of the endpoint
EndpointPubKey string `json:"endpoint_pub_key"` // PEM-encoded ECDSA public key of the endpoint to verify against
License string `json:"license"` // Application license key
ID string `json:"id"` // Device unique identifier
AccessToken string `json:"access_token"` // Authentication token for API access
IPv4 string `json:"ipv4"` // Assigned IPv4 address
IPv6 string `json:"ipv6"` // Assigned IPv6 address
}
Config represents the application configuration structure, containing essential details such as keys, endpoints, and access tokens.
var AppConfig Config
AppConfig holds the global application configuration.
func (*Config) GetEcEndpointPublicKey ¶
GetEcEndpointPublicKey retrieves the ECDSA public key from the stored PEM-encoded string.
Returns:
- *ecdsa.PublicKey: The parsed ECDSA public key.
- error: An error if decoding or parsing the public key fails.
func (*Config) GetEcPrivateKey ¶
func (*Config) GetEcPrivateKey() (*ecdsa.PrivateKey, error)
GetEcPrivateKey retrieves the ECDSA private key from the stored Base64-encoded string.
Returns:
- *ecdsa.PrivateKey: The parsed ECDSA private key.
- error: An error if decoding or parsing the private key fails.
func (*Config) SaveConfig ¶
SaveConfig writes the current application configuration to a prettified JSON file.
Parameters:
- configPath: string - The path to save the configuration JSON file.
Returns:
- error: An error if the configuration file cannot be written.
Click to show internal directories.
Click to hide internal directories.