systemquery/docs/protocol.md

58 lines
1.4 KiB
Markdown
Raw Normal View History

2022-02-09 03:05:48 +00:00
# systemquery protocol
This document details the protocol implemented by systemquery. The protocol has multiple layers to it - these are documented each in their own sections:
1. Framed transport
2. Encryption
3. JSON messages
- Also handles key exchange
The protocol aims to have the following properties:
- It's peer-to-peer
- It's decentralised (i.e. there's no leading peer)
- This may change in the future if there's a need for a leading peer
- It follows existing established standards where possible
- All communication is encrypted
- In order to join, peers must know the same join secret (aka a pre-shared key)
- In the future, full mesh network routing
The following properties are out-of-scope:
- Tolerate malicious nodes
## Framed Transport
## JSON messages
JSON messages look like this:
```json
{
"event": "EVENT_NAME",
"message": { "message_object": "here" }
}
```
The following event names and their associated message objects are listed below:
### Event `query`
The sender requests a table from the receiver.
Properties:
- **string `name`:** The name of the table being requested.
### Event `query-response`
The send response to the receiver's earlier `query` message.
Properties:
- **string `name`:** The name of the table.
- **object `table`:** The requested table.
### Event `end`
Explicitly tells the receiver that the send is going away.
_(this event has no properties)_