From 2e64a1a5a0f3ed344855f0fbcc7ccea3ff2fe9ba Mon Sep 17 00:00:00 2001 From: Sadzurami Date: Thu, 22 Feb 2024 09:29:28 +0300 Subject: [PATCH] tweaks --- components/connection_protocols/tcp.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/components/connection_protocols/tcp.js b/components/connection_protocols/tcp.js index 448573a5..6006e154 100644 --- a/components/connection_protocols/tcp.js +++ b/components/connection_protocols/tcp.js @@ -158,6 +158,11 @@ class TCPConnection extends BaseConnection { data = SteamCrypto.symmetricEncryptWithHmacIv(data, this.sessionKey); } + if (!this.stream) { + this._debug('Tried to send message, but there is no stream'); + return; + } + let buf = Buffer.alloc(4 + 4 + data.length); buf.writeUInt32LE(data.length, 0); buf.write(MAGIC, 4); @@ -192,8 +197,12 @@ class TCPConnection extends BaseConnection { } } - let message; + if (!this.stream) { + this._debug('Tried to read message, but there is no stream'); + return; + } + let message; try { message = this.stream.read(this._messageLength); } catch (error) {