Expand several more config options.
This adds home directory and OS environment variable expansion for the following configuration options: configfile, appdatadir, rpccert, rpckey.
This commit is contained in:
parent
f91303f507
commit
178717341e
1 changed files with 5 additions and 1 deletions
|
@ -283,7 +283,8 @@ func loadConfig() (*config, []string, error) {
|
||||||
// Load additional config from file.
|
// Load additional config from file.
|
||||||
var configFileError error
|
var configFileError error
|
||||||
parser := flags.NewParser(&cfg, flags.Default)
|
parser := flags.NewParser(&cfg, flags.Default)
|
||||||
err = flags.NewIniParser(parser).ParseFile(preCfg.ConfigFile)
|
configFilePath := cleanAndExpandPath(preCfg.ConfigFile)
|
||||||
|
err = flags.NewIniParser(parser).ParseFile(configFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if _, ok := err.(*os.PathError); !ok {
|
if _, ok := err.(*os.PathError); !ok {
|
||||||
fmt.Fprintln(os.Stderr, err)
|
fmt.Fprintln(os.Stderr, err)
|
||||||
|
@ -323,6 +324,7 @@ func loadConfig() (*config, []string, error) {
|
||||||
// relative to the data dir are unchanged, modify each path to be
|
// relative to the data dir are unchanged, modify each path to be
|
||||||
// relative to the new data dir.
|
// relative to the new data dir.
|
||||||
if cfg.AppDataDir != defaultAppDataDir {
|
if cfg.AppDataDir != defaultAppDataDir {
|
||||||
|
cfg.AppDataDir = cleanAndExpandPath(cfg.AppDataDir)
|
||||||
if cfg.RPCKey == defaultRPCKeyFile {
|
if cfg.RPCKey == defaultRPCKeyFile {
|
||||||
cfg.RPCKey = filepath.Join(cfg.AppDataDir, "rpc.key")
|
cfg.RPCKey = filepath.Join(cfg.AppDataDir, "rpc.key")
|
||||||
}
|
}
|
||||||
|
@ -613,6 +615,8 @@ func loadConfig() (*config, []string, error) {
|
||||||
|
|
||||||
// Expand environment variable and leading ~ for filepaths.
|
// Expand environment variable and leading ~ for filepaths.
|
||||||
cfg.CAFile = cleanAndExpandPath(cfg.CAFile)
|
cfg.CAFile = cleanAndExpandPath(cfg.CAFile)
|
||||||
|
cfg.RPCCert = cleanAndExpandPath(cfg.RPCCert)
|
||||||
|
cfg.RPCKey = cleanAndExpandPath(cfg.RPCKey)
|
||||||
|
|
||||||
// If the btcd username or password are unset, use the same auth as for
|
// If the btcd username or password are unset, use the same auth as for
|
||||||
// the client. The two settings were previously shared for btcd and
|
// the client. The two settings were previously shared for btcd and
|
||||||
|
|
Loading…
Reference in a new issue