engine

package
v0.1.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2023 License: Unlicense Imports: 54 Imported by: 0

Documentation

Index

Constants

View Source
const ErrWrongTypeDecode = "magic '%s' but type is '%s'"
View Source
const (
	PubSubTopic = "indra"
)

Variables

This section is empty.

Functions

func MakeReplyHeader

func MakeReplyHeader(ng *Engine) (returnHeader *hidden.ReplyHeader)

func PostAcctOnion

func PostAcctOnion(sm *sess.Manager, o Skins) (res *sess.Data)

PostAcctOnion takes a slice of Skins and calculates their costs and the list of sessions inside them and attaches accounting operations to apply when the associated confirmation(s) or response hooks are executed.

func SetupGossip added in v0.1.16

func SetupGossip(ctx context.Context, host host.Host,
	cancel func()) (PubSub *pubsub.PubSub, topic *pubsub.Topic,
	sub *pubsub.Subscription, e error)

Types

type Engine

type Engine struct {
	Responses *responses.Pending

	NodeAds  *ads.NodeAds
	Listener *transport.Listener
	PubSub   *pubsub.PubSub

	KeySet       *crypto.KeySet
	Load         atomic.Uint32
	Pause        qu.C
	ShuttingDown atomic.Bool
	// contains filtered or unexported fields
}

Engine processes onion messages, forwarding the relevant data to other relays and locally accessible servers as indicated by the API function and message parameters.

func CreateMockEngine

func CreateMockEngine(seed, dataPath string) (ng *Engine, cancel func(), e error)

CreateMockEngine creates an indra Engine with a random localhost listener.

func CreateNMockCircuits

func CreateNMockCircuits(nCirc int, nReturns int,
	ctx context.Context) (cl []*Engine, e error)

func CreateNMockCircuitsWithSessions

func CreateNMockCircuitsWithSessions(nCirc int, nReturns int,
	ctx context.Context) (cl []*Engine, e error)

func New

func New(p Params) (ng *Engine, e error)

New creates a new Engine according to the Params given.

func (*Engine) BuyNewSessions

func (ng *Engine) BuyNewSessions(amount lnwire.MilliSatoshi,
	fn func()) (e error)

BuyNewSessions performs the initial purchase of 5 sessions as well as adding different hop numbers to relays with existing Note that all 5 of the sessions will be paid the amount specified, not divided up.

func (*Engine) Cleanup

func (ng *Engine) Cleanup()

Cleanup closes and flushes any resources the client opened that require sync in order to reopen correctly.

func (*Engine) ClearPeerRecord added in v0.1.16

func (ng *Engine) ClearPeerRecord(id peer.ID, key string) (e error)

func (*Engine) GetHidden

func (ng *Engine) GetHidden() *hidden.Hidden

func (*Engine) GetLoad

func (ng *Engine) GetLoad() byte

func (*Engine) GetPeerRecord added in v0.1.16

func (ng *Engine) GetPeerRecord(id peer.ID, key string) (add ad.Ad, e error)

func (*Engine) HandleAd added in v0.1.15

func (ng *Engine) HandleAd(p *pubsub.Message) (e error)

func (*Engine) HandleMessage

func (ng *Engine) HandleMessage(s *splice.Splice, pr ont.Onion)

func (*Engine) Handler

func (ng *Engine) Handler() (terminate bool)

func (*Engine) Keyset

func (ng *Engine) Keyset() *crypto.KeySet

func (*Engine) Mgr

func (ng *Engine) Mgr() *sess.Manager

func (*Engine) Pending

func (ng *Engine) Pending() *responses.Pending

func (*Engine) RunAdHandler added in v0.1.15

func (ng *Engine) RunAdHandler(handler func(p *pubsub.Message) (e error))

func (*Engine) SendAd added in v0.1.15

func (ng *Engine) SendAd(a slice.Bytes) (e error)

func (*Engine) SendExit

func (ng *Engine) SendExit(port uint16, msg slice.Bytes, id nonce.ID,
	alice, bob *sessions.Data, hook responses.Callback)

func (*Engine) SendGetBalance

func (ng *Engine) SendGetBalance(alice, bob *sessions.Data, hook responses.Callback)

func (*Engine) SendHiddenService

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 *adintro.Ad)

func (*Engine) SendIntroQuery

func (ng *Engine) SendIntroQuery(id nonce.ID, hsk *crypto.Pub,
	alice, bob *sessions.Data, hook func(in *adintro.Ad))

func (*Engine) SendMessage

func (ng *Engine) SendMessage(mp *message.Message, hook responses.Callback) (id nonce.ID)

func (*Engine) SendPing

func (ng *Engine) SendPing(c sessions.Circuit, hook responses.Callback)

func (*Engine) SendRoute

func (ng *Engine) SendRoute(k *crypto.Pub, ap *netip.AddrPort,
	hook responses.Callback)

func (*Engine) SetLoad

func (ng *Engine) SetLoad(load byte)

func (*Engine) Shutdown

func (ng *Engine) Shutdown()

