Documentation
¶
Index ¶
- Constants
- Variables
- func DeriveSessionKey(masterKey, sharedSecret, salt []byte, roomID, clientID, serverID string, ...) ([]byte, error)
- func ICECandidateSize(candidate *webrtc.ICECandidateInit) int
- func ServerIDFromPublicKey(publicKey crypto.PublicKey) (string, error)
- func SignServerHello(privateKey ed25519.PrivateKey, roomID, clientID, serverID string, ...) ([]byte, error)
- func ValidateClientCredentials(clientID string, key []byte) error
- func ValidateClientID(clientID string) error
- func VerifyServerHello(publicKey ed25519.PublicKey, roomID, clientID, serverID string, ...) bool
- type Addr
- type ByteBudget
- type CallbackPool
- type Codec
- func (e *Codec) DecodeMessage(data []byte) (*Message, error)
- func (e *Codec) DecodeMessageHeader(data []byte) (*Header, error)
- func (e *Codec) DecodeWithDecryption(data []byte) ([]byte, error)
- func (e *Codec) DecodeWithDecryptionLimit(data []byte, maxDecodedSize int) ([]byte, error)
- func (e *Codec) EncodeMessage(m *Message) ([]byte, error)
- func (e *Codec) EncodeWithEncryption(data []byte) ([]byte, error)
- func (e *Codec) GetSecret() (typ string, secret []byte)
- func (e *Codec) UpdateSecret(encryptionType string, secret []byte) error
- type Header
- type KeyProvider
- type KeyProviderFunc
- type Message
- type MessageType
- type Payload
- type PreSharedKey
- type RecvBuffer
- type ReplayWindow
- type StaticKeyring
Constants ¶
const ( ENCRYPT_PARTIALY = 0x00 ENCRYPT_GLOBALLY = 0x01 )
const ( INDEX_HEADER = iota INDEX_PAYLOAD INDEX_ENCRYPT_FLAG INDEX_PACKET_LENGTH )
const ( HandshakeNonceSize = 32 HandshakeKeySize = 32 )
const DefaultReceiveBufferSize = 8 << 20
const MaxClientIDLength = 128
Variables ¶
var ErrReceiveBufferFull = errors.New("receive buffer limit exceeded")
var ErrUnknownClient = errors.New("unknown client")
Functions ¶
func DeriveSessionKey ¶
func DeriveSessionKey( masterKey, sharedSecret, salt []byte, roomID, clientID, serverID string, clientNonce, serverNonce, clientEphemeralKey, serverEphemeralKey []byte, ) ([]byte, error)
DeriveSessionKey creates a key scoped to one room, client, pinned server, and handshake. The salt is freshly generated for every successful handshake.
func ICECandidateSize ¶
func ICECandidateSize(candidate *webrtc.ICECandidateInit) int
func SignServerHello ¶
func ValidateClientID ¶
Types ¶
type Addr ¶
Addr implements net.Addr for a room-scoped Telekit endpoint.
func AddrFromNet ¶ added in v0.0.2
AddrFromNet returns a room-scoped address with the host and port extracted from a selected ICE transport address.
type ByteBudget ¶
type ByteBudget struct {
// contains filtered or unexported fields
}
ByteBudget is a concurrency-safe shared memory budget. It is used by a server to cap unread application data across all of its connections.
func NewByteBudget ¶
func NewByteBudget(limit int64) *ByteBudget
func (*ByteBudget) Release ¶
func (b *ByteBudget) Release(n int)
func (*ByteBudget) Reserve ¶
func (b *ByteBudget) Reserve(n int) bool
func (*ByteBudget) Used ¶
func (b *ByteBudget) Used() int64
type CallbackPool ¶
type CallbackPool struct {
// contains filtered or unexported fields
}
CallbackPool bounds asynchronous application callback concurrency and backlog. Submit never blocks the WebRTC receive loop.
func NewCallbackPool ¶
func NewCallbackPool(workers, queueSize int) *CallbackPool
func (*CallbackPool) Close ¶
func (p *CallbackPool) Close()
func (*CallbackPool) Submit ¶
func (p *CallbackPool) Submit(callback func()) bool
func (*CallbackPool) SubmitWithCancel ¶
func (p *CallbackPool) SubmitWithCancel(callback, cancel func()) bool
type Codec ¶
type Codec struct {
// contains filtered or unexported fields
}
func (*Codec) DecodeMessageHeader ¶
func (*Codec) DecodeWithDecryption ¶
func (*Codec) DecodeWithDecryptionLimit ¶
func (*Codec) EncodeWithEncryption ¶
type Header ¶
type KeyProvider ¶
KeyProvider resolves client identities without exposing a peer ID to the client-facing connection API.
type KeyProviderFunc ¶
type MessageType ¶
type MessageType string
const ( MessageTypeClientHello MessageType = "client_hello" MessageTypeServerHello MessageType = "server_hello" MessageTypeOffer MessageType = "offer" MessageTypeAnswer MessageType = "answer" MessageTypeICE MessageType = "ice" MessageTypeTransportSelect MessageType = "transport_select" MessageTypeICEOffer MessageType = "ice_offer" MessageTypeICEAnswer MessageType = "ice_answer" MessageTypeDisconnect MessageType = "disconnect" )
type Payload ¶
type Payload struct {
SDP *webrtc.SessionDescription
ICE *webrtc.ICECandidateInit
SessionSalt []byte
ClientNonce []byte
ServerNonce []byte
ClientEphemeralKey []byte
ServerEphemeralKey []byte
Signature []byte
HandshakeRoomID string
HandshakeClientID string
Timestamp []byte
// Transports is populated in ServerHello. Transport is the client choice.
Transports []string
Transport string
ICEUsername string
ICEPassword string
ICECandidates []string
Data any
}
type PreSharedKey ¶
PreSharedKey couples the public client identity used for routing with its secret authentication key and the pinned server identity. Key should contain at least 256 bits of random material; it is never sent over signaling.
func (PreSharedKey) Validate ¶
func (p PreSharedKey) Validate() error
type RecvBuffer ¶
type RecvBuffer struct {
// contains filtered or unexported fields
}
RecvBuffer is a thread-safe, blocking read buffer that delivers complete reassembled messages in order. Read blocks until data is available or the buffer is closed. Write pushes data in and signals any blocked Read calls. Close signals EOF to all blocked Read calls.
func NewRecvBuffer ¶
func NewRecvBuffer() *RecvBuffer
func NewRecvBufferWithLimit ¶
func NewRecvBufferWithLimit(limit int, budget *ByteBudget) *RecvBuffer
func (*RecvBuffer) Close ¶
func (rb *RecvBuffer) Close()
Close marks the buffer as closed and unblocks all pending Read calls. Unread data is discarded so shared server memory is released immediately. Safe to call multiple times.
func (*RecvBuffer) Read ¶
func (rb *RecvBuffer) Read(p []byte) (int, error)
Read blocks until data is available or the buffer is closed. Returns io.EOF when the buffer has been closed and is empty.
func (*RecvBuffer) SetDeadline ¶
func (rb *RecvBuffer) SetDeadline(deadline time.Time)
func (*RecvBuffer) Write ¶
func (rb *RecvBuffer) Write(data []byte) error
Write appends data to the buffer and wakes a waiting Read.
type ReplayWindow ¶
type ReplayWindow struct {
// contains filtered or unexported fields
}
ReplayWindow accepts each non-zero sequence number once while allowing bounded out-of-order delivery. It is safe for concurrent signaling handlers.
func (*ReplayWindow) Accept ¶
func (w *ReplayWindow) Accept(sequence uint64) bool
func (*ReplayWindow) Reset ¶
func (w *ReplayWindow) Reset()
type StaticKeyring ¶
StaticKeyring is a convenient KeyProvider for small deployments.