cryptpad-server 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/core.js +60 -51
- package/build/core.worker.js +53 -44
- package/build/front.js +60 -51
- package/build/http.js +60 -51
- package/build/http.worker.js +1 -1
- package/build/storage.cluster.js +54 -45
- package/build/storage.js +60 -51
- package/build/storage.worker.js +54 -45
- package/build/websocket.js +35556 -0
- package/build/ws.worker.js +46222 -0
- package/index.js +3 -2
- package/package.json +1 -1
- package/readme.md +41 -44
package/index.js
CHANGED
|
@@ -8,8 +8,9 @@ const Path = require('node:path');
|
|
|
8
8
|
const showHelp = () => {
|
|
9
9
|
console.log(`Usage ${process.argv[1]}:`);
|
|
10
10
|
console.log("\t--help, -h\tDisplay this help");
|
|
11
|
-
console.log("\t--type,-t\tSet the
|
|
12
|
-
console.log("\t--index,-i\tSet the
|
|
11
|
+
console.log("\t--type,-t\tSet the node type (if unset, starts every node)");
|
|
12
|
+
console.log("\t--index,-i\tSet the node index (default: 0)");
|
|
13
|
+
console.log("\t--server,-s\tStart the set of nodes identified with serverId");
|
|
13
14
|
process.exit(1);
|
|
14
15
|
};
|
|
15
16
|
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
SPDX-License-Identifier: AGPL-3.0-or-later
|
|
4
4
|
-->
|
|
5
|
-
# Prototype: Scalable Server for CryptPad
|
|
6
5
|
|
|
7
|
-
This repository contains
|
|
8
|
-
still in progress exploratory work.
|
|
6
|
+
This repository contains the code for CryptPad server.
|
|
9
7
|
|
|
10
8
|
## Architecture
|
|
11
9
|
|
|
@@ -23,54 +21,32 @@ they can be done in place without too much pressure on them.
|
|
|
23
21
|
|
|
24
22
|
### Topology
|
|
25
23
|
|
|
26
|
-
The core nodes are connected to both
|
|
27
|
-
cannot communicate directly.
|
|
24
|
+
The core nodes are connected to both front and storage nodes, but the latter two
|
|
25
|
+
cannot communicate directly (only on the same layer).
|
|
28
26
|
|
|
29
27
|
## Configuration
|
|
30
28
|
|
|
31
|
-
The configuration can be done
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
Using websockets for communication, this variable looks like this:
|
|
35
|
-
|
|
36
|
-
```javascript
|
|
37
|
-
let Config = {
|
|
38
|
-
infra: {
|
|
39
|
-
ws: [{
|
|
40
|
-
host: 'localhost',
|
|
41
|
-
port: 3010
|
|
42
|
-
}],
|
|
43
|
-
core: [{
|
|
44
|
-
host: 'localhost',
|
|
45
|
-
port: 3011
|
|
46
|
-
}, {
|
|
47
|
-
host: 'localhost',
|
|
48
|
-
port: 3012
|
|
49
|
-
}],
|
|
50
|
-
storage: [{
|
|
51
|
-
host: 'localhost',
|
|
52
|
-
port: 3014
|
|
53
|
-
}]
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
The above configuration describes a network comprised of 4 nodes, having one
|
|
59
|
-
front node on port `3010`, 2 core servers on port `3011` and `3012`
|
|
60
|
-
and a storage node accessible via port `3014`.
|
|
29
|
+
The configuration can be done in `config/infra.js`, which will store the graph
|
|
30
|
+
topology of the nodes and how to connect to them.
|
|
61
31
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
node (the node listening on port `3011`), it would be `Config.myId = 'core:0'`.
|
|
32
|
+
Using websockets for communication, please look at `config/infra.example.js` for
|
|
33
|
+
explanations.
|
|
65
34
|
|
|
66
35
|
## Usage
|
|
67
36
|
|
|
68
|
-
|
|
37
|
+
To be used in CryptPad, this repository releases are available on npm:
|
|
38
|
+
https://www.npmjs.com/package/cryptpad-server
|
|
39
|
+
|
|
40
|
+
You can also use it in standalone mode for development purpose. The client code
|
|
41
|
+
should be present in `../cryptpad/` or in a `clientRoot` property as a string in
|
|
42
|
+
`config/config.js`. Before first use, you may want to install the dependencies
|
|
43
|
+
and build the code with:
|
|
69
44
|
```bash
|
|
70
45
|
npm install
|
|
46
|
+
npm run build
|
|
71
47
|
```
|
|
72
48
|
|
|
73
|
-
To spawn the server topology described in `
|
|
49
|
+
To spawn the server topology described in `infra/config.js`, run the start script:
|
|
74
50
|
```bash
|
|
75
51
|
npm run start
|
|
76
52
|
```
|
|
@@ -78,14 +54,35 @@ npm run start
|
|
|
78
54
|
Alternatively, you can the new servers manually. You first need to start the
|
|
79
55
|
`core` nodes with the following command.
|
|
80
56
|
|
|
57
|
+
For that to work, you need to have a shared key between the different nodes to
|
|
58
|
+
authenticate them, which can be generated with:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
openssl rand -base64 32
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Then add the resulting random bytes in `private.nodes_key` property in your
|
|
65
|
+
`config/config.js`.
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
node index.js --type core --index 0
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Then you can start a `front` and `storage` nodes in any order:
|
|
81
72
|
```bash
|
|
82
|
-
node
|
|
73
|
+
node index.js --type front --index 0
|
|
74
|
+
node index.js --type storage --index 0
|
|
75
|
+
node index.js --type front --index 1
|
|
76
|
+
node index.js --type storage --index 2
|
|
77
|
+
node index.js --type storage --index 1
|
|
83
78
|
```
|
|
84
79
|
|
|
85
|
-
|
|
80
|
+
Alternatively, you can identify different sets of nodes with the `serverId`
|
|
81
|
+
property of their corresponding nodes in `config/infra.js`, and start a subset
|
|
82
|
+
of them sharing the same `serverId` with:
|
|
83
|
+
|
|
86
84
|
```bash
|
|
87
|
-
node
|
|
88
|
-
node front/index.js
|
|
85
|
+
node index.js --server [serverId value]
|
|
89
86
|
```
|
|
90
87
|
|
|
91
88
|
## Tests
|