From 9a853fdf9001577610d0a1a2e2e2919769fb359a Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Tue, 19 Nov 2013 11:37:22 -0600 Subject: [PATCH] Use single cert/key for RPC by default. Also, while here, set the default RPC cert/key in the initial config struct so the default will show when displaying the usage. --- config.go | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/config.go b/config.go index b7532d51..d289f671 100644 --- a/config.go +++ b/config.go @@ -31,11 +31,13 @@ const ( ) var ( - btcdHomeDir = btcutil.AppDataDir("btcd", false) - defaultConfigFile = filepath.Join(btcdHomeDir, defaultConfigFilename) - defaultDataDir = filepath.Join(btcdHomeDir, defaultDataDirname) - defaultListener = net.JoinHostPort("", netParams(defaultBtcnet).listenPort) - knownDbTypes = btcdb.SupportedDBs() + btcdHomeDir = btcutil.AppDataDir("btcd", false) + defaultConfigFile = filepath.Join(btcdHomeDir, defaultConfigFilename) + defaultDataDir = filepath.Join(btcdHomeDir, defaultDataDirname) + defaultListener = net.JoinHostPort("", netParams(defaultBtcnet).listenPort) + knownDbTypes = btcdb.SupportedDBs() + defaultRPCKeyFile = filepath.Join(btcdHomeDir, "rpc.key") + defaultRPCCertFile = filepath.Join(btcdHomeDir, "rpc.cert") ) // config defines the configuration options for btcd. @@ -180,6 +182,8 @@ func loadConfig() (*config, []string, error) { ConfigFile: defaultConfigFile, DataDir: defaultDataDir, DbType: defaultDbType, + RPCKey: defaultRPCKeyFile, + RPCCert: defaultRPCCertFile, } // Pre-parse the command line options to see if an alternative config @@ -342,13 +346,6 @@ func loadConfig() (*config, []string, error) { } } - if cfg.RPCKey == "" { - cfg.RPCKey = filepath.Join(cfg.DataDir, "rpc.key") - } - if cfg.RPCCert == "" { - cfg.RPCCert = filepath.Join(cfg.DataDir, "rpc.cert") - } - // Add default port to all listener addresses if needed and remove // duplicate addresses. cfg.Listeners = normalizeAddresses(cfg.Listeners,