Expand description
Shared types and protocol definitions for teter.
This crate defines the wire protocol used between all three components: frontend, relay, and backend. Messages are JSON-encoded and framed by WebSocket text frames.
Re-exports§
pub use error::ProtocolError;pub use error::ProtocolResult;
Modules§
- account
- The account protocol, on the relay’s
/accountpath: one request, one reply, per connection (JSON text frames, like the rest of the protocol). - command
- Commands from a device of the account to one of its machines (#88): to start or end a session, and later others.
- error
- Error types for the teter protocol.
Structs§
- Message
- A message sent between frontend, relay, and backend.
Enums§
- Message
Payload - Type-specific payload for a
Message. - Message
Type - All message type identifiers known to the protocol.
- Role
- An authenticated connection role on the relay.
Constants§
- BACKEND_
LEFT - The
session_errorreason when the session’s backend left: the session is gone. - MAX_
CHANNEL - The longest channel ID, in bytes.
- MIN_
PROTOCOL - The oldest relay protocol a relay of this build accepts from a client.
- PROTOCOL
- The relay protocol this build speaks (#95): the version of the messages between clients (backends, frontends) and the relay. A change a peer of the version before cannot follow raises it.
- SESSION_
GONE - The
session_errorreason when a frontend’s message finds its session already removed: the session is gone.
Functions§
- check_
protocol - Whether a relay that accepts
min..=maxserves a client of protocolclient; the refusal names both and what to upgrade. - check_
relay_ protocol - Whether a client of this build works with a relay that speaks
relay: a relay serves its version and the one before, so one older than this client is not. - deserialize_
message - Deserialize a
Messagefrom a JSON string. - ends_
the_ session - Whether a
session_errorreason says the session itself ended, as opposed to an error about one connection or one message. - machine_
proof_ message - What a machine signs to answer a challenge: this prefix, the challenge, then its ID. The prefix keeps the signature from meaning anything else.
- protocol_
of - The relay protocol a first message
jsoncarries, read loosely before the message is decoded (#95): a newer client’s message may not decode here, and it still says what to upgrade. - serialize_
message - Serialize a
Messageto a JSON string. - valid_
channel - Whether
channelcan be a channel ID: 1 toMAX_CHANNELASCII letters or digits. Opaque: a backend picks it (a random ID per session), and it never holds a session’s name.
Type Aliases§
- Session
Id - Unique identifier for a teter session.