cells

package
v0.0.0-...-e847439 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CERTS_TLS_LINK_X509 = 1
	CERTS_RSA_ID_X509   = 2

	CERTS_IDENTITY_V_SIGNING_CERT = 4
	CERTS_SIGNING_V_TLS_CERT      = 5

	CERTS_RSA_ID_V_IDENTITY = 7
)
View Source
const (
	DESTROY_REASON_NONE           uint8 = iota // No reason given.
	DESTROY_REASON_PROTCOL                     // Tor protocol violation. (Note: if encounter with this reason consider creating an issue in the repo)
	DESTROY_REASON_INTERNAL                    // Internal error.
	DESTROY_REASON_REQUESTED                   // A client sent a TRUNCATE command.
	DESTROY_REASON_HIBERNATING                 // Not currently operating; trying to save bandwidth.
	DESTROY_REASON_RESOURCELIMIT               // Out of memory, sockets, or circuit IDs.
	DESTROY_REASON_CONNECTFAILED               // Unable to reach relay.
	DESTROY_REASON_OR_IDENTITY                 // Connected to relay, but its OR identity was not as expected.
	DESTROY_REASON_CHANNEL_CLOSED              // The OR connection that was carrying this circuit died.
	DESTROY_REASON_FINISHED                    // The circuit has expired for being dirty or old.
	DESTROY_REASON_TIMEOUT                     // Circuit construction took too long
	DESTROY_REASON_DESTROYED                   // The circuit was destroyed w/o client TRUNCATE
	DESTROY_REASON_NOSUCHSERVICE               // Request for unknown hidden service
)
View Source
const (
	DESTROY_REASON_NONE_MSG           string = "No reason given."                                             // No reason given.
	DESTROY_REASON_PROTCOL_MSG        string = "Tor protocol violation."                                      // Tor protocol violation. (Note: if encounter with this reason consider creating an issue in the repo)
	DESTROY_REASON_INTERNAL_MSG       string = "Internal error."                                              // Internal error.
	DESTROY_REASON_REQUESTED_MSG      string = "A client sent a TRUNCATE command."                            // A client sent a TRUNCATE command.
	DESTROY_REASON_HIBERNATING_MSG    string = "Not currently operating; trying to save bandwidth"            // Not currently operating; trying to save bandwidth.
	DESTROY_REASON_RESOURCELIMIT_MSG  string = "Out of memory, sockets, or circuit IDs."                      // Out of memory, sockets, or circuit IDs.
	DESTROY_REASON_CONNECTFAILED_MSG  string = "Unable to reach relay."                                       // Unable to reach relay.
	DESTROY_REASON_OR_IDENTITY_MSG    string = "Connected to relay, but its OR identity was not as expected." // Connected to relay, but its OR identity was not as expected.
	DESTROY_REASON_CHANNEL_CLOSED_MSG string = "The OR connection that was carrying this circuit died."       // The OR connection that was carrying this circuit died.
	DESTROY_REASON_FINISHED_MSG       string = "The circuit has expired for being dirty or old."              // The circuit has expired for being dirty or old.
	DESTROY_REASON_TIMEOUT_MSG        string = "Circuit construction took too long"                           // Circuit construction took too long
	DESTROY_REASON_DESTROYED_MSG      string = "The circuit was destroyed w/o client TRUNCATE"                // The circuit was destroyed w/o client TRUNCATE
	DESTROY_REASON_NOSUCHSERVICE_MSG  string = "Request for unknown hidden service"                           // Request for unknown hidden service
)
View Source
const (
	NETINFO_IPV4 byte = 0x04
	NETINFO_IPV6 byte = 0x06
)
View Source
const CELL_BODY_LEN int = 509
View Source
const COMMAND_AUTH_CHALLANGE uint8 = 130
View Source
const COMMAND_CERTS uint8 = 129
View Source
const COMMAND_CREATE2 uint8 = 10
View Source
const COMMAND_CREATED2 uint8 = 11
View Source
const COMMAND_CREATED_FAST uint8 = 6
View Source
const COMMAND_CREATE_FAST uint8 = 5
View Source
const COMMAND_DESTROY uint8 = 4
View Source
const COMMAND_NETINFO uint8 = 8
View Source
const COMMAND_RELAY uint8 = 3
View Source
const COMMAND_RELAY_EARLY uint8 = 9
View Source
const COMMAND_VERSIONS uint8 = 7

