session

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TicketKeySize   = 32
	TicketNonceSize = 16
	TicketLifetime  = 24 * time.Hour
)

Variables

View Source
var (
	ErrTicketExpired  = errors.New("session: ticket expired")
	ErrTicketInvalid  = errors.New("session: ticket invalid")
	ErrTicketNotFound = errors.New("session: ticket not found")
)
View Source
var (
	ErrHandshakeExpectedHello = errors.New("handshake expected HELLO")
)

Functions

This section is empty.

Types

type HandshakeOptions

type HandshakeOptions struct {
	Capabilities map[string]string
}

type Session

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

Session is an authenticated I6P session over a QUIC connection. The QUIC connection provides encryption; identity is bound via the signed HELLO exchange.

func HandshakeClient

func HandshakeClient(ctx context.Context, conn *q.Conn, kp identity.KeyPair, opts HandshakeOptions) (*Session, error)

HandshakeClient performs the I6P session handshake as a client. The client opens a dedicated control stream.

func HandshakeServer

func HandshakeServer(ctx context.Context, conn *q.Conn, kp identity.KeyPair, opts HandshakeOptions) (*Session, error)

HandshakeServer performs the I6P session handshake as a server. The server accepts a dedicated control stream (opened by the client).

func (*Session) AcceptStream

func (s *Session) AcceptStream(ctx context.Context) (*q.Stream, error)

AcceptStream accepts an application data stream, skipping the control stream.

func (*Session) CloseWithError

func (s *Session) CloseWithError(code q.ApplicationErrorCode, msg string) error

func (*Session) Connection

func (s *Session) Connection() *q.Conn

func (*Session) LocalPeerID

func (s *Session) LocalPeerID() identity.PeerID

func (*Session) OpenStream

func (s *Session) OpenStream(ctx context.Context) (*q.Stream, error)

OpenStream opens an application data stream.

func (*Session) RemoteCapabilities

func (s *Session) RemoteCapabilities() map[string]string

func (*Session) RemotePeerID

func (s *Session) RemotePeerID() identity.PeerID

type Ticket

type Ticket struct {
	ID         [16]byte // unique ticket identifier
	IssuedAt   int64    // unix timestamp
	ExpiresAt  int64
	PeerID     identity.PeerID
	SessionKey [32]byte // pre-shared key for resumed session
}

Ticket enables fast session resumption without full handshake. The ticket contains encrypted session state that only the issuer can decrypt.

type TicketStore

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

TicketStore manages session tickets for resumption.

func NewTicketStore

func NewTicketStore() (*TicketStore, error)

NewTicketStore creates a new ticket store.

func NewTicketStoreWithKey

func NewTicketStoreWithKey(key [TicketKeySize]byte) *TicketStore

NewTicketStoreWithKey creates a ticket store with a specific key (for clustering).

func (*TicketStore) Cleanup

func (ts *TicketStore) Cleanup() int

Cleanup removes expired tickets.

func (*TicketStore) Count

func (ts *TicketStore) Count() int

Count returns the number of active tickets.

func (*TicketStore) DecodeTicket

func (ts *TicketStore) DecodeTicket(data []byte) (*Ticket, error)

DecodeTicket decrypts and validates a ticket from wire format.

func (*TicketStore) EncodeTicket

func (ts *TicketStore) EncodeTicket(ticket *Ticket) ([]byte, error)

EncodeTicket encrypts a ticket for wire transmission. Format: ticketID (16) || nonce (16) || encrypted data

func (*TicketStore) Issue

func (ts *TicketStore) Issue(peerID identity.PeerID, sessionKey [32]byte) (*Ticket, error)

Issue creates a new ticket for the given peer and session key.

func (*TicketStore) Lookup

func (ts *TicketStore) Lookup(ticketID [16]byte) (*Ticket, error)

Lookup retrieves and validates a ticket.

func (*TicketStore) Revoke

func (ts *TicketStore) Revoke(ticketID [16]byte)

Revoke invalidates a ticket.

Jump to

Keyboard shortcuts

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