fix: 3v3 team match wrong problems
This commit is contained in:
-1
@@ -7,7 +7,6 @@ if (hasBlob) BINARY_TYPES.push('blob');
|
||||
|
||||
module.exports = {
|
||||
BINARY_TYPES,
|
||||
CLOSE_TIMEOUT: 30000,
|
||||
EMPTY_BUFFER: Buffer.alloc(0),
|
||||
GUID: '258EAFA5-E914-47DA-95CA-C5AB0DC85B11',
|
||||
hasBlob,
|
||||
|
||||
+6
-20
@@ -37,9 +37,6 @@ class PerMessageDeflate {
|
||||
* acknowledge disabling of client context takeover
|
||||
* @param {Number} [options.concurrencyLimit=10] The number of concurrent
|
||||
* calls to zlib
|
||||
* @param {Boolean} [options.isServer=false] Create the instance in either
|
||||
* server or client mode
|
||||
* @param {Number} [options.maxPayload=0] The maximum allowed message length
|
||||
* @param {(Boolean|Number)} [options.serverMaxWindowBits] Request/confirm the
|
||||
* use of a custom server window size
|
||||
* @param {Boolean} [options.serverNoContextTakeover=false] Request/accept
|
||||
@@ -50,13 +47,16 @@ class PerMessageDeflate {
|
||||
* deflate
|
||||
* @param {Object} [options.zlibInflateOptions] Options to pass to zlib on
|
||||
* inflate
|
||||
* @param {Boolean} [isServer=false] Create the instance in either server or
|
||||
* client mode
|
||||
* @param {Number} [maxPayload=0] The maximum allowed message length
|
||||
*/
|
||||
constructor(options) {
|
||||
constructor(options, isServer, maxPayload) {
|
||||
this._maxPayload = maxPayload | 0;
|
||||
this._options = options || {};
|
||||
this._threshold =
|
||||
this._options.threshold !== undefined ? this._options.threshold : 1024;
|
||||
this._maxPayload = this._options.maxPayload | 0;
|
||||
this._isServer = !!this._options.isServer;
|
||||
this._isServer = !!isServer;
|
||||
this._deflate = null;
|
||||
this._inflate = null;
|
||||
|
||||
@@ -494,14 +494,6 @@ function inflateOnData(chunk) {
|
||||
this[kError].code = 'WS_ERR_UNSUPPORTED_MESSAGE_LENGTH';
|
||||
this[kError][kStatusCode] = 1009;
|
||||
this.removeListener('data', inflateOnData);
|
||||
|
||||
//
|
||||
// The choice to employ `zlib.reset()` over `zlib.close()` is dictated by the
|
||||
// fact that in Node.js versions prior to 13.10.0, the callback for
|
||||
// `zlib.flush()` is not called if `zlib.close()` is used. Utilizing
|
||||
// `zlib.reset()` ensures that either the callback is invoked or an error is
|
||||
// emitted.
|
||||
//
|
||||
this.reset();
|
||||
}
|
||||
|
||||
@@ -517,12 +509,6 @@ function inflateOnError(err) {
|
||||
// closed when an error is emitted.
|
||||
//
|
||||
this[kPerMessageDeflate]._inflate = null;
|
||||
|
||||
if (this[kError]) {
|
||||
this[kCallback](this[kError]);
|
||||
return;
|
||||
}
|
||||
|
||||
err[kStatusCode] = 1007;
|
||||
this[kCallback](err);
|
||||
}
|
||||
|
||||
+1
-1
@@ -551,7 +551,7 @@ class Sender {
|
||||
/**
|
||||
* Sends a frame.
|
||||
*
|
||||
* @param {(Buffer | String)[]} list The frame to send
|
||||
* @param {Buffer[]} list The frame to send
|
||||
* @param {Function} [cb] Callback
|
||||
* @private
|
||||
*/
|
||||
|
||||
-2
@@ -1,7 +1,5 @@
|
||||
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^WebSocket$" }] */
|
||||
'use strict';
|
||||
|
||||
const WebSocket = require('./websocket');
|
||||
const { Duplex } = require('stream');
|
||||
|
||||
/**
|
||||
|
||||
+10
-24
@@ -11,7 +11,7 @@ const extension = require('./extension');
|
||||
const PerMessageDeflate = require('./permessage-deflate');
|
||||
const subprotocol = require('./subprotocol');
|
||||
const WebSocket = require('./websocket');
|
||||
const { CLOSE_TIMEOUT, GUID, kWebSocket } = require('./constants');
|
||||
const { GUID, kWebSocket } = require('./constants');
|
||||
|
||||
const keyRegex = /^[+/0-9A-Za-z]{22}==$/;
|
||||
|
||||
@@ -38,9 +38,6 @@ class WebSocketServer extends EventEmitter {
|
||||
* pending connections
|
||||
* @param {Boolean} [options.clientTracking=true] Specifies whether or not to
|
||||
* track clients
|
||||
* @param {Number} [options.closeTimeout=30000] Duration in milliseconds to
|
||||
* wait for the closing handshake to finish after `websocket.close()` is
|
||||
* called
|
||||
* @param {Function} [options.handleProtocols] A hook to handle protocols
|
||||
* @param {String} [options.host] The hostname where to bind the server
|
||||
* @param {Number} [options.maxPayload=104857600] The maximum allowed message
|
||||
@@ -70,7 +67,6 @@ class WebSocketServer extends EventEmitter {
|
||||
perMessageDeflate: false,
|
||||
handleProtocols: null,
|
||||
clientTracking: true,
|
||||
closeTimeout: CLOSE_TIMEOUT,
|
||||
verifyClient: null,
|
||||
noServer: false,
|
||||
backlog: null, // use default (511 as implemented in net.js)
|
||||
@@ -260,11 +256,9 @@ class WebSocketServer extends EventEmitter {
|
||||
return;
|
||||
}
|
||||
|
||||
if (version !== 13 && version !== 8) {
|
||||
if (version !== 8 && version !== 13) {
|
||||
const message = 'Missing or invalid Sec-WebSocket-Version header';
|
||||
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message, {
|
||||
'Sec-WebSocket-Version': '13, 8'
|
||||
});
|
||||
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -293,11 +287,11 @@ class WebSocketServer extends EventEmitter {
|
||||
this.options.perMessageDeflate &&
|
||||
secWebSocketExtensions !== undefined
|
||||
) {
|
||||
const perMessageDeflate = new PerMessageDeflate({
|
||||
...this.options.perMessageDeflate,
|
||||
isServer: true,
|
||||
maxPayload: this.options.maxPayload
|
||||
});
|
||||
const perMessageDeflate = new PerMessageDeflate(
|
||||
this.options.perMessageDeflate,
|
||||
true,
|
||||
this.options.maxPayload
|
||||
);
|
||||
|
||||
try {
|
||||
const offers = extension.parse(secWebSocketExtensions);
|
||||
@@ -532,23 +526,15 @@ function abortHandshake(socket, code, message, headers) {
|
||||
* @param {Duplex} socket The socket of the upgrade request
|
||||
* @param {Number} code The HTTP response status code
|
||||
* @param {String} message The HTTP response body
|
||||
* @param {Object} [headers] The HTTP response headers
|
||||
* @private
|
||||
*/
|
||||
function abortHandshakeOrEmitwsClientError(
|
||||
server,
|
||||
req,
|
||||
socket,
|
||||
code,
|
||||
message,
|
||||
headers
|
||||
) {
|
||||
function abortHandshakeOrEmitwsClientError(server, req, socket, code, message) {
|
||||
if (server.listenerCount('wsClientError')) {
|
||||
const err = new Error(message);
|
||||
Error.captureStackTrace(err, abortHandshakeOrEmitwsClientError);
|
||||
|
||||
server.emit('wsClientError', err, socket, req);
|
||||
} else {
|
||||
abortHandshake(socket, code, message, headers);
|
||||
abortHandshake(socket, code, message);
|
||||
}
|
||||
}
|
||||
|
||||
+15
-20
@@ -18,7 +18,6 @@ const { isBlob } = require('./validation');
|
||||
|
||||
const {
|
||||
BINARY_TYPES,
|
||||
CLOSE_TIMEOUT,
|
||||
EMPTY_BUFFER,
|
||||
GUID,
|
||||
kForOnEventAttribute,
|
||||
@@ -33,6 +32,7 @@ const {
|
||||
const { format, parse } = require('./extension');
|
||||
const { toBuffer } = require('./buffer-util');
|
||||
|
||||
const closeTimeout = 30 * 1000;
|
||||
const kAborted = Symbol('kAborted');
|
||||
const protocolVersions = [8, 13];
|
||||
const readyStates = ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED'];
|
||||
@@ -88,7 +88,6 @@ class WebSocket extends EventEmitter {
|
||||
initAsClient(this, address, protocols, options);
|
||||
} else {
|
||||
this._autoPong = options.autoPong;
|
||||
this._closeTimeout = options.closeTimeout;
|
||||
this._isServer = true;
|
||||
}
|
||||
}
|
||||
@@ -630,8 +629,6 @@ module.exports = WebSocket;
|
||||
* times in the same tick
|
||||
* @param {Boolean} [options.autoPong=true] Specifies whether or not to
|
||||
* automatically send a pong in response to a ping
|
||||
* @param {Number} [options.closeTimeout=30000] Duration in milliseconds to wait
|
||||
* for the closing handshake to finish after `websocket.close()` is called
|
||||
* @param {Function} [options.finishRequest] A function which can be used to
|
||||
* customize the headers of each http request before it is sent
|
||||
* @param {Boolean} [options.followRedirects=false] Whether or not to follow
|
||||
@@ -658,7 +655,6 @@ function initAsClient(websocket, address, protocols, options) {
|
||||
const opts = {
|
||||
allowSynchronousEvents: true,
|
||||
autoPong: true,
|
||||
closeTimeout: CLOSE_TIMEOUT,
|
||||
protocolVersion: protocolVersions[1],
|
||||
maxPayload: 100 * 1024 * 1024,
|
||||
skipUTF8Validation: false,
|
||||
@@ -677,7 +673,6 @@ function initAsClient(websocket, address, protocols, options) {
|
||||
};
|
||||
|
||||
websocket._autoPong = opts.autoPong;
|
||||
websocket._closeTimeout = opts.closeTimeout;
|
||||
|
||||
if (!protocolVersions.includes(opts.protocolVersion)) {
|
||||
throw new RangeError(
|
||||
@@ -693,7 +688,7 @@ function initAsClient(websocket, address, protocols, options) {
|
||||
} else {
|
||||
try {
|
||||
parsedUrl = new URL(address);
|
||||
} catch {
|
||||
} catch (e) {
|
||||
throw new SyntaxError(`Invalid URL: ${address}`);
|
||||
}
|
||||
}
|
||||
@@ -713,7 +708,7 @@ function initAsClient(websocket, address, protocols, options) {
|
||||
if (parsedUrl.protocol !== 'ws:' && !isSecure && !isIpcUrl) {
|
||||
invalidUrlMessage =
|
||||
'The URL\'s protocol must be one of "ws:", "wss:", ' +
|
||||
'"http:", "https:", or "ws+unix:"';
|
||||
'"http:", "https", or "ws+unix:"';
|
||||
} else if (isIpcUrl && !parsedUrl.pathname) {
|
||||
invalidUrlMessage = "The URL's pathname is empty";
|
||||
} else if (parsedUrl.hash) {
|
||||
@@ -755,11 +750,11 @@ function initAsClient(websocket, address, protocols, options) {
|
||||
opts.timeout = opts.handshakeTimeout;
|
||||
|
||||
if (opts.perMessageDeflate) {
|
||||
perMessageDeflate = new PerMessageDeflate({
|
||||
...opts.perMessageDeflate,
|
||||
isServer: false,
|
||||
maxPayload: opts.maxPayload
|
||||
});
|
||||
perMessageDeflate = new PerMessageDeflate(
|
||||
opts.perMessageDeflate !== true ? opts.perMessageDeflate : {},
|
||||
false,
|
||||
opts.maxPayload
|
||||
);
|
||||
opts.headers['Sec-WebSocket-Extensions'] = format({
|
||||
[PerMessageDeflate.extensionName]: perMessageDeflate.offer()
|
||||
});
|
||||
@@ -1295,7 +1290,7 @@ function senderOnError(err) {
|
||||
function setCloseTimer(websocket) {
|
||||
websocket._closeTimer = setTimeout(
|
||||
websocket._socket.destroy.bind(websocket._socket),
|
||||
websocket._closeTimeout
|
||||
closeTimeout
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1313,23 +1308,23 @@ function socketOnClose() {
|
||||
|
||||
websocket._readyState = WebSocket.CLOSING;
|
||||
|
||||
let chunk;
|
||||
|
||||
//
|
||||
// The close frame might not have been received or the `'end'` event emitted,
|
||||
// for example, if the socket was destroyed due to an error. Ensure that the
|
||||
// `receiver` stream is closed after writing any remaining buffered data to
|
||||
// it. If the readable side of the socket is in flowing mode then there is no
|
||||
// buffered data as everything has been already written. If instead, the
|
||||
// socket is paused, any possible buffered data will be read as a single
|
||||
// chunk.
|
||||
// buffered data as everything has been already written and `readable.read()`
|
||||
// will return `null`. If instead, the socket is paused, any possible buffered
|
||||
// data will be read as a single chunk.
|
||||
//
|
||||
if (
|
||||
!this._readableState.endEmitted &&
|
||||
!websocket._closeFrameReceived &&
|
||||
!websocket._receiver._writableState.errorEmitted &&
|
||||
this._readableState.length !== 0
|
||||
(chunk = websocket._socket.read()) !== null
|
||||
) {
|
||||
const chunk = this.read(this._readableState.length);
|
||||
|
||||
websocket._receiver.write(chunk);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user