readme update

This commit is contained in:
mrfry 2023-04-25 08:50:07 +02:00
parent f2655ac12a
commit 977c118da8

View file

@ -8,7 +8,7 @@ which together with this server are designed to collect questions from moodle/el
* Linux (not tested on windows) * Linux (not tested on windows)
* Cloudflare is highly recommended to hide host IP, and use its other services * Cloudflare is highly recommended to hide host IP, and use its other services
### Hardware requirements ### Other requirements
The server doesn't have high hardware requirements, but users can use it in seasonally, and in The server doesn't have high hardware requirements, but users can use it in seasonally, and in
bursts. This causes it to consume very low resources in most of the time, but can spike up quite a bursts. This causes it to consume very low resources in most of the time, but can spike up quite a
@ -25,6 +25,9 @@ of the implementation, the more cores a CPU has, the server uses more memory, bu
threads, and serve more requests at once. The used cores can be limited with environment variables threads, and serve more requests at once. The used cores can be limited with environment variables
(detailed below, `NS_THREAD_COUNT`). (detailed below, `NS_THREAD_COUNT`).
To set up and perform maintenance tasks you will need basic linux, sqlite, javascript and cloudflare
knowledge, a registered domain (or subdomain on some domain),
## Terminology ## Terminology
| Name | Description | | Name | Description |
@ -32,6 +35,7 @@ threads, and serve more requests at once. The used cores can be limited with env
| Question database | A JSON file, array of saved subjects wich have a Name, and Questions array | | Question database | A JSON file, array of saved subjects wich have a Name, and Questions array |
| Peer to peer functionality | The ability to share question databases and users with other instances of this server | | Peer to peer functionality | The ability to share question databases and users with other instances of this server |
| Peer | Another instance of this server, with peer to peer functionality set up | | Peer | Another instance of this server, with peer to peer functionality set up |
| Registered peer | A peer wich have `pw` and optionally `publicKey` specified in `peers.json` |
| User \#1 | The first user created, admin of the server | | User \#1 | The first user created, admin of the server |
| Submodule | A server submodule, dynamically loaded, and stored in `./src/modules/` | | Submodule | A server submodule, dynamically loaded, and stored in `./src/modules/` |
| Git module | Git modules stored in `./submodules` | | Git module | Git modules stored in `./submodules` |
@ -72,7 +76,10 @@ files `./src/modules.json`.
## Peer to peer ## Peer to peer
This server implements P2P functionality. It can fetch question databases and users from other This server implements P2P functionality. It can fetch question databases and users from other
server instances, and merge the response data to its own databases. server instances, and merge the response data to its own databases. The server also instantly sends
new questions received from users to all registered peers. The sync feature should be used for
initialization, new user getting, and rarely for catching up, since all new questions should be
received instantly.
To setup P2P functionality you have to create a few files in `./data/p2p`: To setup P2P functionality you have to create a few files in `./data/p2p`:
@ -82,20 +89,29 @@ To setup P2P functionality you have to create a few files in `./data/p2p`:
"name": "any name you choose", "name": "any name you choose",
"contact": "contact to server administrator (irc server, e-mail, anything)", "contact": "contact to server administrator (irc server, e-mail, anything)",
"host": "server host (like 'qmining.com', without 'http(s):// and /-s')", "host": "server host (like 'qmining.com', without 'http(s):// and /-s')",
"pw": "password to the host, so the server can log in there. Please use a dedicated password, that only the server uses!",
"port": "server port, number" "port": "server port, number"
} }
``` ```
* `peers.json` : an array, with objects same as above, and `{ publicKey: "public key of the server" * `peers.json` : an array, with objects same as above, and:
}`. Public key is used to encrypt the users database in the response, so they can be synced too. ```json
{
"pw": "password to the host, so the server can log in there. Please use a dedicated password, that only the server uses!",
"publicKey": "public key of the server"
}
```
Public key is optional, but needed to encrypt and add the users database in the response, so they
can be synced too.
New keys will be added during certain actions, such as: `sessionCookie` and `lastSync`
Uppon syncing data or having a peer request data from your server there will be new entries in Uppon syncing data or having a peer request data from your server there will be new entries in
`./data/p2p/thirdPartyPeers.json`. Here you can review the peers, see their contact and host, and if `./data/p2p/thirdPartyPeers.json`. Here you can review the peers, see their contact and host, and if
you choose you can add them to your `peers.json` file. `thirdPartyPeers.json` should also contain you choose you can add them to your `peers.json` file. `thirdPartyPeers.json` should also contain
the public key. the public key.
To start syncing user \#1 should perform a get request to `/syncp2pdata`. To start syncing user \#1 should perform a get request to `/syncp2pdata`. Received new questions are
automatically sent to registered peers.
If the peer doesn't have a https server (only http) then `http: true` should be specified in If the peer doesn't have a https server (only http) then `http: true` should be specified in
`peers.json` `peers.json`