Move config.json to config.dat

This commit is contained in:
Adrian Gallagher
2017-03-05 18:51:49 +11:00
parent fed5367240
commit 255bd125c8
4 changed files with 16 additions and 5 deletions

View File

@@ -52,7 +52,7 @@ Please feel free to submit any pull requests or suggest any desired features to
Download Go from https://golang.org/dl/
Using a terminal, type go get github.com/thrasher-/gocryptotrader
Change directory to the package directory, then type go install.
Copy config_example.json to config.json.
Copy config_example.dat to config.dat.
Make any neccessary changes to the config file.
Run the application!

View File

@@ -6,12 +6,14 @@ import (
"fmt"
"io/ioutil"
"log"
"os"
"strconv"
"time"
)
const (
CONFIG_FILE = "config.json"
CONFIG_FILE = "config.dat"
OLD_CONFIG_FILE = "config.json"
CONFIG_FILE_ENCRYPTION_PROMPT = 0
CONFIG_FILE_ENCRYPTION_ENABLED = 1
@@ -36,6 +38,7 @@ var (
WarningWebserverListenAddressInvalid = "WARNING -- Webserver support disabled due to invalid listen address."
WarningWebserverRootWebFolderNotFound = "WARNING -- Webserver support disabled due to missing web folder."
WarningExchangeAuthAPIDefaultOrEmptyValues = "WARNING -- Exchange %s: Authenticated API support disabled due to default/empty APIKey/Secret/ClientID values."
RenamingConfigFile = "Renaming config file %s to %s."
)
type Webserver struct {
@@ -196,6 +199,15 @@ func CheckWebserverValues() error {
}
func ReadConfig() error {
_, err := ioutil.ReadFile(OLD_CONFIG_FILE)
if err == nil {
err = os.Rename(OLD_CONFIG_FILE, CONFIG_FILE)
if err != nil {
return err
}
log.Printf(RenamingConfigFile+"\n", OLD_CONFIG_FILE, CONFIG_FILE)
}
file, err := ioutil.ReadFile(CONFIG_FILE)
if err != nil {
return err
@@ -237,7 +249,6 @@ func ReadConfig() error {
}
func SaveConfig() error {
log.Println("Saving config.")
payload, err := json.MarshalIndent(bot.config, "", " ")
if bot.config.EncryptConfig == CONFIG_FILE_ENCRYPTION_ENABLED {

View File

@@ -36,7 +36,7 @@ func PromptForConfigKey() ([]byte, error) {
var cryptoKey []byte
for len(cryptoKey) != 32 {
log.Println("Please enter your 32 character AES key:")
log.Println("Enter password (32 characters):")
_, err := fmt.Scanln(&cryptoKey)
if err != nil {
@@ -44,7 +44,7 @@ func PromptForConfigKey() ([]byte, error) {
}
if len(cryptoKey) > 32 || len(cryptoKey) < 32 {
fmt.Println("Please re-enter a 32char key:")
fmt.Println("Please re-enter password (32 characters):")
}
}