Documentation
¶
Index ¶
- Constants
- func MakeReplyHeader(ng *Engine) (returnHeader *hidden.ReplyHeader)
- func PostAcctOnion(sm *sess.Manager, o Skins) (res *sess.Data)
- func SetupGossip(ctx context.Context, host host.Host, cancel func()) (PubSub *pubsub.PubSub, topic *pubsub.Topic, sub *pubsub.Subscription, e error)
- type Engine
- func CreateMockEngine(seed, dataPath string) (ng *Engine, cancel func(), e error)
- func CreateNMockCircuits(nCirc int, nReturns int, ctx context.Context) (cl []*Engine, e error)
- func CreateNMockCircuitsWithSessions(nCirc int, nReturns int, ctx context.Context) (cl []*Engine, e error)
- func New(p Params) (ng *Engine, e error)
- func (ng *Engine) BuyNewSessions(amount lnwire.MilliSatoshi, fn func()) (e error)
- func (ng *Engine) Cleanup()
- func (ng *Engine) ClearPeerRecord(id peer.ID, key string) (e error)
- func (ng *Engine) GetHidden() *hidden.Hidden
- func (ng *Engine) GetLoad() byte
- func (ng *Engine) GetPeerRecord(id peer.ID, key string) (add ad.Ad, e error)
- func (ng *Engine) HandleAd(p *pubsub.Message) (e error)
- func (ng *Engine) HandleMessage(s *splice.Splice, pr ont.Onion)
- func (ng *Engine) Handler() (terminate bool)
- func (ng *Engine) Keyset() *crypto.KeySet
- func (ng *Engine) Mgr() *sess.Manager
- func (ng *Engine) Pending() *responses.Pending
- func (ng *Engine) RunAdHandler(handler func(p *pubsub.Message) (e error))
- func (ng *Engine) SendAd(a slice.Bytes) (e error)
- func (ng *Engine) SendExit(port uint16, msg slice.Bytes, id nonce.ID, alice, bob *sessions.Data, ...)
- func (ng *Engine) SendGetBalance(alice, bob *sessions.Data, hook responses.Callback)
- func (ng *Engine) SendHiddenService(id nonce.ID, key *crypto.Prv, relayRate uint32, port uint16, expiry time.Time, ...) (in *adintro.Ad)
- func (ng *Engine) SendIntroQuery(id nonce.ID, hsk *crypto.Pub, alice, bob *sessions.Data, ...)
- func (ng *Engine) SendMessage(mp *message.Message, hook responses.Callback) (id nonce.ID)
- func (ng *Engine) SendPing(c sessions.Circuit, hook responses.Callback)
- func (ng *Engine) SendRoute(k *crypto.Pub, ap *netip.AddrPort, hook responses.Callback)
- func (ng *Engine) SetLoad(load byte)
- func (ng *Engine) Shutdown()
- func (ng *Engine) Start()
- func (ng *Engine) WaitForShutdown() <-chan struct{}
- type Params
- type RoutingHeader
- type RoutingLayer
- type Skins
- func MakeExit(p exit.ExitParams) Skins
- func MakeGetBalance(p getbalance.GetBalanceParams) Skins
- func MakeHiddenService(in *adintro.Ad, alice, bob *sessions.Data, c sessions.Circuit, ...) Skins
- func MakeIntroQuery(id nonce.ID, hsk *crypto.Pub, alice, bob *sessions.Data, c sessions.Circuit, ...) Skins
- func MakeRoute(id nonce.ID, k *crypto.Pub, ks *crypto.KeySet, alice, bob *sessions.Data, ...) Skins
- func MakeSession(id nonce.ID, s [5]*session.Session, client *sessions.Data, hop []*node.Node, ...) Skins
- func Ping(id nonce.ID, client *sessions.Data, s sessions.Circuit, ks *crypto.KeySet) Skins
- func (o Skins) Confirmation(id nonce.ID, load byte) Skins
- func (o Skins) Crypt(toHdr, toPld *crypto.Pub, from *crypto.Prv, iv nonce.IV, depth int) Skins
- func (o Skins) End() Skins
- func (o Skins) Exit(id nonce.ID, port uint16, payload slice.Bytes, ep *exit.ExitPoint) Skins
- func (o Skins) Forward(addr *netip.AddrPort) Skins
- func (o Skins) ForwardCrypt(s *sessions.Data, k *crypto.Prv, n nonce.IV) Skins
- func (o Skins) ForwardSession(s *node.Node, k *crypto.Prv, n nonce.IV, sess *session.Session) Skins
- func (o Skins) GetBalance(id nonce.ID, ep *exit.ExitPoint) Skins
- func (o Skins) HiddenService(in *adintro.Ad, point *exit.ExitPoint) Skins
- func (o Skins) IntroQuery(id nonce.ID, hsk *crypto.Pub, exit *exit.ExitPoint) Skins
- func (o Skins) Message(msg *message.Message, ks *crypto.KeySet) Skins
- func (o Skins) Ready(id nonce.ID, addr *crypto.Pub, fwHdr, rvHdr hidden.RoutingHeaderBytes, ...) Skins
- func (o Skins) Response(id nonce.ID, res slice.Bytes, port uint16, load byte) Skins
- func (o Skins) Reverse(ip *netip.AddrPort) Skins
- func (o Skins) ReverseCrypt(s *sessions.Data, k *crypto.Prv, n nonce.IV, seq int) (oo Skins)
- func (o Skins) Route(id nonce.ID, k *crypto.Pub, ks *crypto.KeySet, ep *exit.ExitPoint) Skins
- func (o Skins) RoutingHeader(r *exit.Routing) Skins
- func (o Skins) Session(sess *session.Session) Skins
Constants ¶
const ErrWrongTypeDecode = "magic '%s' but type is '%s'"
const (
PubSubTopic = "indra"
)
Variables ¶
This section is empty.
Functions ¶
func MakeReplyHeader ¶
func MakeReplyHeader(ng *Engine) (returnHeader *hidden.ReplyHeader)
func PostAcctOnion ¶
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.
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 ¶
CreateMockEngine creates an indra Engine with a random localhost listener.
func CreateNMockCircuits ¶
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 (*Engine) GetPeerRecord ¶ added in v0.1.16
func (*Engine) RunAdHandler ¶ added in v0.1.15
func (*Engine) SendGetBalance ¶
func (*Engine) SendHiddenService ¶
func (*Engine) SendIntroQuery ¶
func (*Engine) SendMessage ¶
func (*Engine) Shutdown ¶
func (ng *Engine) Shutdown()
Shutdown triggers the shutdown of the client and the Cleanup before finishing.
func (*Engine) WaitForShutdown ¶ added in v0.1.16
func (ng *Engine) WaitForShutdown() <-chan struct{}
type RoutingHeader ¶
type RoutingHeader struct {
Layers [3]RoutingLayer
}
type Skins ¶
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 MakeIntroQuery ¶
func MakeSession ¶
func Ping ¶
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.