@arcblock/ws 1.32.1 → 1.32.2
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/esm/server/index.d.mts +1 -0
- package/esm/server/index.mjs +7 -6
- package/lib/server/index.cjs +7 -6
- package/lib/server/index.d.cts +1 -0
- package/package.json +2 -2
package/esm/server/index.d.mts
CHANGED
package/esm/server/index.mjs
CHANGED
|
@@ -215,13 +215,14 @@ var WsServer = class extends EventEmitter {
|
|
|
215
215
|
this.heartbeatTimeout = opts.heartbeatTimeout || HEARTBEAT_TIMEOUT;
|
|
216
216
|
this.heartbeatInterval = opts.heartbeatInterval ?? DEFAULT_HEARTBEAT_INTERVAL;
|
|
217
217
|
this.maxTopicsPerSocket = opts.maxTopicsPerSocket ?? MAX_TOPICS_PER_SOCKET;
|
|
218
|
-
|
|
219
|
-
this.
|
|
220
|
-
this.
|
|
221
|
-
this.
|
|
222
|
-
|
|
218
|
+
const wsEnv = opts.env ?? process.env;
|
|
219
|
+
this.maxConnections = opts.maxConnections ?? parseEnvNonNegativeInt(wsEnv.WS_MAX_CONNECTIONS, MAX_CONNECTIONS);
|
|
220
|
+
this.maxConnectionsPerIp = opts.maxConnectionsPerIp ?? parseEnvNonNegativeInt(wsEnv.WS_MAX_CONNECTIONS_PER_IP, MAX_CONNECTIONS_PER_IP);
|
|
221
|
+
this.trustProxy = typeof opts.trustProxy === "number" ? opts.trustProxy > 0 : opts.trustProxy ?? parseEnvBoolean(wsEnv.WS_TRUST_PROXY) ?? parseEnvBoolean(wsEnv.TRUST_PROXY) ?? false;
|
|
222
|
+
this.trustProxyHops = opts.trustProxyHops ?? (typeof opts.trustProxy === "number" && opts.trustProxy > 0 ? Math.floor(opts.trustProxy) : parseEnvPositiveInt(wsEnv.WS_TRUST_PROXY_HOPS, 1));
|
|
223
|
+
const envTrustedProxies = wsEnv.WS_TRUSTED_PROXIES?.split(",").map((s) => s.trim()).filter(Boolean);
|
|
223
224
|
this.trustedProxies = opts.trustedProxies ?? (envTrustedProxies && envTrustedProxies.length > 0 ? envTrustedProxies : DEFAULT_TRUSTED_PROXIES);
|
|
224
|
-
this.trustedIpHeader = opts.trustedIpHeader ?? (
|
|
225
|
+
this.trustedIpHeader = opts.trustedIpHeader ?? (wsEnv.WS_TRUSTED_IP_HEADER?.trim() || void 0);
|
|
225
226
|
this.sanitizeErrors = opts.sanitizeErrors ?? false;
|
|
226
227
|
this.wss = new WebSocketServer({
|
|
227
228
|
noServer: true,
|
package/lib/server/index.cjs
CHANGED
|
@@ -220,13 +220,14 @@ var WsServer = class extends node_events.default {
|
|
|
220
220
|
this.heartbeatTimeout = opts.heartbeatTimeout || HEARTBEAT_TIMEOUT;
|
|
221
221
|
this.heartbeatInterval = opts.heartbeatInterval ?? DEFAULT_HEARTBEAT_INTERVAL;
|
|
222
222
|
this.maxTopicsPerSocket = opts.maxTopicsPerSocket ?? MAX_TOPICS_PER_SOCKET;
|
|
223
|
-
|
|
224
|
-
this.
|
|
225
|
-
this.
|
|
226
|
-
this.
|
|
227
|
-
|
|
223
|
+
const wsEnv = opts.env ?? process.env;
|
|
224
|
+
this.maxConnections = opts.maxConnections ?? parseEnvNonNegativeInt(wsEnv.WS_MAX_CONNECTIONS, MAX_CONNECTIONS);
|
|
225
|
+
this.maxConnectionsPerIp = opts.maxConnectionsPerIp ?? parseEnvNonNegativeInt(wsEnv.WS_MAX_CONNECTIONS_PER_IP, MAX_CONNECTIONS_PER_IP);
|
|
226
|
+
this.trustProxy = typeof opts.trustProxy === "number" ? opts.trustProxy > 0 : opts.trustProxy ?? parseEnvBoolean(wsEnv.WS_TRUST_PROXY) ?? parseEnvBoolean(wsEnv.TRUST_PROXY) ?? false;
|
|
227
|
+
this.trustProxyHops = opts.trustProxyHops ?? (typeof opts.trustProxy === "number" && opts.trustProxy > 0 ? Math.floor(opts.trustProxy) : parseEnvPositiveInt(wsEnv.WS_TRUST_PROXY_HOPS, 1));
|
|
228
|
+
const envTrustedProxies = wsEnv.WS_TRUSTED_PROXIES?.split(",").map((s) => s.trim()).filter(Boolean);
|
|
228
229
|
this.trustedProxies = opts.trustedProxies ?? (envTrustedProxies && envTrustedProxies.length > 0 ? envTrustedProxies : DEFAULT_TRUSTED_PROXIES);
|
|
229
|
-
this.trustedIpHeader = opts.trustedIpHeader ?? (
|
|
230
|
+
this.trustedIpHeader = opts.trustedIpHeader ?? (wsEnv.WS_TRUSTED_IP_HEADER?.trim() || void 0);
|
|
230
231
|
this.sanitizeErrors = opts.sanitizeErrors ?? false;
|
|
231
232
|
this.wss = new ws.WebSocketServer({
|
|
232
233
|
noServer: true,
|
package/lib/server/index.d.cts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/ws",
|
|
3
|
-
"version": "1.32.
|
|
3
|
+
"version": "1.32.2",
|
|
4
4
|
"description": "OCAP Chain websocket server and client",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"websocket"
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"url": "https://github.com/ArcBlock/blockchain/issues"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"@arcblock/event-hub": "1.32.
|
|
78
|
+
"@arcblock/event-hub": "1.32.2",
|
|
79
79
|
"debug": "^4.4.3",
|
|
80
80
|
"eventemitter3": "^4.0.7",
|
|
81
81
|
"lodash": "^4.17.23",
|