roster-server 1.4.4 → 1.4.8

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 CHANGED
@@ -42,10 +42,9 @@ Your project should look something like this:
42
42
  const Roster = require('roster-server');
43
43
 
44
44
  const options = {
45
- maintainerEmail: 'admin@example.com',
46
- greenlockConfigDir: '/srv/greenlock.d', // Path to your Greenlock configuration directory
47
- wwwPath: '/srv/www', // Path to your 'www' directory (default: '../www')
48
- staging: false // Set to true for Let's Encrypt staging environment
45
+ email: 'admin@example.com',
46
+ greenlockStorePath: '/srv/greenlock.d', // Path to your Greenlock configuration directory
47
+ wwwPath: '/srv/www' // Path to your 'www' directory (default: '../www')
49
48
  };
50
49
 
51
50
  const server = new Roster(options);
@@ -139,9 +138,9 @@ Add a new site? Just drop it into the `www` folder with an `index.js` file, and
139
138
 
140
139
  When creating a new `RosterServer` instance, you can pass the following options:
141
140
 
142
- - `maintainerEmail` (string): Your email for Let's Encrypt notifications.
141
+ - `email` (string): Your email for Let's Encrypt notifications.
143
142
  - `wwwPath` (string): Path to your `www` directory containing your sites.
144
- - `greenlockConfigDir` (string): Directory for Greenlock configuration.
143
+ - `greenlockStorePath` (string): Directory for Greenlock configuration.
145
144
  - `staging` (boolean): Set to `true` to use Let's Encrypt's staging environment (for testing).
146
145
 
147
146
  ## 🧂 A Touch of Magic
@@ -2,7 +2,7 @@ const Roster = require('../../index.js');
2
2
  const path = require('path');
3
3
 
4
4
  const roster = new Roster({
5
- maintainerEmail: 'mclasen@blyts.com',
5
+ email: 'admin@example.com',
6
6
  wwwPath: path.join(__dirname, '..', 'www'),
7
7
  });
8
8
 
@@ -1,6 +1,6 @@
1
1
  const { Server } = require('socket.io');
2
2
 
3
- module.exports = (httpsServer) => {
3
+ const app = (httpsServer) => {
4
4
  const io = new Server(httpsServer);
5
5
 
6
6
  io.on('connection', (socket) => {
@@ -21,4 +21,10 @@ module.exports = (httpsServer) => {
21
21
  res.writeHead(200);
22
22
  res.end('Socket.IO server running');
23
23
  };
24
- };
24
+ };
25
+
26
+ app.config = {
27
+ port: 3334,
28
+ };
29
+
30
+ module.exports = app;
package/index.js CHANGED
@@ -4,12 +4,20 @@ const Greenlock = require('greenlock-express');
4
4
 
5
5
  class Roster {
6
6
  constructor(options = {}) {
7
- this.maintainerEmail = options.maintainerEmail || 'admin@example.com';
8
- this.wwwPath = options.wwwPath || path.join(__dirname, '..', '..', '..', 'www');
9
- this.greenlockConfigDir = options.greenlockConfigDir || path.join(__dirname, '..', '..', 'greenlock.d');
7
+ this.email = options.email || 'admin@example.com';
8
+ const basePath = options.basePath || path.join(__dirname, '..', '..', '..');
9
+ this.wwwPath = options.wwwPath || path.join(basePath, 'www');
10
+ this.greenlockStorePath = options.greenlockStorePath || path.join(basePath, 'greenlock.d');
10
11
  this.staging = options.staging || false;
12
+ this.cluster = options.cluster || false;
11
13
  this.domains = [];
12
14
  this.sites = {};
15
+
16
+ const port = options.port || 443;
17
+ if (port === 80) {
18
+ throw new Error('Port 80 is reserved for ACME challenge. Please use a different port.');
19
+ }
20
+ this.port = port;
13
21
  }
14
22
 
15
23
  loadSites() {
@@ -47,7 +55,7 @@ class Roster {
47
55
  }
48
56
 
49
57
  generateConfigJson() {
50
- const configDir = this.greenlockConfigDir;
58
+ const configDir = this.greenlockStorePath;
51
59
  const configPath = path.join(configDir, 'config.json');
52
60
 
53
61
  if (!fs.existsSync(configDir)) {
@@ -95,7 +103,7 @@ class Roster {
95
103
  defaults: {
96
104
  store: {
97
105
  module: "greenlock-store-fs",
98
- basePath: this.greenlockConfigDir
106
+ basePath: this.greenlockStorePath
99
107
  },
100
108
  challenges: {
101
109
  "http-01": {
@@ -106,7 +114,7 @@ class Roster {
106
114
  renewStagger: "3d",
107
115
  accountKeyType: "EC-P256",
108
116
  serverKeyType: "RSA-2048",
109
- subscriberEmail: this.maintainerEmail
117
+ subscriberEmail: this.email
110
118
  },
111
119
  sites: sitesConfig
112
120
  };
@@ -179,9 +187,9 @@ class Roster {
179
187
 
180
188
  const greenlock = Greenlock.init({
181
189
  packageRoot: __dirname,
182
- configDir: this.greenlockConfigDir,
183
- maintainerEmail: this.maintainerEmail,
184
- cluster: false,
190
+ configDir: this.greenlockStorePath,
191
+ maintainerEmail: this.email,
192
+ cluster: this.cluster,
185
193
  staging: this.staging
186
194
  });
187
195
 
@@ -192,7 +200,7 @@ class Roster {
192
200
  const { httpsServer, httpServer } = this.initServers(glx);
193
201
 
194
202
  // Primero iniciar el servidor HTTPS
195
- httpsServer.listen(443, '0.0.0.0', () => {
203
+ httpsServer.listen(this.port, '0.0.0.0', () => {
196
204
  console.log('ℹ️ HTTPS server listening on port 443');
197
205
 
198
206
  // Después iniciar el servidor HTTP
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roster-server",
3
- "version": "1.4.4",
3
+ "version": "1.4.8",
4
4
  "description": "👾 RosterServer - A domain host router to host multiple HTTPS.",
5
5
  "main": "index.js",
6
6
  "scripts": {