Variables

View Source
var (
	ErrInvalidCircID    = errors.New("invalid circuit id expected: %s found %s")
	ErrUnknownCommandID = errors.New("unknown command id")
)
View Source
var AllKnownCells = map[uint8]func() Cell{
	COMMAND_RELAY:        func() Cell { return &RelayCell{} },
	COMMAND_DESTROY:      func() Cell { return &DestroyCell{} },
	COMMAND_CREATE_FAST:  func() Cell { return &CreateFastCell{} },
	COMMAND_CREATED_FAST: func() Cell { return &CreatedFastCell{} },
	COMMAND_NETINFO:      func() Cell { return &NetInfoCell{} },

	COMMAND_RELAY_EARLY: func() Cell { return &RelayEarlyCell{C: &RelayCell{}} },
	COMMAND_CREATE2:     func() Cell { return &Create2Cell{} },
	COMMAND_CREATED2:    func() Cell { return &Created2Cell{} },

	COMMAND_CERTS: func() Cell { return &CertsCell{} },
}

Functions

This section is empty.

Types

type Cell

type Cell interface {
	ID() uint8

	GetCircuitID() uint32
	SetCircuitID(uint32)

	Decode(r io.Reader) error
	Encode(w io.Writer) error
}

type CellCoder

type CellCoder struct {
	// contains filtered or unexported fields
}

func NewCellCoder

func NewCellCoder(knownCells map[uint8]func() Cell) *CellCoder

NewCellCoder can encode and decode link cells.

func (*CellCoder) MarshalCell

func (r *CellCoder) MarshalCell(cell Cell) ([]byte, error)

func (*CellCoder) ReadCell

func (r *CellCoder) ReadCell(reader io.Reader) (Cell, error)

ReadCell reads a cell from the reader. The first 4 bytes (circuit id) are discarded; callers that need it must parse the header themselves.

func (*CellCoder) WriteCell

func (r *CellCoder) WriteCell(cell Cell, writer io.Writer) error

type CertsCell

type CertsCell struct {
	CircID       uint32
	Certificates []certificate
}

func (*CertsCell) Decode

func (c *CertsCell) Decode(r io.Reader) error

func (*CertsCell) Encode

func (*CertsCell) Encode(io.Writer) error

func (*CertsCell) GetCircuitID

func (c *CertsCell) GetCircuitID() uint32

func (*CertsCell) ID

func (*CertsCell) ID() uint8

func (*CertsCell) SetCircuitID

func (c *CertsCell) SetCircuitID(n uint32)

type Create2Cell

type Create2Cell struct {
	CircuitID uint32

	HandshakeType uint16
	Handshake     handshakes.Handshake
}

func (*Create2Cell) Decode

func (c *Create2Cell) Decode(r io.Reader) error

func (*Create2Cell) Encode

func (c *Create2Cell) Encode(w io.Writer) error

func (*Create2Cell) GetCircuitID

func (c *Create2Cell) GetCircuitID() uint32

func (*Create2Cell) ID

func (*Create2Cell) ID() uint8

func (*Create2Cell) SetCircuitID

func (c *Create2Cell) SetCircuitID(n uint32)

type CreateFastCell

type CreateFastCell struct {
	CircuitID uint32
	X         [20]byte // X is just 20 random bytes
}

func (*CreateFastCell) Decode

func (c *CreateFastCell) Decode(r io.Reader) error

func (*CreateFastCell) Encode

func (c *CreateFastCell) Encode(w io.Writer) error

func (*CreateFastCell) GetCircuitID

func (c *CreateFastCell) GetCircuitID() uint32

func (*CreateFastCell) ID

func (*CreateFastCell) ID() uint8

func (*CreateFastCell) SetCircuitID

func (c *CreateFastCell) SetCircuitID(n uint32)

type Created2Cell

type Created2Cell struct {
	CircuitID uint32

	Handshake handshakes.Handshake // MAKE SURE YOU USED DecodeHandshake METHOD BEFORE TRYING TO USE THIS VAR
	// contains filtered or unexported fields
}

func (*Created2Cell) Decode

