testing environment vars, config file and arguments.

This commit is contained in:
greg stone
2023-02-15 17:12:23 +00:00
parent d5d4021443
commit 587e74ac59
4 changed files with 19 additions and 27 deletions

View File

@@ -114,7 +114,7 @@ func initConfig() {
func persistConfig() {
if !viper.GetBool("config-save") {
if !cfgSave {
return
}

View File

@@ -5,7 +5,6 @@ import (
"git-indra.lan/indra-labs/indra/pkg/cfg"
log2 "git-indra.lan/indra-labs/indra/pkg/proc/log"
"git-indra.lan/indra-labs/indra/pkg/server"
"github.com/davecgh/go-spew/spew"
"github.com/multiformats/go-multiaddr"
"github.com/spf13/cobra"
"github.com/spf13/viper"
@@ -39,8 +38,6 @@ var seedCmd = &cobra.Command{
Long: `Serves an instance of the seed node.`,
Run: func(cmd *cobra.Command, args []string) {
spew.Dump(viper.AllSettings())
log.I.Ln("-- ", log2.App, "("+viper.GetString("network")+") -", indra.SemVer, "- Network Freedom. --")
var err error

View File

@@ -2,7 +2,6 @@ package server
import (
"context"
"github.com/davecgh/go-spew/spew"
"time"
"github.com/libp2p/go-libp2p"
@@ -100,8 +99,6 @@ func New(params *cfg.Params, config *Config) (srv *Server, err error) {
s.params = params
s.config = config
spew.Dump(config.PrivKey)
if s.host, err = libp2p.New(libp2p.Identity(config.PrivKey), libp2p.UserAgent(userAgent), libp2p.ListenAddrs(config.ListenAddresses...)); check(err) {
return nil, err
}

View File

@@ -4,10 +4,9 @@ import (
"github.com/btcsuite/btcd/btcutil/base58"
"github.com/btcsuite/btcd/btcutil/bech32"
"github.com/libp2p/go-libp2p/core/crypto"
"github.com/spf13/viper"
)
var hnd = "ind"
func bech32encode(key crypto.PrivKey) (keyStr string, err error) {
var raw []byte
@@ -82,23 +81,22 @@ func Base58Decode(key string) (priv crypto.PrivKey, err error) {
func GetOrGeneratePrivKey(key string) (privKey crypto.PrivKey, err error) {
//if key == "" {
//
// privKey = server.GeneratePrivKey()
//
// if key, err = server.Base58Encode(privKey); check(err) {
// return
// }
//}
//
//if privKey, err = server.Base58Decode(key); check(err) {
// return
//}
//
//spew.Dump(key)
//spew.Dump(privKey)
//
//server.DefaultConfig.PrivKey = privKey
if key == "" {
return nil, nil
privKey = GeneratePrivKey()
if key, err = Base58Encode(privKey); check(err) {
return
}
viper.Set("key", key)
return
}
if privKey, err = Base58Decode(key); check(err) {
return
}
return
}