From f38c562d62bb61030db16ba822496fe4c0ddb64d Mon Sep 17 00:00:00 2001 From: David Vennik Date: Fri, 30 Dec 2022 16:45:12 +0000 Subject: [PATCH] moving proc inside --- go.mod | 8 ++++---- go.sum | 2 -- pkg/client/client.go | 22 +++++++++++++++------- pkg/proc | 1 + 4 files changed, 20 insertions(+), 13 deletions(-) create mode 160000 pkg/proc diff --git a/go.mod b/go.mod index 6db4b0e9..41521b50 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,9 @@ module github.com/Indra-Labs/indra go 1.19 require ( - github.com/cybriq/proc v0.20.9 + github.com/cybriq/proc v0.20.10 github.com/cybriq/qu v0.1.2 + github.com/davecgh/go-spew v1.1.1 github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 github.com/docker/cli v0.0.0-20191017083524-a8ff7f821017 github.com/docker/docker v20.10.22+incompatible @@ -14,6 +15,7 @@ require ( github.com/moby/term v0.0.0-20221205130635-1aeaba878587 github.com/multiformats/go-multiaddr v0.8.0 github.com/templexxx/reedsolomon v1.1.3 + go.uber.org/atomic v1.10.0 gopkg.in/src-d/go-git.v4 v4.13.1 ) @@ -27,7 +29,6 @@ require ( github.com/containerd/cgroups v1.0.4 // indirect github.com/containerd/containerd v1.6.14 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect github.com/docker/distribution v2.8.1+incompatible // indirect github.com/docker/docker-credential-helpers v0.6.3 // indirect @@ -131,7 +132,6 @@ require ( github.com/xanzy/ssh-agent v0.2.1 // indirect github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect go.opencensus.io v0.24.0 // indirect - go.uber.org/atomic v1.10.0 // indirect go.uber.org/dig v1.15.0 // indirect go.uber.org/fx v1.18.2 // indirect go.uber.org/multierr v1.8.0 // indirect @@ -154,4 +154,4 @@ replace crypto/sha256 => github.com/minio/sha256-simd v1.0.0 replace math/rand => github.com/lukechampine/frand v1.4.2 -//replace github.com/cybriq/proc => ../../cybriq/proc +replace github.com/cybriq/proc => ./pkg/proc diff --git a/go.sum b/go.sum index fd676d9d..5e36923d 100644 --- a/go.sum +++ b/go.sum @@ -259,8 +259,6 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsr github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= -github.com/cybriq/proc v0.20.9 h1:y1ZJF9Ot3ogQdMwRkNtN+6KcZkuwrHjENYrL1hYZr2g= -github.com/cybriq/proc v0.20.9/go.mod h1:b6JDUUwfe8soxWzvAziWA/msrb73O2v6gZEQL+wHYx8= github.com/cybriq/qu v0.1.2 h1:4R65BhG22C3mY4fXYZpfJYklw9N1AVkCwTwrby4andY= github.com/cybriq/qu v0.1.2/go.mod h1:1Ph7YWr5HVJTBSRTQ8cFcaFE+DK56r+cSpbNWD+CQS8= github.com/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4= diff --git a/pkg/client/client.go b/pkg/client/client.go index d92d3410..963b5415 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -91,7 +91,7 @@ func (cl *Client) runner() (out bool) { break case b := <-cl.Node.Receive(): // process received message - log.I.Ln("received message") + // log.I.Ln("received message") var onion types.Onion var e error c := slice.NewCursor() @@ -125,7 +125,7 @@ func (cl *Client) runner() (out bool) { cl.purchase(on, b, c) case *reverse.OnionSkin: log.I.Ln(reflect.TypeOf(on)) - cl.reply(on, b, c) + cl.reverse(on, b, c) case *response.OnionSkin: log.I.Ln(reflect.TypeOf(on)) cl.response(on, b, c) @@ -174,7 +174,7 @@ func (cl *Client) delay(on *delay.OnionSkin, b slice.Bytes, cur *slice.Cursor) { func (cl *Client) exit(on *exit.OnionSkin, b slice.Bytes, cur *slice.Cursor) { // payload is forwarded to a local port and the response is forwarded - // back with a reply header. + // back with a reverse header. } func (cl *Client) forward(on *forward.OnionSkin, b slice.Bytes, c *slice.Cursor) { @@ -204,7 +204,7 @@ func (cl *Client) layer(on *layer.OnionSkin, b slice.Bytes, c *slice.Cursor) { } on.Decrypt(rcv.Key, b, c) b = append(b[*c:], slice.NoisePad(int(*c))...) - log.I.S(b.ToBytes()) + // log.I.S(b.ToBytes()) cl.Node.Send(b) } @@ -219,17 +219,25 @@ func (cl *Client) purchase(on *purchase.OnionSkin, b slice.Bytes, c *slice.Curso s.Deadline = time.Now().Add(DefaultDeadline) cl.Sessions = append(cl.Sessions, s) cl.Mutex.Unlock() + // log.I.Ln("todo: construct return message") + log.I.S(b[*c:].ToBytes()) + // cl.Node.Send(b[*c:]) + + panic("todo: process purchase message") } -func (cl *Client) reply(on *reverse.OnionSkin, b slice.Bytes, c *slice.Cursor) { +func (cl *Client) reverse(on *reverse.OnionSkin, b slice.Bytes, c *slice.Cursor) { + log.I.Ln("reverse") // Reply means another OnionSkin is coming and the payload encryption // uses the Payload key. if on.AddrPort.String() == cl.Node.AddrPort.String() { + log.I.Ln("it's for us") // it is for us, we want to unwrap the next part. cl.Node.Send(b) } else { // we need to forward this message onion. - cl.Send(on.AddrPort, b) + // cl.Send(on.AddrPort, b) + panic("we haven't processed it yet") } } @@ -239,7 +247,7 @@ func (cl *Client) response(on *response.OnionSkin, b slice.Bytes, cur *slice.Cur } func (cl *Client) session(s *session.OnionSkin, b slice.Bytes, cur *slice.Cursor) { - // Session is returned from a Purchase message in the reply layers. + // Session is returned from a Purchase message in the reverse layers. // // Session has a nonce.ID that is given in the last layer of a LN sphinx // Bolt 4 onion routed payment path that will cause the seller to diff --git a/pkg/proc b/pkg/proc new file mode 160000 index 00000000..ee185b6d --- /dev/null +++ b/pkg/proc @@ -0,0 +1 @@ +Subproject commit ee185b6d80a77d17fde3b510c73f7f46ac115cca