Merge branch 'ind-bootstrap' into proc-debug

# Conflicts:
#	version.go
This commit is contained in:
David Vennik
2023-01-08 22:24:43 +00:00
8 changed files with 31 additions and 28 deletions

View File

@@ -2,16 +2,16 @@ package main
import ( import (
"context" "context"
"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
"github.com/indra-labs/indra" "github.com/indra-labs/indra"
"github.com/indra-labs/indra/pkg/docker"
"github.com/indra-labs/indra/pkg/app" "github.com/indra-labs/indra/pkg/app"
"github.com/indra-labs/indra/pkg/cmds" "github.com/indra-labs/indra/pkg/cmds"
"github.com/indra-labs/indra/pkg/docker"
log2 "github.com/indra-labs/indra/pkg/log" log2 "github.com/indra-labs/indra/pkg/log"
"github.com/indra-labs/indra/pkg/opts/config" "github.com/indra-labs/indra/pkg/opts/config"
"github.com/indra-labs/indra/pkg/opts/meta" "github.com/indra-labs/indra/pkg/opts/meta"
"github.com/indra-labs/indra/pkg/opts/toggle" "github.com/indra-labs/indra/pkg/opts/toggle"
"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
"os" "os"
"time" "time"
) )
@@ -33,19 +33,19 @@ var commands = &cmds.Command{
Name: "release", Name: "release",
Description: "Builds the indra docker image and pushes it to a list of docker repositories.", Description: "Builds the indra docker image and pushes it to a list of docker repositories.",
Documentation: lorem, Documentation: lorem,
Default: cmds.Tags("release"), Default: cmds.Tags("release"),
Configs: config.Opts{ Configs: config.Opts{
"stable": toggle.New(meta.Data{ "stable": toggle.New(meta.Data{
Label: "stable", Label: "stable",
Description: "tag the current build as stable.", Description: "tag the current build as stable.",
Documentation: lorem, Documentation: lorem,
Default: "false", Default: "false",
}), }),
"push": toggle.New(meta.Data{ "push": toggle.New(meta.Data{
Label: "push", Label: "push",
Description: "push the newly built/tagged images to the docker repositories.", Description: "push the newly built/tagged images to the docker repositories.",
Documentation: lorem, Documentation: lorem,
Default: "false", Default: "false",
}), }),
}, },
Entrypoint: func(command *cmds.Command, args []string) error { Entrypoint: func(command *cmds.Command, args []string) error {
@@ -119,4 +119,4 @@ incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.` culpa qui officia deserunt mollit anim id est laborum.`

View File

@@ -69,8 +69,8 @@ var commands = &cmds.Command{
Documentation: lorem, Documentation: lorem,
Configs: config.Opts{ Configs: config.Opts{
"key": text.New(meta.Data{ "key": text.New(meta.Data{
Label: "key", Label: "key",
Description: "A base58 encoded private key.", Description: "A base58 encoded private key.",
Documentation: lorem, Documentation: lorem,
}), }),
"seed": list.New(meta.Data{ "seed": list.New(meta.Data{
@@ -105,11 +105,11 @@ var commands = &cmds.Command{
server.DefaultConfig.PrivKey = privKey server.DefaultConfig.PrivKey = privKey
for _, listener := range c.GetListValue("listen"){ for _, listener := range c.GetListValue("listen") {
server.DefaultConfig.ListenAddresses = append(server.DefaultConfig.ListenAddresses, multiaddr.StringCast(listener)) server.DefaultConfig.ListenAddresses = append(server.DefaultConfig.ListenAddresses, multiaddr.StringCast(listener))
} }
for _, seed := range c.GetListValue("seed"){ for _, seed := range c.GetListValue("seed") {
server.DefaultConfig.SeedAddresses = append(server.DefaultConfig.SeedAddresses, multiaddr.StringCast(seed)) server.DefaultConfig.SeedAddresses = append(server.DefaultConfig.SeedAddresses, multiaddr.StringCast(seed))
} }

View File

@@ -12,7 +12,7 @@ type DNSSeedAddress struct {
func NewSeedAddress(dns string, id string) *DNSSeedAddress { func NewSeedAddress(dns string, id string) *DNSSeedAddress {
return &DNSSeedAddress{ return &DNSSeedAddress{
ID: id, ID: id,
DNSAddress: dns, DNSAddress: dns,
} }
} }

View File

@@ -29,7 +29,7 @@ func HostStatus(ctx context.Context, host host.Host) {
select { select {
case <- ctx.Done(): case <-ctx.Done():
log.I.Ln("shutting down metrics.hoststatus") log.I.Ln("shutting down metrics.hoststatus")
@@ -40,8 +40,8 @@ func HostStatus(ctx context.Context, host host.Host) {
} }
log.I.Ln("---- host status ----") log.I.Ln("---- host status ----")
log.I.Ln("-- peers:",len(host.Network().Peers())) log.I.Ln("-- peers:", len(host.Network().Peers()))
log.I.Ln("-- connections:",len(host.Network().Conns())) log.I.Ln("-- connections:", len(host.Network().Conns()))
log.I.Ln("---- ---- ------ ----") log.I.Ln("---- ---- ------ ----")
} }
} }

View File

@@ -19,8 +19,9 @@ var (
var ( var (
defaultConnectionAttempts uint = 3 defaultConnectionAttempts uint = 3
defaultConnectionAttemptInterval time.Duration = 10 * time.Second defaultConnectionAttemptInterval = 10 * time.Second
defaultConnectionsMax uint = 32
defaultConnectionsToSatisfy uint = 5 defaultConnectionsToSatisfy uint = 5
) )
@@ -28,7 +29,7 @@ var (
wg sync.WaitGroup wg sync.WaitGroup
m sync.Mutex m sync.Mutex
c context.Context c context.Context
h host.Host = nil h host.Host = nil
failedChan = make(chan error) failedChan = make(chan error)
) )
@@ -42,13 +43,16 @@ func connection_attempt(peer *peer.AddrInfo, attempts_left uint) {
return return
} }
if err := h.Connect(c, *peer); check(err) { if err := h.Connect(c, *peer); err != nil {
log.D.Ln("connection connection_attempt failed:", peer.ID) log.I.Ln("connection attempt failed:", peer.ID)
time.Sleep(defaultConnectionAttemptInterval) select {
case <-time.After(defaultConnectionAttemptInterval):
connection_attempt(peer, attempts_left - 1) connection_attempt(peer, attempts_left-1)
case <-c.Done():
wg.Done()
}
return return
} }

View File

@@ -18,14 +18,13 @@ func NewMultiAddr(addr string) (maddr multiaddr.Multiaddr) {
var DefaultConfig = &Config{ var DefaultConfig = &Config{
ListenAddresses: []multiaddr.Multiaddr{}, ListenAddresses: []multiaddr.Multiaddr{},
SeedAddresses: []multiaddr.Multiaddr{}, SeedAddresses: []multiaddr.Multiaddr{},
} }
type Config struct { type Config struct {
PrivKey crypto.PrivKey PrivKey crypto.PrivKey
PublicAddress multiaddr.Multiaddr PublicAddress multiaddr.Multiaddr
SeedAddresses []multiaddr.Multiaddr SeedAddresses []multiaddr.Multiaddr
ListenAddresses []multiaddr.Multiaddr ListenAddresses []multiaddr.Multiaddr
} }

View File

@@ -20,7 +20,7 @@ var (
) )
var ( var (
userAgent = "/indra:"+indra.SemVer+"/" userAgent = "/indra:" + indra.SemVer + "/"
) )
type Server struct { type Server struct {

View File

@@ -7,7 +7,7 @@ import (
"testing" "testing"
) )
func TestBase58(t *testing.T){ func TestBase58(t *testing.T) {
var err error var err error
var priv1, priv2 crypto.PrivKey var priv1, priv2 crypto.PrivKey