Shutdown triggers the shutdown of the client and the Cleanup before finishing.

func (*Engine) Start

func (ng *Engine) Start()

Start a single thread of the Engine.

func (*Engine) WaitForShutdown added in v0.1.16

func (ng *Engine) WaitForShutdown() <-chan struct{}

type Params

type Params struct {
	Transport       tpt.Transport
	Listener        *transport.Listener
	Keys            *crypto.Keys
	Node            *node.Node
	Nodes           []*node.Node
	NReturnSessions int
}

type RoutingHeader

type RoutingHeader struct {
	Layers [3]RoutingLayer
}

type RoutingLayer

type RoutingLayer struct {
	*reverse.Reverse
	*crypt.Crypt
}

type Skins

type Skins []ont.Onion

func MakeExit

func MakeExit(p exit.ExitParams) Skins

MakeExit constructs a message containing an arbitrary payload to a node (3rd hop) with a set of 3 ciphers derived from the hidden PayloadPub of the return hops that are layered progressively after the Exit message.

The Exit node forwards the packet it receives to the local port specified in the Exit message, and then uses the ciphers to encrypt the reply with the three ciphers provided, which don't enable it to decrypt the header, only to encrypt the payload.

The header remains a constant size and each node in the Reverse trims off 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 MakeGetBalance

func MakeGetBalance(p getbalance.GetBalanceParams) Skins

MakeGetBalance sends out a request in a similar way to Exit except the node being queried can be any of the 5.

func MakeHiddenService

func MakeHiddenService(in *adintro.Ad, alice, bob *sessions.Data,
	c sessions.Circuit, ks *crypto.KeySet) Skins

func MakeIntroQuery

func MakeIntroQuery(id nonce.ID, hsk *crypto.Pub, alice, bob *sessions.Data,
	c sessions.Circuit, ks *crypto.KeySet) Skins

func MakeRoute

func MakeRoute(id nonce.ID, k *crypto.Pub, ks *crypto.KeySet,
	alice, bob *sessions.Data, c sessions.Circuit) Skins

func MakeSession

func MakeSession(id nonce.ID, s [5]*session.Session,
	client *sessions.Data, hop []*node.Node, ks *crypto.KeySet) Skins

func Ping

func Ping(id nonce.ID, client *sessions.Data, s sessions.Circuit,
	ks *crypto.KeySet) Skins

Ping is a message which checks the liveness of relays by ensuring they are correctly relaying messages.

The pending ping records keep the identifiers of the 5 nodes that were in a ping onion and when the Confirmation is correctly received these nodes get 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 (Skins) Confirmation

func (o Skins) Confirmation(id nonce.ID, load byte) Skins

func (Skins) Crypt

func (o Skins) Crypt(toHdr, toPld *crypto.Pub, from *crypto.Prv, iv nonce.IV,
	depth int) Skins

func (Skins) End

func (o Skins) End() Skins

func (Skins) Exit

func (o Skins) Exit(id nonce.ID, port uint16, payload slice.Bytes,
	ep *exit.ExitPoint) Skins

func (Skins) Forward

func (o Skins) Forward(addr *netip.AddrPort) Skins

func (Skins) ForwardCrypt

func (o Skins) ForwardCrypt(s *sessions.Data, k *crypto.Prv, n nonce.IV) Skins

func (Skins) ForwardSession

func (o Skins) ForwardSession(s *node.Node,
	k *crypto.Prv, n nonce.IV, sess *session.Session) Skins

func (Skins) GetBalance

func (o Skins) GetBalance(id nonce.ID, ep *exit.ExitPoint) Skins

func (Skins) HiddenService

func (o Skins) HiddenService(in *adintro.Ad, point *exit.ExitPoint) Skins

func (Skins) IntroQuery

func (o Skins) IntroQuery(id nonce.ID, hsk *crypto.Pub, exit *exit.ExitPoint) Skins

func (Skins) Message

func (o Skins) Message(msg *message.Message, ks *crypto.KeySet) Skins

func (Skins) Ready

func (o Skins) Ready(id nonce.ID, addr *crypto.Pub, fwHdr,
	rvHdr hidden.RoutingHeaderBytes, fc, rc crypto.Ciphers, fn, rn crypto.Nonces) Skins

func (Skins) Response

func (o Skins) Response(id nonce.ID, res slice.Bytes, port uint16, load byte) Skins

func (Skins) Reverse

func (o Skins) Reverse(ip *netip.AddrPort) Skins

func (Skins) ReverseCrypt

func (o Skins) ReverseCrypt(s *sessions.Data, k *crypto.Prv, n nonce.IV,
	seq int) (oo Skins)

func (Skins) Route

func (o Skins) Route(id nonce.ID, k *crypto.Pub, ks *crypto.KeySet, ep *exit.ExitPoint) Skins

func (Skins) RoutingHeader

func (o Skins) RoutingHeader(r *exit.Routing) Skins

func (Skins) Session

func (o Skins) Session(sess *session.Session) Skins

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL