tracex

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: GPL-3.0 Imports: 5 Imported by: 1

Documentation

Overview

Package tracex implements a handshake tracer that can be passed to the TUN constructor to observe handshake events.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	// EventType is the type for this event.
	EventType string `json:"operation"`

	// Stage is the stage of the handshake negotiation we're in.
	Stage string `json:"stage"`

	// AtTime is the time for this event, relative to the start time.
	AtTime float64 `json:"t"`

	// Tags is an array of tags that can be useful to interpret this event, like the contents of the packet.
	Tags []string `json:"tags"`

	// LoggedPacket is an optional packet metadata.
	LoggedPacket optional.Value[LoggedPacket] `json:"packet"`

	// TransactionID is an optional index identifying one particular handshake.
	TransactionID int64 `json:"transaction_id,omitempty"`
}

Event is a handshake event collected by this model.HandshakeTracer.

type HandshakeEventType

type HandshakeEventType int

HandshakeEventType indicates which event we logged.

func (HandshakeEventType) String

func (e HandshakeEventType) String() string

String implements fmt.Stringer

type LoggedPacket

type LoggedPacket struct {
	Direction string `json:"operation"`

	// the only fields of the packet we want to log.
	Opcode string                           `json:"opcode"`
	ID     model.PacketID                   `json:"id"`
	ACKs   optional.Value[[]model.PacketID] `json:"acks"`

	// PayloadSize is the size of the payload in bytes
	PayloadSize int `json:"payload_size"`

	// Retries keeps track of packet retransmission (only for outgoing packets).
	Retries optional.Value[int] `json:"send_attempts"`
}

LoggedPacket tracks metadata about a packet useful to build traces.

type NegotiationState

type NegotiationState = model.NegotiationState

type Tracer

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

Tracer implements model.HandshakeTracer.

func NewTracer

func NewTracer(start time.Time) *Tracer

NewTracer returns a Tracer with the passed start time.

func NewTracerWithTransactionID

func NewTracerWithTransactionID(start time.Time, txid int64) *Tracer

NewTracerWithTransactionID returns a Tracer with the passed start time and the given identifier for a transaction. Transaction IDs are meant as a convenience to use this tracer out-of-the-box from within the ooni probes, and it follows the expected semantics to cross-reference measurements.

func (*Tracer) OnDroppedPacket

func (t *Tracer) OnDroppedPacket(direction model.Direction, stage NegotiationState, packet *model.Packet)

OnDroppedPacket is called whenever a packet is dropped (in/out)

func (*Tracer) OnIncomingPacket

func (t *Tracer) OnIncomingPacket(packet *model.Packet, stage NegotiationState)

OnIncomingPacket is called when a packet is received.

func (*Tracer) OnOutgoingPacket

func (t *Tracer) OnOutgoingPacket(packet *model.Packet, stage NegotiationState, retries int)

OnOutgoingPacket is called when a packet is about to be sent.

func (*Tracer) OnStateChange

func (t *Tracer) OnStateChange(state NegotiationState)

OnStateChange is called for each transition in the state machine.

func (*Tracer) TimeNow

func (t *Tracer) TimeNow() time.Time

TimeNow allows to manipulate time for deterministic tests.

func (*Tracer) Trace

func (t *Tracer) Trace() []*Event

Trace returns a structured log containing a copy of the array of model.HandshakeEvent.

Jump to

Keyboard shortcuts

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