and yet more were found to merge
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"github.com/cybriq/qu"
|
||||
|
||||
"git-indra.lan/indra-labs/indra/pkg/crypto/nonce"
|
||||
"git-indra.lan/indra-labs/indra/pkg/traffic"
|
||||
"git-indra.lan/indra-labs/indra/pkg/util/slice"
|
||||
)
|
||||
|
||||
@@ -20,7 +19,7 @@ type PendingResponse struct {
|
||||
Billable []nonce.ID
|
||||
Return nonce.ID
|
||||
PostAcct []func()
|
||||
traffic.Sessions
|
||||
Sessions
|
||||
Callback
|
||||
time.Time
|
||||
Success qu.C
|
||||
@@ -42,7 +41,7 @@ func (p *PendingResponses) GetOldestPending() (pr *PendingResponse) {
|
||||
return
|
||||
}
|
||||
|
||||
func (p *PendingResponses) Add(id nonce.ID, sentSize int, s traffic.Sessions,
|
||||
func (p *PendingResponses) Add(id nonce.ID, sentSize int, s Sessions,
|
||||
billable []nonce.ID, ret nonce.ID, port uint16,
|
||||
callback func(id nonce.ID, b slice.Bytes), postAcct []func()) {
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ import (
|
||||
)
|
||||
|
||||
func TestOnionSkins_Cipher(t *testing.T) {
|
||||
|
||||
var e error
|
||||
sess := session.New(1)
|
||||
on := Skins{}.
|
||||
@@ -55,7 +54,6 @@ func TestOnionSkins_Cipher(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOnionSkins_Confirmation(t *testing.T) {
|
||||
|
||||
var e error
|
||||
n := nonce.NewID()
|
||||
on := Skins{}.
|
||||
@@ -80,7 +78,6 @@ func TestOnionSkins_Confirmation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOnionSkins_Delay(t *testing.T) {
|
||||
|
||||
var e error
|
||||
del := time.Duration(rand.Uint64())
|
||||
on := Skins{}.
|
||||
@@ -105,7 +102,6 @@ func TestOnionSkins_Delay(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOnionSkins_Exit(t *testing.T) {
|
||||
|
||||
var e error
|
||||
prvs, pubs := GetCipherSet(t)
|
||||
ciphers := GenCiphers(prvs, pubs)
|
||||
@@ -162,7 +158,6 @@ func TestOnionSkins_Exit(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOnionSkins_Forward(t *testing.T) {
|
||||
|
||||
var e error
|
||||
ipSizes := []int{net.IPv4len, net.IPv6len}
|
||||
for i := range ipSizes {
|
||||
@@ -205,7 +200,6 @@ func TestOnionSkins_Forward(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOnionSkins_Layer(t *testing.T) {
|
||||
|
||||
var e error
|
||||
n := nonce.NewID()
|
||||
n1 := nonce.New()
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
"git-indra.lan/indra-labs/indra/pkg/crypto/key/signer"
|
||||
"git-indra.lan/indra-labs/indra/pkg/crypto/nonce"
|
||||
log2 "git-indra.lan/indra-labs/indra/pkg/proc/log"
|
||||
"git-indra.lan/indra-labs/indra/pkg/traffic"
|
||||
"git-indra.lan/indra-labs/indra/pkg/types"
|
||||
)
|
||||
|
||||
@@ -27,7 +26,7 @@ const DefaultTimeout = time.Second
|
||||
type Engine struct {
|
||||
sync.Mutex
|
||||
*PendingResponses
|
||||
*traffic.SessionManager
|
||||
*SessionManager
|
||||
*signer.KeySet
|
||||
Load byte
|
||||
TimeoutSignal qu.C
|
||||
@@ -36,8 +35,8 @@ type Engine struct {
|
||||
qu.C
|
||||
}
|
||||
|
||||
func NewEngine(tpt types.Transport, hdrPrv *prv.Key, no *traffic.Node,
|
||||
nodes []*traffic.Node, nReturnSessions int) (c *Engine, e error) {
|
||||
func NewEngine(tpt types.Transport, hdrPrv *prv.Key, no *Node,
|
||||
nodes []*Node, nReturnSessions int) (c *Engine, e error) {
|
||||
|
||||
no.Transport = tpt
|
||||
no.IdentityPrv = hdrPrv
|
||||
@@ -49,16 +48,16 @@ func NewEngine(tpt types.Transport, hdrPrv *prv.Key, no *traffic.Node,
|
||||
c = &Engine{
|
||||
PendingResponses: &PendingResponses{},
|
||||
KeySet: ks,
|
||||
SessionManager: traffic.NewSessionManager(),
|
||||
SessionManager: NewSessionManager(),
|
||||
TimeoutSignal: qu.T(),
|
||||
Pause: qu.T(),
|
||||
C: qu.T(),
|
||||
}
|
||||
c.AddNodes(append([]*traffic.Node{no}, nodes...)...)
|
||||
c.AddNodes(append([]*Node{no}, nodes...)...)
|
||||
// Add a return session for receiving responses, ideally more of these will
|
||||
// be generated during operation and rotated out over time.
|
||||
for i := 0; i < nReturnSessions; i++ {
|
||||
c.AddSession(traffic.NewSession(nonce.NewID(), no, 0, nil, nil, 5))
|
||||
c.AddSession(NewSession(nonce.NewID(), no, 0, nil, nil, 5))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
"git-indra.lan/indra-labs/indra/pkg/crypto/sha256"
|
||||
log2 "git-indra.lan/indra-labs/indra/pkg/proc/log"
|
||||
"git-indra.lan/indra-labs/indra/pkg/service"
|
||||
"git-indra.lan/indra-labs/indra/pkg/traffic"
|
||||
"git-indra.lan/indra-labs/indra/pkg/transport"
|
||||
"git-indra.lan/indra-labs/indra/pkg/util/slice"
|
||||
"git-indra.lan/indra-labs/indra/pkg/util/tests"
|
||||
@@ -185,7 +184,7 @@ func TestClient_SendPing(t *testing.T) {
|
||||
out:
|
||||
for i := 3; i < len(clients[0].Sessions)-1; i++ {
|
||||
wg.Add(1)
|
||||
var c traffic.Circuit
|
||||
var c Circuit
|
||||
sess := clients[0].Sessions[i]
|
||||
c[sess.Hop] = clients[0].Sessions[i]
|
||||
clients[0].SendPing(c,
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"git-indra.lan/indra-labs/lnd/lnd/lnwire"
|
||||
|
||||
"git-indra.lan/indra-labs/indra/pkg/onion/balance"
|
||||
"git-indra.lan/indra-labs/indra/pkg/traffic"
|
||||
"git-indra.lan/indra-labs/indra/pkg/types"
|
||||
"git-indra.lan/indra-labs/indra/pkg/util/slice"
|
||||
)
|
||||
@@ -36,8 +35,8 @@ func (eng *Engine) balance(on *balance.Layer,
|
||||
}
|
||||
}
|
||||
}
|
||||
var se *traffic.Session
|
||||
eng.IterateSessions(func(s *traffic.Session) bool {
|
||||
var se *Session
|
||||
eng.IterateSessions(func(s *Session) bool {
|
||||
if s.ID == on.ID {
|
||||
log.D.F("%s received balance %s for session %s %s was %s",
|
||||
local,
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"git-indra.lan/indra-labs/indra/pkg/onion/balance"
|
||||
"git-indra.lan/indra-labs/indra/pkg/onion/crypt"
|
||||
"git-indra.lan/indra-labs/indra/pkg/onion/getbalance"
|
||||
"git-indra.lan/indra-labs/indra/pkg/traffic"
|
||||
"git-indra.lan/indra-labs/indra/pkg/types"
|
||||
"git-indra.lan/indra-labs/indra/pkg/util/slice"
|
||||
)
|
||||
@@ -17,7 +16,7 @@ func (eng *Engine) getBalance(on *getbalance.Layer,
|
||||
log.T.S(on)
|
||||
var found bool
|
||||
var bal *balance.Layer
|
||||
eng.IterateSessions(func(s *traffic.Session) bool {
|
||||
eng.IterateSessions(func(s *Session) bool {
|
||||
if s.ID == on.ID {
|
||||
bal = &balance.Layer{
|
||||
ID: on.ID,
|
||||
@@ -49,7 +48,7 @@ func (eng *Engine) getBalance(on *getbalance.Layer,
|
||||
eng.DecSession(sess.ID, in+out, false, "getbalance")
|
||||
}
|
||||
}
|
||||
eng.IterateSessions(func(s *traffic.Session) bool {
|
||||
eng.IterateSessions(func(s *Session) bool {
|
||||
if s.ID == on.ID {
|
||||
bal = &balance.Layer{
|
||||
ID: on.ID,
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
|
||||
"git-indra.lan/indra-labs/indra/pkg/onion/session"
|
||||
"git-indra.lan/indra-labs/indra/pkg/traffic"
|
||||
"git-indra.lan/indra-labs/indra/pkg/types"
|
||||
"git-indra.lan/indra-labs/indra/pkg/util/slice"
|
||||
)
|
||||
@@ -25,7 +24,7 @@ func (eng *Engine) session(on *session.Layer, b slice.Bytes,
|
||||
// duplicate sessions.
|
||||
eng.DeletePendingPayment(pi.Preimage)
|
||||
log.D.F("Adding session %s to %s", pi.ID, eng.GetLocalNodeAddress())
|
||||
eng.AddSession(traffic.NewSession(pi.ID,
|
||||
eng.AddSession(NewSession(pi.ID,
|
||||
eng.GetLocalNode(), pi.Amount, on.Header, on.Payload, on.Hop))
|
||||
eng.handleMessage(BudgeUp(b, *c), on)
|
||||
} else {
|
||||
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
"git-indra.lan/indra-labs/indra/pkg/onion/response"
|
||||
"git-indra.lan/indra-labs/indra/pkg/onion/reverse"
|
||||
"git-indra.lan/indra-labs/indra/pkg/onion/session"
|
||||
"git-indra.lan/indra-labs/indra/pkg/traffic"
|
||||
"git-indra.lan/indra-labs/indra/pkg/types"
|
||||
"git-indra.lan/indra-labs/indra/pkg/util/slice"
|
||||
)
|
||||
@@ -35,7 +34,7 @@ func (eng *Engine) handler() (out bool) {
|
||||
case p := <-eng.GetLocalNode().PaymentChan.Receive():
|
||||
log.D.F("incoming payment for %s: %v", p.ID, p.Amount)
|
||||
topUp := false
|
||||
eng.IterateSessions(func(s *traffic.Session) bool {
|
||||
eng.IterateSessions(func(s *Session) bool {
|
||||
if s.Preimage == p.Preimage {
|
||||
s.IncSats(p.Amount, false, "top-up")
|
||||
topUp = true
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
|
||||
"git-indra.lan/indra-labs/indra/pkg/crypto/nonce"
|
||||
"git-indra.lan/indra-labs/indra/pkg/onion/session"
|
||||
"git-indra.lan/indra-labs/indra/pkg/traffic"
|
||||
"git-indra.lan/indra-labs/indra/pkg/util/cryptorand"
|
||||
"git-indra.lan/indra-labs/indra/pkg/util/slice"
|
||||
)
|
||||
@@ -18,7 +17,7 @@ import (
|
||||
func (eng *Engine) BuyNewSessions(amount lnwire.MilliSatoshi,
|
||||
hook func()) (e error) {
|
||||
|
||||
var nodes [5]*traffic.Node
|
||||
var nodes [5]*Node
|
||||
nodes = eng.SessionManager.SelectUnusedCircuit()
|
||||
for i := range nodes {
|
||||
if nodes[i] == nil {
|
||||
@@ -27,7 +26,7 @@ func (eng *Engine) BuyNewSessions(amount lnwire.MilliSatoshi,
|
||||
}
|
||||
}
|
||||
// Get a random return hop session (index 5).
|
||||
var returnSession *traffic.Session
|
||||
var returnSession *Session
|
||||
returnHops := eng.SessionManager.GetSessionsAtHop(5)
|
||||
if len(returnHops) > 1 {
|
||||
cryptorand.Shuffle(len(returnHops), func(i, j int) {
|
||||
@@ -83,12 +82,12 @@ func (eng *Engine) BuyNewSessions(amount lnwire.MilliSatoshi,
|
||||
eng.SendWithOneHook(nodes[0].AddrPort, res, func(id nonce.ID, b slice.Bytes) {
|
||||
eng.SessionManager.Lock()
|
||||
defer eng.SessionManager.Unlock()
|
||||
var sessions [5]*traffic.Session
|
||||
var sessions [5]*Session
|
||||
for i := range nodes {
|
||||
log.D.F("confirming and storing session at hop %d %s for %s with"+
|
||||
" %v initial"+
|
||||
" balance", i, s[i].ID, nodes[i].AddrPort.String(), amount)
|
||||
sessions[i] = traffic.NewSession(s[i].ID, nodes[i], amount,
|
||||
sessions[i] = NewSession(s[i].ID, nodes[i], amount,
|
||||
s[i].Header, s[i].Payload, byte(i))
|
||||
eng.SessionManager.Add(sessions[i])
|
||||
eng.Sessions = append(eng.Sessions, sessions[i])
|
||||
|
||||
@@ -3,15 +3,14 @@ package relay
|
||||
import (
|
||||
"git-indra.lan/indra-labs/indra/pkg/crypto/key/cloak"
|
||||
"git-indra.lan/indra-labs/indra/pkg/crypto/key/prv"
|
||||
"git-indra.lan/indra-labs/indra/pkg/traffic"
|
||||
)
|
||||
|
||||
// FindCloaked searches the client identity key and the sessions for a match. It
|
||||
// returns the session as well, though not all users of this function will need
|
||||
// this.
|
||||
func (eng *Engine) FindCloaked(clk cloak.PubKey) (hdr *prv.Key,
|
||||
pld *prv.Key, sess *traffic.Session, identity bool) {
|
||||
|
||||
pld *prv.Key, sess *Session, identity bool) {
|
||||
|
||||
var b cloak.Blinder
|
||||
copy(b[:], clk[:cloak.BlindLen])
|
||||
hash := cloak.Cloak(b, eng.GetLocalNodeIdentityBytes())
|
||||
@@ -23,7 +22,7 @@ func (eng *Engine) FindCloaked(clk cloak.PubKey) (hdr *prv.Key,
|
||||
return
|
||||
}
|
||||
var i int
|
||||
eng.IterateSessions(func(s *traffic.Session) (stop bool) {
|
||||
eng.IterateSessions(func(s *Session) (stop bool) {
|
||||
hash = cloak.Cloak(b, s.HeaderBytes)
|
||||
if hash == clk {
|
||||
log.T.F("found cloaked key in session %d", i)
|
||||
|
||||
@@ -11,13 +11,12 @@ import (
|
||||
"git-indra.lan/indra-labs/indra/pkg/onion/forward"
|
||||
"git-indra.lan/indra-labs/indra/pkg/onion/getbalance"
|
||||
"git-indra.lan/indra-labs/indra/pkg/onion/reverse"
|
||||
"git-indra.lan/indra-labs/indra/pkg/traffic"
|
||||
"git-indra.lan/indra-labs/indra/pkg/util/slice"
|
||||
)
|
||||
|
||||
type SendData struct {
|
||||
b slice.Bytes
|
||||
sessions traffic.Sessions
|
||||
sessions Sessions
|
||||
billable []nonce.ID
|
||||
ret, last nonce.ID
|
||||
port uint16
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"net/netip"
|
||||
"runtime"
|
||||
|
||||
"git-indra.lan/indra-labs/indra/pkg/traffic"
|
||||
"git-indra.lan/indra-labs/indra/pkg/util/slice"
|
||||
)
|
||||
|
||||
@@ -13,7 +12,7 @@ func (eng *Engine) Send(addr *netip.AddrPort, b slice.Bytes) {
|
||||
// first search if we already have the node available with connection
|
||||
// open.
|
||||
as := addr.String()
|
||||
eng.ForEachNode(func(n *traffic.Node) bool {
|
||||
eng.ForEachNode(func(n *Node) bool {
|
||||
if as == n.AddrPort.String() {
|
||||
n.Transport.Send(b)
|
||||
_, f, l, _ := runtime.Caller(1)
|
||||
|
||||
@@ -4,19 +4,18 @@ import (
|
||||
"time"
|
||||
|
||||
"git-indra.lan/indra-labs/indra/pkg/crypto/nonce"
|
||||
"git-indra.lan/indra-labs/indra/pkg/traffic"
|
||||
"git-indra.lan/indra-labs/indra/pkg/util/slice"
|
||||
)
|
||||
|
||||
func (eng *Engine) SendExit(port uint16, message slice.Bytes, id nonce.ID,
|
||||
target *traffic.Session, hook func(id nonce.ID, b slice.Bytes),
|
||||
target *Session, hook func(id nonce.ID, b slice.Bytes),
|
||||
timeout time.Duration) {
|
||||
|
||||
hops := []byte{0, 1, 2, 3, 4, 5}
|
||||
s := make(traffic.Sessions, len(hops))
|
||||
s := make(Sessions, len(hops))
|
||||
s[2] = target
|
||||
se := eng.SelectHops(hops, s)
|
||||
var c traffic.Circuit
|
||||
var c Circuit
|
||||
copy(c[:], se)
|
||||
o := SendExit(port, message, id, se[len(se)-1], c, eng.KeySet)
|
||||
log.D.Ln("sending out exit onion")
|
||||
@@ -25,11 +24,11 @@ func (eng *Engine) SendExit(port uint16, message slice.Bytes, id nonce.ID,
|
||||
}
|
||||
|
||||
func (eng *Engine) MakeExit(port uint16, message slice.Bytes, id nonce.ID,
|
||||
target *traffic.Session) (c traffic.Circuit,
|
||||
target *Session) (c Circuit,
|
||||
o Skins) {
|
||||
|
||||
hops := []byte{0, 1, 2, 3, 4, 5}
|
||||
s := make(traffic.Sessions, len(hops))
|
||||
s := make(Sessions, len(hops))
|
||||
s[2] = target
|
||||
se := eng.SelectHops(hops, s)
|
||||
copy(c[:], se)
|
||||
@@ -37,7 +36,7 @@ func (eng *Engine) MakeExit(port uint16, message slice.Bytes, id nonce.ID,
|
||||
return
|
||||
}
|
||||
|
||||
func (eng *Engine) SendExitNew(c traffic.Circuit,
|
||||
func (eng *Engine) SendExitNew(c Circuit,
|
||||
o Skins, hook func(id nonce.ID, b slice.Bytes),
|
||||
timeout time.Duration) {
|
||||
|
||||
|
||||
@@ -2,15 +2,14 @@ package relay
|
||||
|
||||
import (
|
||||
"git-indra.lan/indra-labs/indra/pkg/crypto/nonce"
|
||||
"git-indra.lan/indra-labs/indra/pkg/traffic"
|
||||
)
|
||||
|
||||
func (eng *Engine) SendGetBalance(target *traffic.Session, hook Callback) {
|
||||
func (eng *Engine) SendGetBalance(target *Session, hook Callback) {
|
||||
hops := []byte{0, 1, 2, 3, 4, 5}
|
||||
s := make(traffic.Sessions, len(hops))
|
||||
s := make(Sessions, len(hops))
|
||||
s[2] = target
|
||||
se := eng.SelectHops(hops, s)
|
||||
var c traffic.Circuit
|
||||
var c Circuit
|
||||
copy(c[:], se)
|
||||
confID := nonce.NewID()
|
||||
o := GetBalance(target.ID, confID, se[5], c, eng.KeySet)
|
||||
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
"git-indra.lan/indra-labs/indra/pkg/onion/forward"
|
||||
"git-indra.lan/indra-labs/indra/pkg/onion/getbalance"
|
||||
"git-indra.lan/indra-labs/indra/pkg/onion/reverse"
|
||||
"git-indra.lan/indra-labs/indra/pkg/traffic"
|
||||
"git-indra.lan/indra-labs/indra/pkg/util/slice"
|
||||
)
|
||||
|
||||
@@ -30,7 +29,7 @@ func (eng *Engine) SendOnion(ap *netip.AddrPort, o Skins,
|
||||
var last nonce.ID
|
||||
var port uint16
|
||||
var postAcct []func()
|
||||
var sessions traffic.Sessions
|
||||
var sessions Sessions
|
||||
// do client accounting
|
||||
skip := false
|
||||
for i := range o {
|
||||
|
||||
@@ -2,12 +2,11 @@ package relay
|
||||
|
||||
import (
|
||||
"git-indra.lan/indra-labs/indra/pkg/crypto/nonce"
|
||||
"git-indra.lan/indra-labs/indra/pkg/traffic"
|
||||
)
|
||||
|
||||
func (eng *Engine) SendPing(c traffic.Circuit, hook Callback) {
|
||||
func (eng *Engine) SendPing(c Circuit, hook Callback) {
|
||||
hops := []byte{0, 1, 2, 3, 4, 5}
|
||||
s := make(traffic.Sessions, len(hops))
|
||||
s := make(Sessions, len(hops))
|
||||
copy(s, c[:])
|
||||
se := eng.SelectHops(hops, s)
|
||||
copy(c[:], se)
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
// Package traffic maintains information about peers on the network and
|
||||
// associated connection sessions.
|
||||
package traffic
|
||||
package relay
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -9,22 +7,15 @@ import (
|
||||
|
||||
"git-indra.lan/indra-labs/lnd/lnd/lnwire"
|
||||
|
||||
"git-indra.lan/indra-labs/indra"
|
||||
"git-indra.lan/indra-labs/indra/pkg/crypto/key/prv"
|
||||
"git-indra.lan/indra-labs/indra/pkg/crypto/key/pub"
|
||||
"git-indra.lan/indra-labs/indra/pkg/crypto/nonce"
|
||||
log2 "git-indra.lan/indra-labs/indra/pkg/proc/log"
|
||||
"git-indra.lan/indra-labs/indra/pkg/ring"
|
||||
"git-indra.lan/indra-labs/indra/pkg/service"
|
||||
"git-indra.lan/indra-labs/indra/pkg/types"
|
||||
"git-indra.lan/indra-labs/indra/pkg/util/slice"
|
||||
)
|
||||
|
||||
var (
|
||||
log = log2.GetLogger(indra.PathBase)
|
||||
check = log.E.Chk
|
||||
)
|
||||
|
||||
// Node is a representation of a messaging counterparty.
|
||||
type Node struct {
|
||||
nonce.ID
|
||||
@@ -1,11 +1,11 @@
|
||||
package traffic
|
||||
package relay
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/netip"
|
||||
|
||||
|
||||
"git-indra.lan/indra-labs/lnd/lnd/lnwire"
|
||||
|
||||
|
||||
"git-indra.lan/indra-labs/indra/pkg/crypto/key/prv"
|
||||
"git-indra.lan/indra-labs/indra/pkg/crypto/key/pub"
|
||||
"git-indra.lan/indra-labs/indra/pkg/crypto/nonce"
|
||||
@@ -44,7 +44,7 @@ func (sm *SessionManager) SetLocalNodeAddress(addr *netip.AddrPort) {
|
||||
|
||||
func (sm *SessionManager) SendFromLocalNode(port uint16,
|
||||
b slice.Bytes) (e error) {
|
||||
|
||||
|
||||
sm.Lock()
|
||||
defer sm.Unlock()
|
||||
return sm.GetLocalNode().SendTo(port, b)
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"git-indra.lan/indra-labs/indra/pkg/crypto/key/signer"
|
||||
"git-indra.lan/indra-labs/indra/pkg/crypto/nonce"
|
||||
"git-indra.lan/indra-labs/indra/pkg/onion/session"
|
||||
"git-indra.lan/indra-labs/indra/pkg/traffic"
|
||||
"git-indra.lan/indra-labs/indra/pkg/util/slice"
|
||||
)
|
||||
|
||||
@@ -18,7 +17,7 @@ import (
|
||||
// an increment of their liveness score. By using this scheme, when nodes are
|
||||
// offline their scores will fall to zero after a time whereas live nodes will
|
||||
// have steadily increasing scores from successful pings.
|
||||
func Ping(id nonce.ID, client *traffic.Session, s traffic.Circuit,
|
||||
func Ping(id nonce.ID, client *Session, s Circuit,
|
||||
ks *signer.KeySet) Skins {
|
||||
|
||||
n := GenPingNonces()
|
||||
@@ -50,7 +49,7 @@ func Ping(id nonce.ID, client *traffic.Session, s traffic.Circuit,
|
||||
// their section at the top, moves the next crypt header to the top and pads the
|
||||
// remainder with noise, so it always looks like the first hop.
|
||||
func SendExit(port uint16, payload slice.Bytes, id nonce.ID,
|
||||
client *traffic.Session, s traffic.Circuit, ks *signer.KeySet) Skins {
|
||||
client *Session, s Circuit, ks *signer.KeySet) Skins {
|
||||
|
||||
var prvs [3]*prv.Key
|
||||
for i := range prvs {
|
||||
@@ -96,7 +95,7 @@ func SendExit(port uint16, payload slice.Bytes, id nonce.ID,
|
||||
// set of sessions. This is by way of indicating to not use the IdentityPub but
|
||||
// the HeaderPub instead. Not allowing free relay at all prevents spam attacks.
|
||||
func SendKeys(id nonce.ID, s [5]*session.Layer,
|
||||
client *traffic.Session, hop []*traffic.Node, ks *signer.KeySet) Skins {
|
||||
client *Session, hop []*Node, ks *signer.KeySet) Skins {
|
||||
|
||||
n := GenNonces(6)
|
||||
sk := Skins{}
|
||||
@@ -114,8 +113,8 @@ func SendKeys(id nonce.ID, s [5]*session.Layer,
|
||||
|
||||
// GetBalance sends out a request in a similar way to SendExit except the node
|
||||
// being queried can be any of the 5.
|
||||
func GetBalance(id, confID nonce.ID, client *traffic.Session,
|
||||
s traffic.Circuit, ks *signer.KeySet) Skins {
|
||||
func GetBalance(id, confID nonce.ID, client *Session,
|
||||
s Circuit, ks *signer.KeySet) Skins {
|
||||
|
||||
var prvs [3]*prv.Key
|
||||
for i := range prvs {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package traffic
|
||||
package relay
|
||||
|
||||
import (
|
||||
"git-indra.lan/indra-labs/lnd/lnd/lnwire"
|
||||
@@ -1,4 +1,4 @@
|
||||
package traffic
|
||||
package relay
|
||||
|
||||
import (
|
||||
"git-indra.lan/indra-labs/indra/pkg/util/cryptorand"
|
||||
@@ -1,4 +1,4 @@
|
||||
package traffic
|
||||
package relay
|
||||
|
||||
// SelectUnusedCircuit accepts an array of 5 Node entries where all or some are
|
||||
// empty and picks nodes for the remainder that do not have a hop at that
|
||||
@@ -1,10 +1,10 @@
|
||||
package traffic
|
||||
package relay
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
|
||||
|
||||
"git-indra.lan/indra-labs/lnd/lnd/lnwire"
|
||||
|
||||
|
||||
"git-indra.lan/indra-labs/indra/pkg/crypto/key/prv"
|
||||
"git-indra.lan/indra-labs/indra/pkg/crypto/key/pub"
|
||||
"git-indra.lan/indra-labs/indra/pkg/crypto/nonce"
|
||||
@@ -35,7 +35,7 @@ func NewSession(
|
||||
pldPrv *prv.Key,
|
||||
hop byte,
|
||||
) (s *Session) {
|
||||
|
||||
|
||||
var e error
|
||||
if hdrPrv == nil || pldPrv == nil {
|
||||
if hdrPrv, e = prv.GenerateKey(); check(e) {
|
||||
@@ -1,4 +1,4 @@
|
||||
package traffic
|
||||
package relay
|
||||
|
||||
import (
|
||||
"git-indra.lan/indra-labs/indra/pkg/crypto/nonce"
|
||||
@@ -1,4 +1,4 @@
|
||||
package traffic
|
||||
package relay
|
||||
|
||||
import (
|
||||
"sync"
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
"git-indra.lan/indra-labs/indra/pkg/onion/response"
|
||||
"git-indra.lan/indra-labs/indra/pkg/onion/reverse"
|
||||
"git-indra.lan/indra-labs/indra/pkg/onion/session"
|
||||
"git-indra.lan/indra-labs/indra/pkg/traffic"
|
||||
"git-indra.lan/indra-labs/indra/pkg/types"
|
||||
"git-indra.lan/indra-labs/indra/pkg/util/slice"
|
||||
)
|
||||
@@ -29,19 +28,19 @@ type Skins []types.Onion
|
||||
|
||||
var nop = &noop.Layer{}
|
||||
|
||||
func (o Skins) ForwardCrypt(s *traffic.Session, k *prv.Key,
|
||||
func (o Skins) ForwardCrypt(s *Session, k *prv.Key,
|
||||
n nonce.IV) Skins {
|
||||
|
||||
return o.Forward(s.AddrPort).Crypt(s.HeaderPub, s.PayloadPub, k, n, 0)
|
||||
}
|
||||
|
||||
func (o Skins) ReverseCrypt(s *traffic.Session, k *prv.Key, n nonce.IV,
|
||||
func (o Skins) ReverseCrypt(s *Session, k *prv.Key, n nonce.IV,
|
||||
seq int) Skins {
|
||||
|
||||
return o.Reverse(s.AddrPort).Crypt(s.HeaderPub, s.PayloadPub, k, n, seq)
|
||||
}
|
||||
|
||||
func (o Skins) ForwardSession(s *traffic.Node,
|
||||
func (o Skins) ForwardSession(s *Node,
|
||||
k *prv.Key, n nonce.IV, sess *session.Layer) Skins {
|
||||
|
||||
return o.Forward(s.AddrPort).
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"git-indra.lan/indra-labs/indra/pkg/crypto/key/prv"
|
||||
"git-indra.lan/indra-labs/indra/pkg/crypto/key/pub"
|
||||
"git-indra.lan/indra-labs/indra/pkg/crypto/nonce"
|
||||
"git-indra.lan/indra-labs/indra/pkg/traffic"
|
||||
"git-indra.lan/indra-labs/indra/pkg/transport"
|
||||
"git-indra.lan/indra-labs/indra/pkg/types"
|
||||
"git-indra.lan/indra-labs/indra/pkg/util/slice"
|
||||
@@ -14,9 +13,9 @@ func CreateNMockCircuits(inclSessions bool, nCircuits int, nReturnSessions int)
|
||||
|
||||
nTotal := 1 + nCircuits*5
|
||||
cl = make([]*Engine, nTotal)
|
||||
nodes := make([]*traffic.Node, nTotal)
|
||||
nodes := make([]*Node, nTotal)
|
||||
transports := make([]types.Transport, nTotal)
|
||||
sessions := make(traffic.Sessions, nTotal-1)
|
||||
sessions := make(Sessions, nTotal-1)
|
||||
for i := range transports {
|
||||
transports[i] = transport.NewSim(nTotal)
|
||||
}
|
||||
@@ -31,7 +30,7 @@ func CreateNMockCircuits(inclSessions bool, nCircuits int, nReturnSessions int)
|
||||
if i == 0 {
|
||||
local = true
|
||||
}
|
||||
nodes[i], _ = traffic.NewNode(addr, idPub, idPrv, transports[i], 50000,
|
||||
nodes[i], _ = NewNode(addr, idPub, idPrv, transports[i], 50000,
|
||||
local)
|
||||
if cl[i], e = NewEngine(transports[i], idPrv, nodes[i], nil,
|
||||
nReturnSessions); check(e) {
|
||||
@@ -42,7 +41,7 @@ func CreateNMockCircuits(inclSessions bool, nCircuits int, nReturnSessions int)
|
||||
if inclSessions {
|
||||
// Create a session for all but the first.
|
||||
if i > 0 {
|
||||
sessions[i-1] = traffic.NewSession(
|
||||
sessions[i-1] = NewSession(
|
||||
nonce.NewID(), nodes[i],
|
||||
1<<16, nil, nil,
|
||||
byte((i-1)/nCircuits))
|
||||
|
||||
Reference in New Issue
Block a user