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.
This commit is contained in:
Dave Collins 2013-11-19 11:37:22 -06:00
parent 6fcc1c9d1b
commit 9a853fdf90

View file

@ -31,11 +31,13 @@ const (
) )
var ( var (
btcdHomeDir = btcutil.AppDataDir("btcd", false) btcdHomeDir = btcutil.AppDataDir("btcd", false)
defaultConfigFile = filepath.Join(btcdHomeDir, defaultConfigFilename) defaultConfigFile = filepath.Join(btcdHomeDir, defaultConfigFilename)
defaultDataDir = filepath.Join(btcdHomeDir, defaultDataDirname) defaultDataDir = filepath.Join(btcdHomeDir, defaultDataDirname)
defaultListener = net.JoinHostPort("", netParams(defaultBtcnet).listenPort) defaultListener = net.JoinHostPort("", netParams(defaultBtcnet).listenPort)
knownDbTypes = btcdb.SupportedDBs() knownDbTypes = btcdb.SupportedDBs()
defaultRPCKeyFile = filepath.Join(btcdHomeDir, "rpc.key")
defaultRPCCertFile = filepath.Join(btcdHomeDir, "rpc.cert")
) )
// config defines the configuration options for btcd. // config defines the configuration options for btcd.
@ -180,6 +182,8 @@ func loadConfig() (*config, []string, error) {
ConfigFile: defaultConfigFile, ConfigFile: defaultConfigFile,
DataDir: defaultDataDir, DataDir: defaultDataDir,
DbType: defaultDbType, DbType: defaultDbType,
RPCKey: defaultRPCKeyFile,
RPCCert: defaultRPCCertFile,
} }
// Pre-parse the command line options to see if an alternative config // 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 // Add default port to all listener addresses if needed and remove
// duplicate addresses. // duplicate addresses.
cfg.Listeners = normalizeAddresses(cfg.Listeners, cfg.Listeners = normalizeAddresses(cfg.Listeners,