Expand description
The Obby client engine.
One Client is one connection. It owns the registration state machine, the negotiated
capabilities and the client model. It opens no socket, reads no clock and renders nothing: the
host pushes bytes and time in, and drains bytes and events out.
use obby_client::{Client, Config, Event};
let mut client = Client::new(Config::new("mynick"));
client.handle_connected();
// whatever the host wrote is now waiting to go on the wire
let first = client.poll_transmit().expect("registration starts on connect");
assert!(first.starts_with(b"CAP LS 302"));
client.handle_bytes(b":irc.example.org CAP * LS :sasl multi-prefix\r\n");
client.handle_bytes(b":irc.example.org CAP * ACK :multi-prefix\r\n");
assert!(matches!(client.poll_event(), Some(Event::CapabilitiesAcknowledged { .. })));Re-exports§
pub use obby_proto as proto;
Structs§
- Bot
- What the server knows about a bot in a channel.
- BotCommand
- One command a bot offers.
- Bots
- The bots we know about, keyed by their folded nick.
- Capabilities
- What the server offers and what we hold.
- Capability
- One capability the server advertised, with the value it carried if any.
- Channel
- A channel we are in.
- Chat
Message - One message, as the model holds it.
- Chunk
Meta - The chunk-correlation fields riding alongside a split
sdpvalue. - Client
- One connection.
- Commands
- The set of commands the server says we may currently use.
- Config
- What a host needs to give the engine before it can connect.
- Conversation
- A private conversation with one other person.
- Fingerprint
- A peer’s identity fingerprint: the first 16 bytes of
SHA-256(signing_public_key). - Frag
- The fragmentation envelope the real client uses to split a frame too large for one wire line, on either carrier. The working client sends this, and no spec text describes it.
- Handshake
Response - The responder’s answer, decoded from the wire’s base64 JSON blob that
acceptcarries asresponse. - Identity
- A long-term identity: an X25519 agreement key and an Ed25519 signing key, generated once and kept for the lifetime of an account.
- Identity
Public - The public half of an
Identity: an X25519 agreement key (ik) and an Ed25519 signing key (sik), exactly as they travel insidePreKeyBundleandHandshakeResponse. - Invitation
- An invitation link to the network or to one channel.
- Link
Preview - A preview of a link someone posted, built by the server and attached to the message.
- Local
User - Who we are on this connection.
- Membership
- What one member holds in one channel.
- Message
Key - Where a message is ordered and how it is found again.
- Message
Log - The messages of one channel or conversation, ordered and bounded.
- Model
- Everything the connection knows.
- Now
- A moment in time, as the host’s two clocks see it.
- Participant
- One participant’s state within a
Room. - Peer
Trust - Trust-on-first-use bookkeeping for one peer.
- Pending
Offer - The offering side’s freshly generated prekeys, retained locally until the peer’s
acceptarrives. Never sent as-is;PreKeyBundleis the public half that is. - Person
- Someone we know about, held once however many channels we share.
- PreKey
Bundle - A responder-published prekey bundle, decoded from the wire’s base64 JSON blob that
initcarries asbundle. Field names match the wire exactly. - Ratchet
- One party’s half of a Double Ratchet session: a sending chain, a receiving chain, and the skipped-key store that lets messages arrive out of order.
- Ratchet
Message - One Double Ratchet message: a header carried as authenticated associated data, and an AEAD ciphertext.
- Room
- The state of one voice room: who is in it, their kind of channel, and every participant’s mic, video, speaking, deaf, screen and hand state and role.
- Scram
- An exchange in progress.
- SdpChunk
- One numbered slice of a split
offer/answerframe. - SdpReassembler
- A bounded buffer that reassembles
offer/answerframes split across chunks. - Session
- One pairwise end-to-end encrypted conversation.
- Track
Hint - A hint from the SFU mapping one negotiated media line to the member it belongs to.
- Turn
Credentials - TURN/STUN credentials the SFU hands us on
joined. - Watch
List - Who we are watching, and whether each is online.
- Whois
- What a
WHOISsaid about someone.
Enums§
- Change
- What changed, for a host that wants to react without diffing the whole model.
- Command
- Something to do on this connection.
- Credentials
- What to authenticate with.
- E2ee
Error - Everything that can go wrong here: a doomed handshake, a ratchet that refuses to advance, or a caller asking the state machine for a transition it does not allow.
- E2ee
Role - Which side of the handshake a session played, once negotiation has started.
- Event
- Something the host needs to know about.
- Frame
- One
t/vprotocol frame, exactly as the wire’s client-only tag carries it (init,accept,reject,ack,close) or, formsgandmedia, the?obe2ee:-prefixed body. - Message
Kind - What kind of thing happened.
- OnOff
- The two states an intent frame like
micorhandtoggles between. - Phase
- How far the connection has got.
- PinOutcome
- The result of observing a peer’s fingerprint against what was previously pinned for them.
- Presence
State - The
stateapresencenotification carries. - Role
- Whether a room participant may publish audio and video, or only receive it.
- Room
Kind - Who may publish in a voice room, decided by the channel’s sigil.
- Sasl
Failure - Why authentication ended without succeeding.
- Scram
Error - Why an exchange could not continue.
- Session
State - How far a conversation has got towards being encrypted.
- Severity
- How serious a
standard-repliesmessage is. - Signal
- One
+obsidianirc/rtcsignalling frame. - Toggle
Kind - Which per-participant toggle a
presencenotification reports, for its toggle sub-shape. - Typing
- Whether we are still composing a message.
Constants§
- DEFAULT_
CHUNK_ BUDGET - Default per-chunk SDP budget, in bytes.
- DEFAULT_
MAX_ CHUNKS_ PER_ REASSEMBLY - How many chunks one in-flight reassembly may claim before it is refused outright.
- DEFAULT_
MAX_ CONCURRENT_ REASSEMBLIES - How many distinct chunked signals may be reassembling at once.
- DEFAULT_
RETENTION - How many messages one channel or conversation keeps before the oldest are dropped.
- E2EE_
PROTOCOL_ VERSION - The wire’s protocol version, carried as
von every frame. Never varies today; kept as a named constant for whoever writes the wire codec rather than a magic1in two places. - MAX_
SKIP - One skip-ahead jump’s bound: a single message whose counter implies more than this many unseen messages in one chain is refused outright, rather than buffered.
- MAX_
SKIPPED_ KEYS - The total number of out-of-order message keys this ratchet will hold onto at once, across every chain it has ever had. Beyond this, the oldest key is evicted to make room, so a peer cannot exhaust memory by never sending the messages a lower counter promised.
- PRIVILEGED_
COMMANDS - Command names a self-registered bot must never be allowed to claim.
- WANTED_
CAPS - The capabilities this engine knows how to use, in the order we ask for them.
Traits§
- Random
Source - A source of random bytes, supplied by the caller.
Functions§
- accept_
offer - The responder’s reaction to an inbound
init: verify the bundle’s self-signature, derive the X3DH secret, and open a sending-only ratchet whose first message (boot) proves it derived the same secret the initiator will. - complete_
handshake - The initiator’s reaction to an inbound
accept: verify the responder’s signature over its own ephemeral key, derive the X3DH secret, and decryptbootto complete the receiving side of the ratchet. - create_
offer - Build the prekey bundle an
initframe carries: a fresh signed-prekey and one-time-prekey, signed together with the identity key by the long-term signing key. - is_
privileged - True when this command name may only be claimed by a bot an operator configured.
- keeps_
own_ offer - Decide who keeps their offer when both sides send
initat the same moment. - reassemble
- Reassemble a complete set of fragments back into the payload they were split from.
- split_
sdp - Split
sdpinto chunks of at mostbudgetbytes each, sharingid.