/
doc.go
71 lines (58 loc) · 4.34 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
Package client implements a CR complient client.
The diagram below shows the major layers of the client. Depicted is Alice
sending a message while Bob is receiving it.
Alice server Bob
+----------+ +----------+
| Client | | Client |
+----------+ +----------+
| |
| |
| |
+------------+ +------------+
| RemoteUser | . . . . . . . . . . . . . . . . . . . . . | RemoteUser |
+------------+ +------------+
| |
| |
| |
+---------+ +-----------------+ +---------------+
| rmq | . . . . . . | subscriptions |. . . . . .| rdzvManager |
+---------+ +-----------------+ +---------------+
| | |
| | |
| | |
+-----------------+ +------------------+ +-----------------+
---------->| serverSession | . . . . | client session | . . . . | serverSession |
/ +-----------------+ +------------------+ +-----------------+
/ / | | |
+-------------+ / | | |
| connKeeper |<------- | | |
+-------------+ +-------+ +-------+ +-------+
| net |-------------------| net |-------------------- | net |
+-------+ +-------+ +-------+
Each layer has certain specific responsibilities and attempts to maintain
certain invariants for the other layers:
- `net`: Lower-level network connection (currently TLS)
- `connKeeper`: Attempts to keep an open connection to the server. Whenever a
new connection is made, a new instance of `serverSession` is created
- `serverSession`: Maintains the tag stack invariant (max inflight, non-acked
messages to the server), encrypts/decrypts the wire msgs w/ the per-session
key
- `rmq`: outbound RoutedMessages queue; pays for each outbound RM before
sending it, encrypts each RM according to its type (clear text, kx, ratchet)
- `rdzvManager`: Rendezvous Manager, is the inbound RM queue; ensures the
client is subscribed to the appropriate RV points in the server as needed
and decides which `remoteUser` to call for every pushed RM
- `RemoteUser`: holds the ratchet state for each user the client has completed
a kx flow with and progresses it as RMs are sent and received. Also
implements per-user higher level calls (send/receive PMs, files, etc)
Each layer is tipically implemented as a runnable state machine, where its
API is (usually) synchronous and concurrent-safe and actions are
performed in its `run()` call.
The main public-facing structures of this package are `Config` and `Client`.
Consumers (e.g. a GUI or CLI client app) setup a `Config` instance as needed,
create a new client instance and run it. The client will maintain its operations
until one of its subsystems fail (in which case `Run()` returns with an error)
or the context is canceled.
*/
package client