Documentation
¶
Index ¶
- Constants
- Variables
- type HandshakeOptions
- type Session
- func (s *Session) AcceptStream(ctx context.Context) (*q.Stream, error)
- func (s *Session) CloseWithError(code q.ApplicationErrorCode, msg string) error
- func (s *Session) Connection() *q.Conn
- func (s *Session) LocalPeerID() identity.PeerID
- func (s *Session) OpenStream(ctx context.Context) (*q.Stream, error)
- func (s *Session) RemoteCapabilities() map[string]string
- func (s *Session) RemotePeerID() identity.PeerID
- type Ticket
- type TicketStore
- func (ts *TicketStore) Cleanup() int
- func (ts *TicketStore) Count() int
- func (ts *TicketStore) DecodeTicket(data []byte) (*Ticket, error)
- func (ts *TicketStore) EncodeTicket(ticket *Ticket) ([]byte, error)
- func (ts *TicketStore) Issue(peerID identity.PeerID, sessionKey [32]byte) (*Ticket, error)
- func (ts *TicketStore) Lookup(ticketID [16]byte) (*Ticket, error)
- func (ts *TicketStore) Revoke(ticketID [16]byte)
Constants ¶
const ( TicketKeySize = 32 TicketNonceSize = 16 TicketLifetime = 24 * time.Hour )
Variables ¶
var ( ErrTicketExpired = errors.New("session: ticket expired") ErrTicketInvalid = errors.New("session: ticket invalid") ErrTicketNotFound = errors.New("session: ticket not found") )
var (
ErrHandshakeExpectedHello = errors.New("handshake expected HELLO")
)
Functions ¶
This section is empty.
Types ¶
type HandshakeOptions ¶
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 ¶
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 (*Session) LocalPeerID ¶
func (*Session) OpenStream ¶
OpenStream opens an application data stream.
func (*Session) RemoteCapabilities ¶
func (*Session) RemotePeerID ¶
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) 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) 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.