From 08b78432d50b9510d0108df01970798df6543181 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: Mon, 5 Jun 2023 07:51:01 +0100 Subject: [PATCH] finishing rename of intro --- pkg/engine/eng_senders.go | 12 ++++++------ pkg/engine/onion_skins.go | 9 ++++----- pkg/onions/adpeer/peer.go | 4 ++-- pkg/onions/adservice/adservice.go | 6 +++--- pkg/onions/hidden/hidden.go | 16 ++++++++-------- pkg/onions/introquery/introquery.go | 6 +++--- 6 files changed, 26 insertions(+), 27 deletions(-) diff --git a/pkg/engine/eng_senders.go b/pkg/engine/eng_senders.go index 44801413..9b86aaf8 100644 --- a/pkg/engine/eng_senders.go +++ b/pkg/engine/eng_senders.go @@ -1,9 +1,9 @@ package engine import ( + "github.com/indra-labs/indra/pkg/onions/adintro" "github.com/indra-labs/indra/pkg/onions/exit" "github.com/indra-labs/indra/pkg/onions/getbalance" - "github.com/indra-labs/indra/pkg/onions/intro" "github.com/indra-labs/indra/pkg/onions/message" "github.com/indra-labs/indra/pkg/onions/ont" "github.com/indra-labs/indra/pkg/onions/reg" @@ -55,7 +55,7 @@ func (ng *Engine) SendGetBalance(alice, bob *sessions.Data, hook responses.Callb func (ng *Engine) SendHiddenService(id nonce.ID, key *crypto.Prv, relayRate uint32, port uint16, expiry time.Time, alice, bob *sessions.Data, svc *services.Service, - hook responses.Callback) (in *intro.Ad) { + hook responses.Callback) (in *adintro.Ad) { hops := sess.StandardCircuit() s := make(sessions.Sessions, len(hops)) @@ -63,7 +63,7 @@ func (ng *Engine) SendHiddenService(id nonce.ID, key *crypto.Prv, se := ng.Manager.SelectHops(hops, s, "sendhiddenservice") var c sessions.Circuit copy(c[:], se[:len(c)]) - in = intro.NewIntroAd(id, key, alice.Node.AddrPort, relayRate, port, expiry) + in = adintro.NewIntroAd(id, key, alice.Node.AddrPort, relayRate, port, expiry) o := MakeHiddenService(in, alice, bob, c, ng.KeySet) log.D.F("%s sending out hidden service onion %s", ng.Manager.GetLocalNodeAddressString(), @@ -76,7 +76,7 @@ func (ng *Engine) SendHiddenService(id nonce.ID, key *crypto.Prv, } func (ng *Engine) SendIntroQuery(id nonce.ID, hsk *crypto.Pub, - alice, bob *sessions.Data, hook func(in *intro.Ad)) { + alice, bob *sessions.Data, hook func(in *adintro.Ad)) { fn := func(id nonce.ID, ifc interface{}, b slice.Bytes) (e error) { s := splice.Load(b, slice.NewCursor()) @@ -84,9 +84,9 @@ func (ng *Engine) SendIntroQuery(id nonce.ID, hsk *crypto.Pub, if e = on.Decode(s); fails(e) { return } - var oni *intro.Ad + var oni *adintro.Ad var ok bool - if oni, ok = on.(*intro.Ad); !ok { + if oni, ok = on.(*adintro.Ad); !ok { return } hook(oni) diff --git a/pkg/engine/onion_skins.go b/pkg/engine/onion_skins.go index 9a0ca7f7..e00e80b4 100644 --- a/pkg/engine/onion_skins.go +++ b/pkg/engine/onion_skins.go @@ -5,6 +5,7 @@ import ( "github.com/indra-labs/indra/pkg/crypto/nonce" "github.com/indra-labs/indra/pkg/engine/node" "github.com/indra-labs/indra/pkg/engine/sessions" + "github.com/indra-labs/indra/pkg/onions/adintro" "github.com/indra-labs/indra/pkg/onions/confirmation" "github.com/indra-labs/indra/pkg/onions/crypt" "github.com/indra-labs/indra/pkg/onions/end" @@ -14,7 +15,6 @@ import ( headers2 "github.com/indra-labs/indra/pkg/onions/headers" "github.com/indra-labs/indra/pkg/onions/hidden" "github.com/indra-labs/indra/pkg/onions/hiddenservice" - "github.com/indra-labs/indra/pkg/onions/intro" "github.com/indra-labs/indra/pkg/onions/introquery" "github.com/indra-labs/indra/pkg/onions/message" "github.com/indra-labs/indra/pkg/onions/ont" @@ -35,11 +35,10 @@ func (o Skins) Confirmation(id nonce.ID, load byte) Skins { return append(o, confirmation.NewConfirmation(id, load)) } - //func (o Skins) Delay(d time.Duration) Skins { return append(o, delay.NewDelay(d)) } type ( - Skins []ont.Onion + Skins []ont.Onion RoutingLayer struct { *reverse.Reverse *crypt.Crypt @@ -78,7 +77,7 @@ func (o Skins) GetBalance(id nonce.ID, ep *exit.ExitPoint) Skins { return append(o, getbalance.NewGetBalance(id, ep)) } -func (o Skins) HiddenService(in *intro.Ad, point *exit.ExitPoint) Skins { +func (o Skins) HiddenService(in *adintro.Ad, point *exit.ExitPoint) Skins { return append(o, hiddenservice.NewHiddenService(in, point)) } @@ -143,7 +142,7 @@ func MakeGetBalance(p getbalance.GetBalanceParams) Skins { RoutingHeader(headers.Return) } -func MakeHiddenService(in *intro.Ad, alice, bob *sessions.Data, +func MakeHiddenService(in *adintro.Ad, alice, bob *sessions.Data, c sessions.Circuit, ks *crypto.KeySet) Skins { headers := headers2.GetHeaders(alice, bob, c, ks) diff --git a/pkg/onions/adpeer/peer.go b/pkg/onions/adpeer/peer.go index 5720d80f..cbc05fce 100644 --- a/pkg/onions/adpeer/peer.go +++ b/pkg/onions/adpeer/peer.go @@ -9,7 +9,7 @@ import ( "github.com/indra-labs/indra/pkg/engine/coding" "github.com/indra-labs/indra/pkg/engine/magic" "github.com/indra-labs/indra/pkg/engine/sess" - "github.com/indra-labs/indra/pkg/onions/intro" + "github.com/indra-labs/indra/pkg/onions/adintro" "github.com/indra-labs/indra/pkg/onions/reg" log2 "github.com/indra-labs/indra/pkg/proc/log" "github.com/indra-labs/indra/pkg/util/qu" @@ -43,7 +43,7 @@ func New(id nonce.ID, key *crypto.Prv, relayRate uint32) (peerAd *Ad) { pk := crypto.DerivePub(key) - s := splice.New(intro.Len - magic.Len) + s := splice.New(adintro.Len - magic.Len) s.ID(id). Pubkey(pk). Uint32(relayRate) diff --git a/pkg/onions/adservice/adservice.go b/pkg/onions/adservice/adservice.go index 0d0d18b6..f5dd5cb5 100644 --- a/pkg/onions/adservice/adservice.go +++ b/pkg/onions/adservice/adservice.go @@ -9,7 +9,7 @@ import ( "github.com/indra-labs/indra/pkg/engine/coding" "github.com/indra-labs/indra/pkg/engine/magic" "github.com/indra-labs/indra/pkg/engine/sess" - "github.com/indra-labs/indra/pkg/onions/intro" + "github.com/indra-labs/indra/pkg/onions/adintro" "github.com/indra-labs/indra/pkg/onions/reg" log2 "github.com/indra-labs/indra/pkg/proc/log" "github.com/indra-labs/indra/pkg/util/qu" @@ -54,7 +54,7 @@ func NewServiceAd( port uint16, ) (sv *Ad) { - s := splice.New(intro.Len) + s := splice.New(adintro.Len) k := crypto.DerivePub(key) ServiceSplice(s, id, k, relayRate, port) hash := sha256.Single(s.GetUntil(s.GetCursor())) @@ -122,7 +122,7 @@ func (x *Ad) SpliceNoSig(s *splice.Splice) { } func (x *Ad) Validate() (valid bool) { - s := splice.New(intro.Len - magic.Len) + s := splice.New(adintro.Len - magic.Len) x.SpliceNoSig(s) hash := sha256.Single(s.GetUntil(s.GetCursor())) key, e := x.Sig.Recover(hash) diff --git a/pkg/onions/hidden/hidden.go b/pkg/onions/hidden/hidden.go index 44d1c71c..f48f9b98 100644 --- a/pkg/onions/hidden/hidden.go +++ b/pkg/onions/hidden/hidden.go @@ -6,8 +6,8 @@ import ( "github.com/indra-labs/indra/pkg/crypto/ciph" "github.com/indra-labs/indra/pkg/crypto/nonce" "github.com/indra-labs/indra/pkg/engine/services" + "github.com/indra-labs/indra/pkg/onions/adintro" "github.com/indra-labs/indra/pkg/onions/consts" - "github.com/indra-labs/indra/pkg/onions/intro" log2 "github.com/indra-labs/indra/pkg/proc/log" "github.com/indra-labs/indra/pkg/util/slice" "github.com/indra-labs/indra/pkg/util/splice" @@ -29,7 +29,7 @@ type Hidden struct { } func (hr *Hidden) AddHiddenService(svc *services.Service, key *crypto.Prv, - in *intro.Ad, addr string) { + in *adintro.Ad, addr string) { pk := crypto.DerivePub(key).ToBytes() hr.Lock() log.D.F("%s added hidden service with key %s", addr, pk) @@ -54,7 +54,7 @@ func (hr *Hidden) AddIntro(pk *crypto.Pub, intro *Introduction) { hr.Unlock() } -func (hr *Hidden) AddIntroToHiddenService(key crypto.PubBytes, in *intro.Ad) { +func (hr *Hidden) AddIntroToHiddenService(key crypto.PubBytes, in *adintro.Ad) { hr.Lock() hr.Services[key].CurrentIntros = append(hr.Services[key]. CurrentIntros, in) @@ -176,7 +176,7 @@ func (hr *Hidden) FindIntroductionUnsafe( return } -func (hr *Hidden) FindKnownIntro(key crypto.PubBytes) (intro *intro.Ad) { +func (hr *Hidden) FindKnownIntro(key crypto.PubBytes) (intro *adintro.Ad) { hr.Lock() var ok bool if intro, ok = hr.KnownIntros[key]; ok { @@ -185,7 +185,7 @@ func (hr *Hidden) FindKnownIntro(key crypto.PubBytes) (intro *intro.Ad) { return } -func (hr *Hidden) FindKnownIntroUnsafe(key crypto.PubBytes) (intro *intro.Ad) { +func (hr *Hidden) FindKnownIntroUnsafe(key crypto.PubBytes) (intro *adintro.Ad) { var ok bool if intro, ok = hr.KnownIntros[key]; ok { } @@ -193,13 +193,13 @@ func (hr *Hidden) FindKnownIntroUnsafe(key crypto.PubBytes) (intro *intro.Ad) { } type Introduction struct { - Intro *intro.Ad + Intro *adintro.Ad ReplyHeader } -type KnownIntros map[crypto.PubBytes]*intro.Ad +type KnownIntros map[crypto.PubBytes]*adintro.Ad type LocalHiddenService struct { Prv *crypto.Prv - CurrentIntros []*intro.Ad + CurrentIntros []*adintro.Ad *services.Service } type MyIntros map[crypto.PubBytes]*Introduction diff --git a/pkg/onions/introquery/introquery.go b/pkg/onions/introquery/introquery.go index a2eb00e5..27d95325 100644 --- a/pkg/onions/introquery/introquery.go +++ b/pkg/onions/introquery/introquery.go @@ -9,11 +9,11 @@ import ( "github.com/indra-labs/indra/pkg/engine/magic" "github.com/indra-labs/indra/pkg/engine/sess" "github.com/indra-labs/indra/pkg/engine/sessions" + "github.com/indra-labs/indra/pkg/onions/adintro" "github.com/indra-labs/indra/pkg/onions/crypt" "github.com/indra-labs/indra/pkg/onions/end" "github.com/indra-labs/indra/pkg/onions/exit" "github.com/indra-labs/indra/pkg/onions/hidden" - "github.com/indra-labs/indra/pkg/onions/intro" "github.com/indra-labs/indra/pkg/onions/ont" "github.com/indra-labs/indra/pkg/onions/reg" log2 "github.com/indra-labs/indra/pkg/proc/log" @@ -87,11 +87,11 @@ func (x *IntroQuery) Handle(s *splice.Splice, p ont.Onion, ng ont.Ngin) (e error log.D.Ln(ng.Mgr().GetLocalNodeAddressString(), "handling introquery", x.ID, x.Key.ToBased32Abbreviated()) var ok bool - var il *intro.Ad + var il *adintro.Ad if il, ok = ng.GetHidden().KnownIntros[x.Key.ToBytes()]; !ok { // if the reply is zeroes the querant knows it needs to retry at a // different relay - il = &intro.Ad{} + il = &adintro.Ad{} ng.GetHidden().Unlock() log.E.Ln("intro not known") return