From c6283ea33a26bc664c5f31872b76142f22ec613f Mon Sep 17 00:00:00 2001 From: l0k18 Date: Tue, 20 Jun 2023 14:14:09 +0100 Subject: [PATCH] mainly cosmetic tweaks in seed mode operation --- pkg/p2p/introducer/bootstrap.go | 8 +++-- pkg/p2p/metrics/host.go | 10 +++--- pkg/storage/configure.go | 58 ++++++++++++++++----------------- 3 files changed, 40 insertions(+), 36 deletions(-) diff --git a/pkg/p2p/introducer/bootstrap.go b/pkg/p2p/introducer/bootstrap.go index bee7e68b..50146a64 100644 --- a/pkg/p2p/introducer/bootstrap.go +++ b/pkg/p2p/introducer/bootstrap.go @@ -3,6 +3,7 @@ package introducer import ( "context" "errors" + "fmt" record "github.com/libp2p/go-libp2p-record" "sync" @@ -47,13 +48,14 @@ func Bootstrap(ctx context.Context, host host.Host, seeds []multiaddr.Multiaddr) c = ctx h = host - log.I.Ln("using seeds:") + + o := "using seeds:\n\n" var bootstrapPeer *peer.AddrInfo for _, seed := range seeds { - log.I.Ln("-", seed.String()) + o+=fmt.Sprintln("-", seed.String()) if bootstrapPeer, err = peer.AddrInfoFromP2pAddr(seed); check(err) { return @@ -67,6 +69,8 @@ func Bootstrap(ctx context.Context, host host.Host, seeds []multiaddr.Multiaddr) bootstrapPeers = append(bootstrapPeers, *bootstrapPeer) } + log.I.Ln(o) + var options = []dht.Option{ dht.Mode(dht.ModeServer), dht.ProtocolPrefix(protocolPrefix), diff --git a/pkg/p2p/metrics/host.go b/pkg/p2p/metrics/host.go index c41ad2d7..61dc0129 100644 --- a/pkg/p2p/metrics/host.go +++ b/pkg/p2p/metrics/host.go @@ -43,11 +43,11 @@ func HostStatus(ctx context.Context, host host.Host) { select { case <-time.After(hostStatusInterval): - log.I.Ln() - log.I.Ln("---- host status ----") - log.I.Ln("-- peers:", len(host.Network().Peers())) - log.I.Ln("-- connections:", len(host.Network().Conns())) - log.I.Ln("---- ---- ------ ----") + log.I.Ln(` +---- host status ---- +-- peers:`, len(host.Network().Peers()),` +-- connections:`, len(host.Network().Conns()),` +`) case <-ctx.Done(): diff --git a/pkg/storage/configure.go b/pkg/storage/configure.go index 8a07a990..8e9e4feb 100644 --- a/pkg/storage/configure.go +++ b/pkg/storage/configure.go @@ -83,35 +83,35 @@ func configureKey() { return } - log.W.Ln("") - log.W.Ln("--------------------------------------------------------") - log.W.Ln("--") - log.W.Ln("-- WARNING: The following key will be used to store") - log.W.Ln("-- your database securely, please ensure that you make") - log.W.Ln("-- a copy and store it in a secure place before using") - log.W.Ln("-- this software in a production environment.") - log.W.Ln("--") - log.W.Ln("--") - log.W.Ln("-- Failure to store this key properly will result in") - log.W.Ln("-- no longer being able to decrypt this database.") - log.W.Ln("--") - log.W.Ln("--") - log.W.Ln("-- It is recommended to use the following to generate") - log.W.Ln("-- your key:") - log.W.Ln("--") - log.W.Ln("-- indra seed keygen") - log.W.Ln("--") - log.W.Ln("-- OR") - log.W.Ln("--") - log.W.Ln("-- indra seed keygen --keyfile=/path/to/keyfile") - log.W.Ln("--") - log.W.Ln("--") - log.W.Ln("-- YOU HAVE BEEN WARNED!") - log.W.Ln("--") - log.W.Ln("-------------------------------------------------------") - log.W.Ln("-- KEY:", key.Encode(), "--") - log.W.Ln("-------------------------------------------------------") - log.W.Ln("") + log.W.Ln(` +-------------------------------------------------------- +-- +-- WARNING: The following key will be used to store +-- your database securely, please ensure that you make +-- a copy and store it in a secure place before using +-- this software in a production environment. +-- +-- +-- Failure to store this key properly will result in +-- no longer being able to decrypt this database. +-- +-- +-- It is recommended to use the following to generate +-- your key: +-- +-- indra seed keygen +-- +-- OR +-- +-- indra seed keygen --keyfile=/path/to/keyfile +-- +-- +-- YOU HAVE BEEN WARNED! +-- +------------------------------------------------------- +-- KEY:`, key.Encode(), `-- +------------------------------------------------------- +`) newKeyGenerated = true