snakeia-server 1.2.5 → 1.2.7

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/.drone.yml CHANGED
@@ -15,5 +15,5 @@ steps:
15
15
  password:
16
16
  from_secret: REGISTRY_PASSWORD
17
17
  tags:
18
- - latest
19
- - 1.2.5
18
+ - 1.2.7
19
+ - latest
package/README.md CHANGED
@@ -8,7 +8,7 @@ A server for my [SnakeIA](https://github.com/Eliastik/snakeia) game, written in
8
8
 
9
9
  ## About this server
10
10
 
11
- * Version 1.2.5 (1/4/2026)
11
+ * Version 1.2.7 (2/22/2026)
12
12
  * Made in France by Eliastik - [eliastiksofts.com](http://eliastiksofts.com) - Contact : [eliastiksofts.com/contact](http://eliastiksofts.com/contact)
13
13
  * License: GNU GPLv3 (see LICENCE.txt file)
14
14
 
@@ -74,8 +74,11 @@ You can create another configuration file in the **config** directory named **lo
74
74
  ````
75
75
  {
76
76
  "ServerConfig": {
77
- "version": "1.2.5", // The server version
77
+ "version": "1.2.7", // The server version
78
78
  "port": 3000, // The port where the server runs
79
+ "enableHttps": false, // Enable or disable HTTPS listening on the server. If disabled, the server will only listen on HTTP.
80
+ "httpsCertFile": "path/to/https/cert.pem", // Path to HTTPS certificate file
81
+ "httpsKeyFile": "path/to/https/key.pem", // Path to HTTPS certificate key file
79
82
  "proxyMode": false, // Sets this value to true if your server is behind a proxy - defaults to false
80
83
  "numberOfProxies": 1, // Sets the number of reverse proxies in front of the server. Default to 1. See: https://expressjs.com/en/guide/behind-proxies.html / https://express-rate-limit.mintlify.app/guides/troubleshooting-proxy-issues
81
84
  "enableMultithreading": true, // Enabling the use of different threads for the game engine, improves performance / requires a version of Nodejs that supports Worker Threads
@@ -123,6 +126,13 @@ You can create another configuration file in the **config** directory named **lo
123
126
 
124
127
  ## Changelog
125
128
 
129
+ * Version 1.2.7 (2/22/2026):
130
+ - Update dependencies + SnakeIA to version 3.1.0
131
+
132
+ * Version 1.2.6 (1/26/2026):
133
+ - Added the ability to start the server in HTTPS mode
134
+ - Update dependencies
135
+
126
136
  * Version 1.2.5 (1/4/2026):
127
137
  - Update dependencies
128
138
 
@@ -219,7 +229,7 @@ Un serveur pour mon jeu [SnakeIA](https://github.com/Eliastik/snakeia), écrit e
219
229
 
220
230
  ## À propos de ce serveur
221
231
 
222
- * Version 1.2.5 (04/01/2026)
232
+ * Version 1.2.7 (22/02/2026)
223
233
  * Made in France by Eliastik - [eliastiksofts.com](http://eliastiksofts.com) - Contact : [eliastiksofts.com/contact](http://eliastiksofts.com/contact)
224
234
  * Licence : GNU GPLv3 (voir le fichier LICENCE.txt)
225
235
 
@@ -285,8 +295,11 @@ Vous pouvez créer un fichier de configuration **local.json** dans le dossier **
285
295
  ````
286
296
  {
287
297
  "ServerConfig": {
288
- "version": "1.2.5", // La version du serveur
298
+ "version": "1.2.7", // La version du serveur
289
299
  "port": 3000, // Le port sur lequel lancer le server
300
+ "enableHttps": false, // Activer ou désactiver l'écoute du serveur en HTTPS. Si désactivé, le serveur n'écoutera qu'en HTTP.
301
+ "httpsCertFile": "path/to/https/cert.pem", // Chemin vers le certificat HTTPS
302
+ "httpsKeyFile": "path/to/https/key.pem", // Chemin vers la clé du certificat HTTPS
290
303
  "proxyMode": false, // Mettez à true si votre serveur est derrière un proxy - par défaut false
291
304
  "numberOfProxies": 1, // Configure le nombre de proxies devant votre serveur. Par défaut 1. Voir : https://expressjs.com/en/guide/behind-proxies.html / https://express-rate-limit.mintlify.app/guides/troubleshooting-proxy-issues
292
305
  "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
@@ -334,6 +347,13 @@ Vous pouvez créer un fichier de configuration **local.json** dans le dossier **
334
347
 
335
348
  ## Journal des changements
336
349
 
350
+ * Version 1.2.7 (22/02/2026) :
351
+ - Mise à jour des dépendences + SnakeIA vers 3.1.0
352
+
353
+ * Version 1.2.6 (26/01/2026) :
354
+ - Ajout de la possibilité de démarrer le serveur en HTTPS
355
+ - Mise à jour des dépendences
356
+
337
357
  * Version 1.2.5 (04/01/2026) :
338
358
  - Mise à jour des dépendences
339
359
 
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "ServerConfig": {
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "port": 3000,
5
+ "enableHttps": false,
6
+ "httpsCertFile": "path/to/https/cert.pem",
7
+ "httpsKeyFile": "path/to/https/key.pem",
5
8
  "proxyMode": false,
6
9
  "numberOfProxies": 1,
7
10
  "enableMultithreading": true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snakeia-server",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "description": "Server for multiplaying in SnakeIA (https://github.com/Eliastik/snakeia)",
5
5
  "main": "server.js",
6
6
  "scripts": {
@@ -18,11 +18,11 @@
18
18
  },
19
19
  "homepage": "https://github.com/Eliastik/snakeia-server#readme",
20
20
  "dependencies": {
21
- "body-parser": "^2.2.1",
22
- "config": "^4.1.1",
21
+ "body-parser": "^2.2.2",
22
+ "config": "^4.3.0",
23
23
  "cookie-parser": "^1.4.7",
24
24
  "csrf-csrf": "^4.0.3",
25
- "ejs": "^3.1.10",
25
+ "ejs": "^4.0.1",
26
26
  "express": "^5.2.1",
27
27
  "express-rate-limit": "^8.2.1",
28
28
  "html-entities": "^2.6.0",
@@ -30,7 +30,7 @@
30
30
  "jsonwebtoken": "^9.0.3",
31
31
  "node-fetch": "^3.3.2",
32
32
  "seedrandom": "^3.0.5",
33
- "snakeia": "^3.0.1",
33
+ "snakeia": "^3.1.0",
34
34
  "socket.io": "^4.8.3",
35
35
  "socket.io-cookie-parser": "^1.0.0",
36
36
  "winston": "^3.19.0"
package/server.js CHANGED
@@ -17,16 +17,12 @@
17
17
  * along with "SnakeIA Server". If not, see <http://www.gnu.org/licenses/>.
18
18
  */
19
19
  const express = require("express");
20
- const app = require("express")();
20
+ const app = express();
21
21
  const fs = require("fs");
22
- const http = require("http").createServer(app);
23
- const io = require("socket.io")(http, {
24
- cors: {
25
- origin: true,
26
- credentials: true
27
- },
28
- allowEIO3: true
29
- });
22
+ const httpLib = require("http");
23
+ const httpsLib = require("https");
24
+ let server = null;
25
+ let io = null;
30
26
  const entities = require("html-entities");
31
27
  const ejs = require("ejs");
32
28
  const jwt = require("jsonwebtoken");
@@ -90,6 +86,32 @@ i18n.configure({
90
86
  cookie: "lang"
91
87
  });
92
88
 
89
+ // Initialize server
90
+ if(config.enableHttps) {
91
+ const certPath = config.httpsCertFile;
92
+ const keyPath = config.httpsKeyFile;
93
+
94
+ try {
95
+ const key = fs.readFileSync(keyPath);
96
+ const cert = fs.readFileSync(certPath);
97
+
98
+ server = httpsLib.createServer({ key, cert }, app);
99
+ } catch(e) {
100
+ logger.error("failed to initialize HTTPS server. Fallback to HTTP server.", e);
101
+ server = httpLib.createServer(app);
102
+ }
103
+ } else {
104
+ server = httpLib.createServer(app);
105
+ }
106
+
107
+ io = require("socket.io")(server, {
108
+ cors: {
109
+ origin: true,
110
+ credentials: true
111
+ },
112
+ allowEIO3: true
113
+ });
114
+
93
115
  // Game modules
94
116
  const snakeia = require("snakeia");
95
117
  const { randomUUID } = require("crypto");
@@ -1563,6 +1585,6 @@ io.on("connection", function(socket) {
1563
1585
  });
1564
1586
  });
1565
1587
 
1566
- http.listen(config.port, () => {
1588
+ server.listen(config.port, () => {
1567
1589
  console.log("listening on *:" + config.port);
1568
1590
  });