btcctl: Inherit notls config from btcd.conf
This commit is contained in:
parent
1fee394e08
commit
45967f8641
1 changed files with 14 additions and 2 deletions
|
@ -309,6 +309,13 @@ func createDefaultConfigFile(destinationPath string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Extract the notls
|
||||||
|
noTLSRegexp, err := regexp.Compile(`(?m)^\s*notls=(0|1)(?:\s|$)`)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
noTLSSubmatches := noTLSRegexp.FindSubmatch(content)
|
||||||
|
|
||||||
// Create the destination directory if it does not exists
|
// Create the destination directory if it does not exists
|
||||||
err = os.MkdirAll(filepath.Dir(destinationPath), 0700)
|
err = os.MkdirAll(filepath.Dir(destinationPath), 0700)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -323,8 +330,13 @@ func createDefaultConfigFile(destinationPath string) error {
|
||||||
}
|
}
|
||||||
defer dest.Close()
|
defer dest.Close()
|
||||||
|
|
||||||
dest.WriteString(fmt.Sprintf("rpcuser=%s\nrpcpass=%s",
|
destString := fmt.Sprintf("rpcuser=%s\nrpcpass=%s\n",
|
||||||
string(userSubmatches[1]), string(passSubmatches[1])))
|
string(userSubmatches[1]), string(passSubmatches[1]))
|
||||||
|
if noTLSSubmatches != nil {
|
||||||
|
destString += fmt.Sprintf("notls=%s\n", noTLSSubmatches[1])
|
||||||
|
}
|
||||||
|
|
||||||
|
dest.WriteString(destString)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue