commands

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2021 License: AGPL-3.0 Imports: 5 Imported by: 5

Documentation

Overview

Package commands implements the Sphinx Packet Format per-hop routing info commands.

Index

Constants

View Source
const (
	// NextNodeHopLength is the length of a NextNodeHop command in bytes.
	NextNodeHopLength = 1 + constants.NodeIDLength + crypto.MACLength

	// RecipientLength is the length of a Recipient command in bytes.
	RecipientLength = 1 + constants.RecipientIDLength

	// SURBReplyLength is the length of a SURBReply command in bytes.
	SURBReplyLength = 1 + constants.SURBIDLength

	// NodeDelayLength is the length of a NodeDelay command in bytes.
	NodeDelayLength = 1 + 4
)

Variables

This section is empty.

Functions

This section is empty.

Types

type NextNodeHop

type NextNodeHop struct {
	ID  [constants.NodeIDLength]byte
	MAC [crypto.MACLength]byte
}

NextNodeHop is a de-serialized Sphinx next_node command.

func (*NextNodeHop) ToBytes

func (cmd *NextNodeHop) ToBytes(b []byte) []byte

ToBytes appends the serialized NextNodeHop to slice b, and returns the resulting slice.

type NodeDelay

type NodeDelay struct {
	Delay uint32
}

NodeDelay is a de-serialized Sphinx mix_delay command.

func (*NodeDelay) ToBytes

func (cmd *NodeDelay) ToBytes(b []byte) []byte

ToBytes appends the serialized NodeDelay to slice b, and returns the resulting slice.

type Recipient

type Recipient struct {
	ID [constants.RecipientIDLength]byte
}

Recipient is a de-serialized Sphinx recipient command.

func (*Recipient) ToBytes

func (cmd *Recipient) ToBytes(b []byte) []byte

ToBytes appends the serialized Recipeient to slice b, and returns the resulting slice.

type RoutingCommand

type RoutingCommand interface {
	// ToBytes appends the serialized command to slice b, and returns the
	// resulting slice.
	ToBytes(b []byte) []byte
}

RoutingCommand is the common interface exposed by all per-hop routing command structures.

func FromBytes

func FromBytes(b []byte) (cmd RoutingCommand, rest []byte, err error)

FromBytes deserializes the first per-hop routing command in the buffer b, returning a RoutingCommand and the remaining bytes (if any), or an error.

type SURBReply

type SURBReply struct {
	ID [constants.SURBIDLength]byte
}

SURBReply is a de-serialized Sphinx surb-reply command.

func (*SURBReply) ToBytes

func (cmd *SURBReply) ToBytes(b []byte) []byte

ToBytes appends the serialized SURBReply to slice b, and returns the resulting slice.

Jump to

Keyboard shortcuts

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