snakeia-server 1.1.3-3

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/README.md ADDED
@@ -0,0 +1,330 @@
1
+ <img src="https://raw.githubusercontent.com/Eliastik/snakeia-server/master/assets/img/logo.png" width="300" alt="SnakeIA Server" />
2
+
3
+ # English
4
+
5
+ A server for my [SnakeIA](https://github.com/Eliastik/snakeia) game, written in JavaScript with the Socket.IO library and running on Node.js.
6
+
7
+ * Github repository: [https://github.com/Eliastik/snakeia-server](https://github.com/Eliastik/snakeia-server)
8
+
9
+ ## About this server
10
+
11
+ * Version 1.1.3.3 (3/30/2024)
12
+ * Made in France by Eliastik - [eliastiksofts.com](http://eliastiksofts.com) - Contact : [eliastiksofts.com/contact](http://eliastiksofts.com/contact)
13
+ * License: GNU GPLv3 (see LICENCE.txt file)
14
+
15
+ ## How to run the server
16
+
17
+ ### NodeJS
18
+
19
+ You can run the server on your machine. To do this, you have to install Node.js and npm.
20
+
21
+ To install Node.js and npm for your OS, read this page: https://docs.npmjs.com/getting-started/installing-node
22
+
23
+ Git clone the repository and cd to the project directory (or download it directly from Github):
24
+ ````
25
+ git clone https://github.com/Eliastik/snakeia-server.git
26
+ cd snakeia-server
27
+ ````
28
+
29
+ Install the dependencies:
30
+ ````
31
+ npm install
32
+ ````
33
+
34
+ Then to run the server:
35
+ ````
36
+ npm start
37
+ ````
38
+
39
+ The server will by default run on the port 3000.
40
+
41
+ ### Docker
42
+
43
+ You can also run the server with the Docker image using the docker-compose.yml file.
44
+ Don't forget to edit the file to include your local configuration file:
45
+
46
+ ````
47
+ volumes:
48
+ - ./config/default.json:/home/snakeia-server/server/config/default.json
49
+ ````
50
+
51
+ Replace ./config/default.json with the location of your configuration file.
52
+ See the section below to know how to configurate the server.
53
+
54
+ Also, change the running port for the server:
55
+
56
+ ````
57
+ ports:
58
+ - "3000:3000"
59
+ ````
60
+
61
+ You can specify any port for the first part of the rule, but the second part must be the same port as configured in the config file.
62
+
63
+ Then run this command in the directory of the docker-compose.yml file to run the server:
64
+
65
+ ````
66
+ docker-compose up
67
+ ````
68
+
69
+ ## Config file explanations (default config)
70
+
71
+ The server uses [node-config](https://github.com/lorenwest/node-config) for the configuration files.
72
+ You can create another configuration file in the **config** directory named **local.json** to override the default config file. [See this doc](https://github.com/lorenwest/node-config/wiki/Configuration-Files).
73
+
74
+ ````
75
+ {
76
+ "ServerConfig": {
77
+ "version": "1.1.3.3", // The server version
78
+ "port": 3000, // The port where the server runs
79
+ "proxyMode": false, // Set this value to true if your server is behind a proxy - defaults to false
80
+ "enableMultithreading": true, // Enabling the use of different threads for the game engine, improves performance / requires a version of Nodejs that supports Worker Threads
81
+ "maxPlayers": 20, // The maximum number of players for each room
82
+ "maxRooms": 20, // The maximum number of room
83
+ "minGridSize": 5, // The minimum size for a grid (width and height)
84
+ "maxGridSize": 50, // The maximum size for a grid (width and height)
85
+ "minSpeed": 1, // The minimum speed
86
+ "maxSpeed": 100, // The maximum speed
87
+ "enableAI": false, // Disable or enable AIs
88
+ "playerWaitTime": 45000, // The time while waiting for players to join a room (ms)
89
+ "enableMaxTimeGame": true, // Enable time limit for each game
90
+ "maxTimeGame": 300000, // The time limit for each game (ms)
91
+ "enableAuthentication": true, // Enable authentification when connecting to the server
92
+ "authenticationTime": 86400000, // The duration of authentication token (ms)
93
+ "jsonWebTokenSecretKey": "", // A private key for signing a token (if not provided, a random key will be generated)
94
+ "jsonWebTokenSecretKeyAdmin": "", // A private key for signing an admin token - should be different from previous value (if not provided, a random key will be generated)
95
+ "minCharactersUsername": 3, // The minimum number of characters for the username
96
+ "maxCharactersUsername": 15, // The maximum number of characters for the username
97
+ "enableRecaptcha": true, // Enable ReCaptcha
98
+ "recaptchaApiUrl": "https://www.google.com/recaptcha/api/siteverify", // ReCaptcha API URL
99
+ "recaptchaPublicKey": "", // ReCaptcha public key (if not provided, the ReCaptcha will be disabled)
100
+ "recaptchaPrivateKey": "", // ReCaptcha private key (if not provided, the ReCaptcha will be disabled)
101
+ "authentMaxRequest": 50, // Maximum request for authentication
102
+ "authentWindowMs": 900000, // Time when the authentication requests are saved (ms)
103
+ "ipBan": [], // A list of IP to ban
104
+ "usernameBan": [], // A list of usernames to ban
105
+ "contactBan": "", // A contact URL displayed when an user is banned
106
+ "enableLoggingFile": true, // Enable logging into file
107
+ "logFile": "logs/server.log", // Log file
108
+ "errorLogFile": "logs/error.log", // Error log file
109
+ "logLevel": "debug" // Log level (see Winston documentation),
110
+ "adminAccounts": { // User accounts of the administrator panel (can be accessed at serverDomain/admin)
111
+ "test": { // Username
112
+ "password": "", // Password SHA-512 hash
113
+ "role": "administrator" // Role (administrator or moderator) - defaults to moderator
114
+ }
115
+ }
116
+ }
117
+ }
118
+ ````
119
+
120
+ ## Changelog
121
+
122
+ * Version 1.1.3.3 (3/30/2024) :
123
+ - Updated dependencies
124
+
125
+ * Version 1.1.3.2 (3/23/2024) :
126
+ - Updated dependencies
127
+
128
+ * Version 1.1.3.1 (9/24/2023) :
129
+ - Updated dependencies
130
+
131
+ * Version 1.1.3 (3/29/2021) :
132
+ - Using node-config
133
+ - Updated dependencies
134
+
135
+ * Version 1.1.2 (10/18/2020):
136
+ - Version based on SnakeIA version 2.2.
137
+
138
+ * Version 1.1.1 (6/1/2020):
139
+ - Worker (multi-threading) errors are now logged ;
140
+ - Version based on SnakeIA version 2.1.1.
141
+
142
+ * Version 1.1 (5/4/2020):
143
+ - Added an administration panel (can be accessed at serverDomain/admin). The accounts are configurable via the configuration file (two possible roles: moderator or administrator);
144
+ - Games are now multithreaded by default, this improves performance (can be disabled in the configuration file);
145
+ - Maximum time limit per game (configurable);
146
+ - Added the possibility of adding IAs to a game (can be disabled in the configuration file);
147
+ - Bug fixes and other adjustments:
148
+ - The state of a game is sent directly to the spectators;
149
+ - It's now impossible to choose the same username as another user;
150
+ - Corrections of other bugs and adjustments.
151
+ - Version based on SnakeIA version 2.1.
152
+
153
+ # Français
154
+
155
+ Un serveur pour mon jeu [SnakeIA](https://github.com/Eliastik/snakeia), écrit en JavaScript avec la bibliothèque logicielle Socket.IO et tournant via Node.js.
156
+
157
+ * Dépôt Github : [https://github.com/Eliastik/snakeia-server](https://github.com/Eliastik/snakeia-server)
158
+
159
+ ## À propos de ce serveur
160
+
161
+ * Version 1.1.3.3 (30/03/2024)
162
+ * Made in France by Eliastik - [eliastiksofts.com](http://eliastiksofts.com) - Contact : [eliastiksofts.com/contact](http://eliastiksofts.com/contact)
163
+ * Licence : GNU GPLv3 (voir le fichier LICENCE.txt)
164
+
165
+ ## Comment lancer le serveur
166
+
167
+ ### NodeJS
168
+
169
+ Vous pouvez lancer le serveur sur votre machine. Pour cela, vous devez avoir installé Node.js et npm.
170
+
171
+ Pour installer Node.js et npm sur votre système, suivez le guide : https://docs.npmjs.com/getting-started/installing-node
172
+
173
+ Effectuez un clonage du dépôt et déplacez-vous dedans (ou téléchargez-le directement depuis Github) :
174
+ ````
175
+ git clone https://github.com/Eliastik/snakeia-server.git
176
+ cd snakeia-server
177
+ ````
178
+
179
+ Puis lancez cette commande pour installer les dépendances :
180
+ ````
181
+ npm install
182
+ ````
183
+
184
+ Puis pour lancer le serveur :
185
+ ````
186
+ npm start
187
+ ````
188
+
189
+ Le serveur va se lancer sur le port 3000 par défaut.
190
+
191
+ ### Docker
192
+
193
+ Vous pouvez aussi lancer le serveur en utilisant l'image Docker avec le fichier docker-compose.yml.
194
+ N'oubliez pas de modifier ce fichier avec l'emplacement de votre fichier de configuration :
195
+
196
+ ````
197
+ volumes:
198
+ - ./config/default.json:/home/snakeia-server/server/config/default.json
199
+ ````
200
+
201
+ Remplacez ./config/default.json par l'emplacement du fichier de configuration.
202
+ Consultez la section plus bas pour savoir comment configurer le serveur.
203
+
204
+ Changez également le port sur lequel le serveur écoute :
205
+
206
+ ````
207
+ ports:
208
+ - "3000:3000"
209
+ ````
210
+
211
+ Vous pouvez indiquer n'importe quel port pour la première partie de la règle, mais la seconde partie doit être cohérente avec la configuration du serveur.
212
+
213
+ Ensuite, lancez cette commande pour lancer le serveur :
214
+
215
+ ````
216
+ docker-compose up
217
+ ````
218
+
219
+ ## Explications du fichier de configuration (configuration par défaut)
220
+
221
+ Le serveur utilise [node-config](https://github.com/lorenwest/node-config) pour les fichiers de configuration.
222
+ Vous pouvez créer un fichier de configuration **local.json** dans le dossier **config** pour remplacer la configuration par défaut. [Voir cette doc](https://github.com/lorenwest/node-config/wiki/Configuration-Files).
223
+
224
+ ````
225
+ {
226
+ "ServerConfig": {
227
+ "version": "1.1.3.3", // La version du serveur
228
+ "port": 3000, // Le port sur lequel lancer le server
229
+ "proxyMode": false, // Mettez à true si votre serveur est derrière un proxy - par défaut false
230
+ "enableMultithreading": true, // Activer l'utilisation de threads différents pour le moteur de jeu, améliore les performances / nécessite une version de Nodejs qui supporte les Worker Threads
231
+ "maxPlayers": 20, // Le nombre maximal d'utilisateurs par salle
232
+ "maxRooms": 20, // Le nombre maximal de salles
233
+ "minGridSize": 5, // La taille minimale pour une grille (largeur et hauteur)
234
+ "maxGridSize": 50, // La taille maximale pour une grille (largeur et hauteur)
235
+ "minSpeed": 1, // La vitesse minimale
236
+ "maxSpeed": 100, // La vitesse maximale
237
+ "enableAI": false, // Désactiver ou activer les IA
238
+ "playerWaitTime": 45000, // Le temps durant lequel attendre la connexion d'autres joueurs à la salle (ms)
239
+ "enableMaxTimeGame": true, // Activer la limite de temps pour chaque partie
240
+ "maxTimeGame": 300000, // La limite de temps pour chaque partie (ms)
241
+ "enableAuthentication": true, // Activer l'authentification lors de la connexion au serveur
242
+ "authenticationTime": 86400000, // La durée de vie d'un token d'authentification
243
+ "jsonWebTokenSecretKey": "", // Une clée privée pour signer un token (si non fournie, une clé sera générée au hasard)
244
+ "jsonWebTokenSecretKeyAdmin": "", // Une clée privée pour signer un token d'administration - doit être différente de la valeur précédente (si non fournie, une clé sera générée au hasard)
245
+ "minCharactersUsername": 3, // Le nombre minimal de caractères pour le nom d'utilisateur
246
+ "maxCharactersUsername": 15, // Le nombre maximal de caractères pour le nom d'utilisateur
247
+ "enableRecaptcha": true, // Activer le ReCaptcha
248
+ "recaptchaApiUrl": "https://www.google.com/recaptcha/api/siteverify", // URL de l'API ReCaptcha
249
+ "recaptchaPublicKey": "", // Clé publique ReCaptcha (si non fournie, le ReCaptcha sera désactivé)
250
+ "recaptchaPrivateKey": "", // Clé privée ReCaptcha (si non fournie, le ReCaptcha sera désactivé)
251
+ "authentMaxRequest": 50, // Nombre maximal de requêtes lors de l'authentification
252
+ "authentWindowMs": 900000, // Temps durant lequel les tentatives d'authentification seront enregistrées (ms)
253
+ "ipBan": [], // Une liste d'IPs à bannir
254
+ "usernameBan": [], // Une liste de noms d'utilisateur à bannir
255
+ "contactBan": "", // Une URL de contact à afficher lorsque l'utilisateur est banni
256
+ "enableLoggingFile": true, // Activer le log dans un fichier
257
+ "logFile": "logs/server.log", // Fichier de log
258
+ "errorLogFile": "logs/error.log", // Fichier de log d'erreurs
259
+ "logLevel": "debug" // Niveau de log (voir la documentation de Winston),
260
+ "adminAccounts": { // Compte utilisateurs du panel d'administration (peut être accédé à serverDomain/admin)
261
+ "test": { // Nom d'utilisateur
262
+ "password": "", // Hash SHA-512 du mot de passe
263
+ "role": "administrator" // Rôle (administrator ou moderator) - par défaut moderator
264
+ }
265
+ }
266
+ }
267
+ }
268
+ ````
269
+
270
+ ## Journal des changements
271
+
272
+ * Version 1.1.3.3 (30/03/2024) :
273
+ - Mise à jour des dépendences
274
+
275
+ * Version 1.1.3.2 (23/03/2024) :
276
+ - Mise à jour des dépendences
277
+
278
+ * Version 1.1.3.1 (24/09/2023) :
279
+ - Mise à jour des dépendences
280
+
281
+ * Version 1.1.3 (29/03/2021) :
282
+ - Utilisation de node-config
283
+ - Mise à jour des dépendences
284
+
285
+ * Version 1.1.2 (18/10/2020) :
286
+ - Version basée sur la version 2.2 de SnakeIA.
287
+
288
+ * Version 1.1.1 (01/06/2020) :
289
+ - Les erreurs des Worker (multi-threading) sont maintenant loggées ;
290
+ - Version basée sur la version 2.1.1 de SnakeIA.
291
+
292
+ * Version 1.1 (04/05/2020) :
293
+ - Ajout d'un panel d'administration (accessible à serverDomain/admin). Les comptes sont configurables via le fichier de configuration (deux rôles possibles : moderator ou administrator) ;
294
+ - Multithreading des parties, cela améliore les performances (désactivable dans le fichier de configuration) ;
295
+ - Limite de temps maximale par partie (configurable ou désactivable) ;
296
+ - Ajout de la possibilité de remplir une partie avec des IAs (désactivable dans le fichier de configuration) ;
297
+ - Correction de bugs et autres ajustements :
298
+ - L'état d'une partie est directement envoyée aux spectateurs (avant il y avait un délai) ;
299
+ - Il est désormais impossible de choisir le même nom d'utilisateur qu'un autre utilisateur ;
300
+ - Corrections d'autres bugs et ajustements.
301
+ - Version basée sur la version 2.1 de SnakeIA.
302
+
303
+ ## TO-DO
304
+
305
+ - [x] Multithreading
306
+ - [x] Limite de temps maximale par partie
307
+ - [x] Envoyer directement l'état d'une partie aux spectateurs (actuellement il y a un délai)
308
+ - [x] Ajouter possibilité de remplir une partie avec des IAs
309
+ - [x] Empêcher choix du même nom d'utilisateur qu'un autre utilisateur
310
+ - [x] Panel d'administration
311
+
312
+ ## Déclaration de licence
313
+
314
+ Copyright (C) 2020-2024 Eliastik (eliastiksofts.com)
315
+
316
+ Ce programme est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence, soit (à votre gré) toute version ultérieure.
317
+
318
+ Ce programme est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; sans même la garantie tacite de QUALITÉ MARCHANDE ou d'ADÉQUATION à UN BUT PARTICULIER. Consultez la GNU General Public License pour plus de détails.
319
+
320
+ Vous devez avoir reçu une copie de la GNU General Public License en même temps que ce programme ; si ce n'est pas le cas, consultez http://www.gnu.org/licenses.
321
+
322
+ ----
323
+
324
+ Copyright (C) 2020-2024 Eliastik (eliastiksofts.com)
325
+
326
+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
327
+
328
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
329
+
330
+ You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.