angelia.io 1.65.0 → 1.66.0
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/package.json +1 -1
- package/readme.md +8 -7
- package/server/Server.js +10 -27
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -85,13 +85,14 @@ const server = new Server.listen({
|
|
|
85
85
|
})
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
-
| name
|
|
89
|
-
|
|
|
90
|
-
| `hostname`
|
|
91
|
-
| `port`
|
|
92
|
-
| `maxMessageSize`
|
|
93
|
-
| `
|
|
94
|
-
| `
|
|
88
|
+
| name | kind | default | description |
|
|
89
|
+
| -------------------- | ------- | ------- | --------------------------------------------------- |
|
|
90
|
+
| `hostname` | String | '' | the hostname if any |
|
|
91
|
+
| `port` | Number | 3001 | the port to use for this server |
|
|
92
|
+
| `maxMessageSize` | Number | 5 | max size in mb of a message received |
|
|
93
|
+
| `skipUTF8Validation` | Boolean | false | allows to skip utf8 validation |
|
|
94
|
+
| `cert` | String | '' | path to the cert file for using https fullchain.pem |
|
|
95
|
+
| `key` | String | '' | path to the key file for using https privkey.pem |
|
|
95
96
|
|
|
96
97
|
### Server Object
|
|
97
98
|
|
package/server/Server.js
CHANGED
|
@@ -78,10 +78,7 @@ class ServerSingleton {
|
|
|
78
78
|
},
|
|
79
79
|
})
|
|
80
80
|
|
|
81
|
-
this.pingData = this.WebSocket.Sender.frame(
|
|
82
|
-
Buffer.from(''),
|
|
83
|
-
this.WebSocketFrame,
|
|
84
|
-
)
|
|
81
|
+
this.pingData = this.WebSocket.Sender.frame(Buffer.from(''), this.WebSocketFrame)
|
|
85
82
|
this.disconnectData = this.WebSocket.Sender.frame(
|
|
86
83
|
Buffer.from(JSON.stringify([['disconnect', true]])),
|
|
87
84
|
this.WebSocketFrame,
|
|
@@ -90,13 +87,9 @@ class ServerSingleton {
|
|
|
90
87
|
|
|
91
88
|
listen(options) {
|
|
92
89
|
Object.assign(this, {
|
|
93
|
-
port:
|
|
94
|
-
+options.port > 0 && +options.port <= 65535 ? +options.port : this.port,
|
|
90
|
+
port: +options.port > 0 && +options.port <= 65535 ? +options.port : this.port,
|
|
95
91
|
hostname: options.hostname || this.hostname,
|
|
96
|
-
maxMessageSize:
|
|
97
|
-
+options.maxMessageSize > 0
|
|
98
|
-
? +options.maxMessageSize
|
|
99
|
-
: this.maxMessageSize,
|
|
92
|
+
maxMessageSize: +options.maxMessageSize > 0 ? +options.maxMessageSize : this.maxMessageSize,
|
|
100
93
|
cert: options.cert || this.cert,
|
|
101
94
|
key: options.key || this.key,
|
|
102
95
|
|
|
@@ -135,6 +128,8 @@ class ServerSingleton {
|
|
|
135
128
|
maxPayload: this.maxMessageSize * 1024 * 1024,
|
|
136
129
|
clientTracking: false,
|
|
137
130
|
backlog: 1024,
|
|
131
|
+
skipUTF8Validation:
|
|
132
|
+
options.skipUTF8Validation !== undefined ? options.skipUTF8Validation : false,
|
|
138
133
|
})
|
|
139
134
|
|
|
140
135
|
io.on('connection', this.onconnect)
|
|
@@ -229,9 +224,7 @@ class ServerSingleton {
|
|
|
229
224
|
Object.assign(socket, {
|
|
230
225
|
ip: (
|
|
231
226
|
this.ip(request.connection.remoteAddress) ||
|
|
232
|
-
this.ip(
|
|
233
|
-
(request.headers['x-forwarded-for'] || '').split(/\s*,\s*/)[0],
|
|
234
|
-
) ||
|
|
227
|
+
this.ip((request.headers['x-forwarded-for'] || '').split(/\s*,\s*/)[0]) ||
|
|
235
228
|
request.connection.remoteAddress ||
|
|
236
229
|
(request.headers['x-forwarded-for'] || '').split(/\s*,\s*/)[0]
|
|
237
230
|
).replace(/^::ffff:/, ''),
|
|
@@ -287,10 +280,7 @@ class ServerSingleton {
|
|
|
287
280
|
let json = JSON.stringify(messages)
|
|
288
281
|
this.bytesSent += json.length
|
|
289
282
|
socket.bytesSent += json.length
|
|
290
|
-
this.cache[id] = this.WebSocket.Sender.frame(
|
|
291
|
-
Buffer.from(json),
|
|
292
|
-
this.WebSocketFrame,
|
|
293
|
-
)
|
|
283
|
+
this.cache[id] = this.WebSocket.Sender.frame(Buffer.from(json), this.WebSocketFrame)
|
|
294
284
|
} else {
|
|
295
285
|
this.messagesSentCacheHit++
|
|
296
286
|
}
|
|
@@ -349,12 +339,8 @@ class ServerSingleton {
|
|
|
349
339
|
if (
|
|
350
340
|
/^(::f{4}:)?10\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(i) ||
|
|
351
341
|
/^(::f{4}:)?192\.168\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(i) ||
|
|
352
|
-
/^(::f{4}:)?172\.(1[6-9]|2\d|30|31)\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(
|
|
353
|
-
|
|
354
|
-
) ||
|
|
355
|
-
/^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(
|
|
356
|
-
i,
|
|
357
|
-
) ||
|
|
342
|
+
/^(::f{4}:)?172\.(1[6-9]|2\d|30|31)\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(i) ||
|
|
343
|
+
/^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(i) ||
|
|
358
344
|
/^(::f{4}:)?169\.254\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(i) ||
|
|
359
345
|
/^f[cd][0-9a-f]{2}:/i.test(i) ||
|
|
360
346
|
/^fe80:/i.test(i)
|
|
@@ -472,10 +458,7 @@ class ServerSingleton {
|
|
|
472
458
|
// classes
|
|
473
459
|
console.log('this.events', this.HasFastProperties(this.events.classes))
|
|
474
460
|
for (let m in this.events.classes) {
|
|
475
|
-
console.log(
|
|
476
|
-
'this.events.' + m,
|
|
477
|
-
this.HasFastProperties(this.events.classes[m]),
|
|
478
|
-
)
|
|
461
|
+
console.log('this.events.' + m, this.HasFastProperties(this.events.classes[m]))
|
|
479
462
|
// class
|
|
480
463
|
for (let f in this.events.classes[m]) {
|
|
481
464
|
// methods
|