func (c *Created2Cell) Decode(r io.Reader) error

func (*Created2Cell) DecodeHandshake

func (c *Created2Cell) DecodeHandshake(htype uint16) error

func (*Created2Cell) Encode

func (c *Created2Cell) Encode(w io.Writer) error

func (*Created2Cell) GetCircuitID

func (c *Created2Cell) GetCircuitID() uint32

func (*Created2Cell) ID

func (*Created2Cell) ID() uint8

func (*Created2Cell) SetCircuitID

func (c *Created2Cell) SetCircuitID(n uint32)

type CreatedFastCell

type CreatedFastCell struct {
	CircuitID uint32

	Y  [20]byte
	KH [20]byte
}

func (*CreatedFastCell) Decode

func (c *CreatedFastCell) Decode(r io.Reader) error

func (*CreatedFastCell) Encode

func (*CreatedFastCell) Encode(io.Writer) error

func (*CreatedFastCell) GetCircuitID

func (c *CreatedFastCell) GetCircuitID() uint32

func (*CreatedFastCell) ID

func (*CreatedFastCell) ID() uint8

func (*CreatedFastCell) SetCircuitID

func (c *CreatedFastCell) SetCircuitID(n uint32)

type DestroyCell

type DestroyCell struct {
	CircuitID uint32

	Reason uint8
}

func (*DestroyCell) Decode

func (c *DestroyCell) Decode(r io.Reader) error

func (*DestroyCell) Encode

func (c *DestroyCell) Encode(w io.Writer) error

func (*DestroyCell) GetCircuitID

func (c *DestroyCell) GetCircuitID() uint32

func (*DestroyCell) ID

func (*DestroyCell) ID() uint8

func (*DestroyCell) SetCircuitID

func (c *DestroyCell) SetCircuitID(n uint32)

type NetInfoCell

type NetInfoCell struct {
	CircuitID uint32

	Timestamp uint32       // UNIX Timestamp (should be empty if you aren't a relay)
	OtherAddr netip.Addr   // recipient's address
	MyAdress  []netip.Addr // sender's adress (should be empty if you aren't a relay)
}

func (*NetInfoCell) Decode

func (c *NetInfoCell) Decode(r io.Reader) error

func (*NetInfoCell) Encode

func (c *NetInfoCell) Encode(w io.Writer) error

func (*NetInfoCell) GetCircuitID

func (c *NetInfoCell) GetCircuitID() uint32

func (*NetInfoCell) ID

func (*NetInfoCell) ID() uint8

func (*NetInfoCell) SetCircuitID

func (c *NetInfoCell) SetCircuitID(n uint32)

type RelayCell

type RelayCell struct {
	CircuitID uint32
	Body      []byte
}

RelayCell carries an opaque 509-byte relay body. Onion encrypt/decrypt is owned by internal/hops.Chain, not this type.

func (*RelayCell) Decode

func (c *RelayCell) Decode(r io.Reader) error

func (*RelayCell) Encode

func (c *RelayCell) Encode(w io.Writer) error

func (*RelayCell) GetCircuitID

func (c *RelayCell) GetCircuitID() uint32

func (*RelayCell) ID

func (*RelayCell) ID() uint8

func (*RelayCell) SetCircuitID

func (c *RelayCell) SetCircuitID(n uint32)

type RelayEarlyCell

type RelayEarlyCell struct {
	C *RelayCell
}

func (*RelayEarlyCell) Decode

func (c *RelayEarlyCell) Decode(r io.Reader) error

func (*RelayEarlyCell) Encode

func (c *RelayEarlyCell) Encode(w io.Writer) error

func (*RelayEarlyCell) GetCircuitID

func (c *RelayEarlyCell) GetCircuitID() uint32

func (*RelayEarlyCell) ID

func (*RelayEarlyCell) ID() uint8

func (*RelayEarlyCell) SetCircuitID

func (c *RelayEarlyCell) SetCircuitID(n uint32)

type VersionCell

type VersionCell struct {
	CircuitID uint16
	Versions  []uint16
}

func UnserializeVersionCell

func UnserializeVersionCell(b []byte) (*VersionCell, error)

func (*VersionCell) Serialize

func (cell *VersionCell) Serialize() []byte

Jump to

Keyboard shortcuts

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