fix one ping/pong function

Signed-off-by: si458 <simonsmith5521@gmail.com>

si458 committed Feb 12, 2024 at 11:46 UTC 6f78f9e2764109bfa783eabc396512dcb4a72baa
1 file changed +14 -17
apprelays.js
+14 -17
@@ -842,24 +842,21 @@ module.exports.CreateMstscRelay = function (parent, db, ws, req, args, domain) {
842 obj.relaySocket.resume();
843 }
844 } else {
845 - if (typeof data == 'string') {
846 - // Forward any ping/pong commands to the browser
847 - var cmd = null;
848 - try { // Forward any ping/pong commands to the browser
849 - cmd = JSON.parse(data);
850 - if ((cmd != null) && (cmd.ctrlChannel == '102938')) {
851 - if (cmd.type == 'ping') { send(['ping']); }
852 - else if (cmd.type == 'pong') { send(['pong']); }
853 - }
854 - return;
855 - } catch (ex) { // You are not JSON data so just send over relaySocket
856 - obj.wsClient._socket.pause();
857 - try {
858 - obj.relaySocket.write(data, function () {
859 - if (obj.wsClient && obj.wsClient._socket) { try { obj.wsClient._socket.resume(); } catch (ex) { console.log(ex); } }
860 - });
861 - } catch (ex) { console.log(ex); obj.close(); }
845 + try { // Forward any ping/pong commands to the browser
846 + var cmd = JSON.parse(data);
847 + if ((cmd != null) && (cmd.ctrlChannel == '102938')) {
848 + if (cmd.type == 'ping') { send(['ping']); }
849 + else if (cmd.type == 'pong') { send(['pong']); }
850 }
851 + return;
852 + } catch (ex) { // You are not JSON data so just send over relaySocket
853 + obj.wsClient._socket.pause();
854 + try {
855 + obj.relaySocket.write(data, function () {
856 + if (obj.wsClient && obj.wsClient._socket) { try { obj.wsClient._socket.resume(); } catch (ex) { console.log(ex); } }
857 + });
858 + } catch (ex) { console.log(ex); obj.close(); }
859 + }
860 }
861 });
862 obj.wsClient.on('close', function () { parent.parent.debug('relay', 'RDP: Relay websocket closed'); obj.close(); });