Documentation ¶
Index ¶
- Constants
- func ConfirmECS(file []byte) bool
- func ConfirmSalt(file []byte) bool
- func DecryptConfigFile(configData, key []byte) ([]byte, error)
- func EncryptConfigFile(configData, key []byte) ([]byte, error)
- func GetFilePath(configFile string) (configPath string, isImplicitDefaultPath bool, err error)
- func PromptForConfigKey(initialSetup bool) ([]byte, error)
- func Unencrypted() ([]byte, error)
- type Config
- func (c *Config) LoadConfig(configPath string, dryrun bool) error
- func (c *Config) ReadConfigFromFile(configPath string, dryrun bool) error
- func (c *Config) Save(writerProvider func() (io.Writer, error), keyProvider func() ([]byte, error)) error
- func (c *Config) SaveConfigToFile(configPath string) error
- func (c *Config) UpdateConfig(configPath string, newCfg *Config, dryrun bool) error
- type ConnectionMonitorConfig
Constants ¶
const ( FXProviderFixer = "fixer" EncryptedFile = "config.dat" File = "config.json" TestFile = "../testdata/configtest.json" DefaultAPIKey = "Key" DefaultAPISecret = "Secret" DefaultAPIClientID = "ClientID" DefaultOrderbookPublishPeriod = time.Second * 10 )
Constants declared here are filename strings and test strings
const ( ErrExchangeNameEmpty = "exchange #%d name is empty" ErrNoEnabledExchanges = "no exchanges enabled" ErrFailureOpeningConfig = "fatal error opening %s file. Error: %s" ErrCheckingConfigValues = "fatal error checking config values. Error: %s" WarningExchangeAuthAPIDefaultOrEmptyValues = "exchange %s authenticated API support disabled due to default/empty APIKey/Secret/ClientID values" WarningPairsLastUpdatedThresholdExceeded = "exchange %s last manual update of available currency pairs has exceeded %d days. Manual update required!" )
Constants here hold some messages
const ( APIURLNonDefaultMessage = "NON_DEFAULT_HTTP_LINK_TO_EXCHANGE_API" WebsocketURLNonDefaultMessage = "NON_DEFAULT_HTTP_LINK_TO_WEBSOCKET_EXCHANGE_API" DefaultUnsetAPIKey = "Key" DefaultUnsetAPISecret = "Secret" DefaultUnsetAccountPlan = "accountPlan" DefaultForexProviderExchangeRatesAPI = "ExchangeRateHost" )
Constants here define unset default values displayed in the config.json file
const ( // EncryptConfirmString has a the general confirmation string to allow us to // see if the file is correctly encrypted EncryptConfirmString = "THORS-HAMMER" // SaltPrefix string SaltPrefix = "~GCT~SO~SALTY~" // SaltRandomLength is the number of random bytes to append after the prefix string SaltRandomLength = 12 )
Variables ¶
This section is empty.
Functions ¶
func ConfirmECS ¶
ConfirmECS confirms that the encryption confirmation string is found
func ConfirmSalt ¶
ConfirmSalt checks whether the encrypted data contains a salt
func DecryptConfigFile ¶
DecryptConfigFile decrypts configuration data with the supplied key and returns the un-encrypted data as a byte array with an error
func EncryptConfigFile ¶
EncryptConfigFile encrypts configuration data that is parsed in with a key and returns it as a byte array with an error
func GetFilePath ¶
GetFilePath returns the desired config file or the default config file name and whether it was loaded from a default location (rather than explicitly specified)
func PromptForConfigKey ¶
PromptForConfigKey asks for configuration key if initialSetup is true, the password needs to be repeated
func Unencrypted ¶
Unencrypted provides the default key provider implementation for unencrypted files
Types ¶
type Config ¶
type Config struct { Name string `json:"name"` DataDirectory string `json:"dataDirectory"` EncryptConfig int `json:"encryptConfig"` GlobalHTTPTimeout time.Duration `json:"globalHTTPTimeout"` Database database.Config `json:"database"` Logging log.Config `json:"logging"` // contains filtered or unexported fields }
Config is the overarching object that holds all the information for prestart management of Portfolio, Webserver and Enabled Exchanges
Variables here are used for configuration
func ReadConfig ¶
ReadConfig verifies and checks for encryption and loads the config from a JSON object. Prompts for decryption key, if target data is encrypted. Returns the loaded configuration and whether it was encrypted.
func (*Config) LoadConfig ¶
LoadConfig loads your configuration file into your configuration object
func (*Config) ReadConfigFromFile ¶
ReadConfigFromFile reads the configuration from the given file if target file is encrypted, prompts for encryption key Also - if not in dryrun mode - it checks if the configuration needs to be encrypted and stores the file as encrypted, if necessary (prompting for enryption key)
func (*Config) Save ¶
func (c *Config) Save(writerProvider func() (io.Writer, error), keyProvider func() ([]byte, error)) error
Save saves your configuration to the writer as a JSON object with encryption, if configured If there is an error when preparing the data to store, the writer is never requested
func (*Config) SaveConfigToFile ¶
SaveConfigToFile saves your configuration to your desired path as a JSON object. The function encrypts the data and prompts for encryption key, if necessary
type ConnectionMonitorConfig ¶
type ConnectionMonitorConfig struct { DNSList []string `json:"preferredDNSList"` PublicDomainList []string `json:"preferredDomainList"` CheckInterval time.Duration `json:"checkInterval"` }
ConnectionMonitorConfig defines the connection monitor variables to ensure that there is internet connectivity