From dbd32c2b29ac124dd9a15de7a0fd117c77ec0650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D1=85=D0=B5=D1=80=D0=B5=D1=82=D0=B8=D0=BA?= <херетик@indra.org> Date: Thu, 15 Jun 2023 15:29:24 +0100 Subject: [PATCH] some fixes for ci/notci --- cmd/docker/release/main.go | 39 ++++++++++++------------ pkg/engine/dispatcher/dispatcher.go | 9 +++--- pkg/engine/dispatcher/dispatcher_test.go | 8 +++-- pkg/engine/peerstore.go | 13 +++++--- pkg/onions/adpeer/peer_test.go | 5 ++- version.go | 2 +- 6 files changed, 40 insertions(+), 36 deletions(-) diff --git a/cmd/docker/release/main.go b/cmd/docker/release/main.go index 5b2864a4..5d94f88d 100644 --- a/cmd/docker/release/main.go +++ b/cmd/docker/release/main.go @@ -2,10 +2,9 @@ package main import ( "context" - + "github.com/docker/docker/client" - - "github.com/indra-labs/indra" + "github.com/indra-labs/indra/pkg/docker" "github.com/indra-labs/indra/pkg/proc/app" "github.com/indra-labs/indra/pkg/proc/cmds" @@ -13,7 +12,7 @@ import ( "github.com/indra-labs/indra/pkg/proc/opts/config" "github.com/indra-labs/indra/pkg/proc/opts/meta" "github.com/indra-labs/indra/pkg/proc/opts/toggle" - + "os" "time" ) @@ -54,66 +53,66 @@ var commands = &cmds.Command{ }), }, Entrypoint: func(command *cmds.Command, args []string) error { - + // If we've flagged stable, we should also build a stable tag if command.GetValue("stable").Bool() { docker.SetRelease() } - + // If we've flagged push, the tags will be pushed to all repositories. if command.GetValue("push").Bool() { docker.SetPush() } - + // Set a Timeout for 120 seconds ctx, cancel := context.WithTimeout(context.Background(), defaultBuildingTimeout) defer cancel() - + // Setup a new instance of the docker client - + var err error var cli *client.Client - + if cli, err = client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation()); check(err) { return err } - + defer cli.Close() - + // Get ready to submit the builds var builder = docker.NewBuilder(ctx, cli, sourceConfigurations, buildConfigurations, packagingConfigurations) - + if err = builder.Build(); check(err) { return err } - + if err = builder.Push(); check(err) { return err } - + if err = builder.Close(); check(err) { return err } - + return nil }, } func main() { - + var err error var application *app.App - + // Creates a new application if application, err = app.New(commands, os.Args); check(err) { os.Exit(1) } - + // Launches the application if err = application.Launch(); check(err) { os.Exit(1) } - + os.Exit(0) } diff --git a/pkg/engine/dispatcher/dispatcher.go b/pkg/engine/dispatcher/dispatcher.go index b8fb4911..06b923d3 100644 --- a/pkg/engine/dispatcher/dispatcher.go +++ b/pkg/engine/dispatcher/dispatcher.go @@ -2,6 +2,10 @@ package dispatcher import ( "context" + "math/big" + "sync" + "time" + "github.com/VividCortex/ewma" "github.com/gookit/color" "github.com/indra-labs/indra/pkg/crypto" @@ -17,9 +21,6 @@ import ( "github.com/indra-labs/indra/pkg/util/splice" "github.com/libp2p/go-libp2p/p2p/protocol/ping" "go.uber.org/atomic" - "math/big" - "sync" - "time" ) const ( @@ -641,7 +642,7 @@ func NewDispatcher(l *transport.Conn, ctx context.Context, d.rekeying.Store(false) d.ip = blue(d.Conn.RemoteMultiaddr()) var e error - prk := d.Conn.LocalPrivateKey() + prk := d.Conn.RemotePublicKey() var rprk slice.Bytes if rprk, e = prk.Raw(); fails(e) { return diff --git a/pkg/engine/dispatcher/dispatcher_test.go b/pkg/engine/dispatcher/dispatcher_test.go index b3fd1740..3030229f 100644 --- a/pkg/engine/dispatcher/dispatcher_test.go +++ b/pkg/engine/dispatcher/dispatcher_test.go @@ -2,14 +2,15 @@ package dispatcher import ( "context" + "os" + "testing" + "time" + "github.com/indra-labs/indra" "github.com/indra-labs/indra/pkg/engine" "github.com/indra-labs/indra/pkg/onions/confirmation" "github.com/indra-labs/indra/pkg/onions/ont" "github.com/indra-labs/indra/pkg/onions/response" - "os" - "testing" - "time" "github.com/indra-labs/indra/pkg/util/slice" "github.com/indra-labs/indra/pkg/util/splice" @@ -23,6 +24,7 @@ import ( ) func TestDispatcher(t *testing.T) { + t.Log(indra.CI) if indra.CI=="false" { log2.SetLogLevel(log2.Trace) log.D.Ln("debug") diff --git a/pkg/engine/peerstore.go b/pkg/engine/peerstore.go index 0bf0d6bd..67c20101 100644 --- a/pkg/engine/peerstore.go +++ b/pkg/engine/peerstore.go @@ -4,6 +4,8 @@ import ( "context" "errors" "fmt" + "reflect" + "github.com/indra-labs/indra/pkg/ad" "github.com/indra-labs/indra/pkg/onions/adaddress" "github.com/indra-labs/indra/pkg/onions/adintro" @@ -13,17 +15,18 @@ import ( "github.com/indra-labs/indra/pkg/onions/reg" "github.com/indra-labs/indra/pkg/util/splice" pubsub "github.com/libp2p/go-libp2p-pubsub" - "reflect" ) func (ng *Engine) SendAd(a ad.Ad) (e error) { return ng.topic.Publish(ng.ctx, ont.Encode(a).GetAll()) } -func (ng *Engine) RunAdHandler(handler func(p *pubsub.Message, ctx context.Context) (e error)) { - // Since the frequency of updates should be around 1 hour we run here only one - // thread here. Relays indicate their loading as part of the response message - // protocol for ranking in the session cache. +func (ng *Engine) RunAdHandler(handler func(p *pubsub.Message, + ctx context.Context) (e error)) { + + // Since the frequency of updates should be around 1 hour we run here only + // one thread here. Relays indicate their loading as part of the response + // message protocol for ranking in the session cache. go func(ng *Engine) { out: for { diff --git a/pkg/onions/adpeer/peer_test.go b/pkg/onions/adpeer/peer_test.go index 3fbec8e5..202c5e00 100644 --- a/pkg/onions/adpeer/peer_test.go +++ b/pkg/onions/adpeer/peer_test.go @@ -1,7 +1,8 @@ package adpeer import ( - "fmt" + "testing" + "github.com/indra-labs/indra" "github.com/indra-labs/indra/pkg/crypto" "github.com/indra-labs/indra/pkg/crypto/nonce" @@ -9,13 +10,11 @@ import ( "github.com/indra-labs/indra/pkg/onions/reg" log2 "github.com/indra-labs/indra/pkg/proc/log" "github.com/indra-labs/indra/pkg/util/splice" - "testing" ) func TestPeerAd(t *testing.T) { if indra.CI != "false" { log2.SetLogLevel(log2.Trace) - fmt.Println("logging") } var e error pr, ks, _ := crypto.NewSigner() diff --git a/version.go b/version.go index 7ca8ba39..65147297 100644 --- a/version.go +++ b/version.go @@ -34,7 +34,7 @@ const ( Patch = 14 ) -var CI = "false" +var CI = "true" // Version returns a pretty printed version information string. func Version() string {