From ebf1c0f9912aacaba511563de56413477bba6d68 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Sat, 14 Oct 2017 13:02:40 +0200 Subject: [PATCH] Always include ID marker in repeater protocol This makes sure we're always following the protocol, and the caller doesn't have to care about the details. --- core/rfb.js | 2 +- tests/test.rfb.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/rfb.js b/core/rfb.js index 2fe251c2..5b79d3c8 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -732,7 +732,7 @@ RFB.prototype = { } if (is_repeater) { - var repeaterID = this._repeaterID; + var repeaterID = "ID:" + this._repeaterID; while (repeaterID.length < 250) { repeaterID += "\0"; } diff --git a/tests/test.rfb.js b/tests/test.rfb.js index 9e606122..9ccc2fad 100644 --- a/tests/test.rfb.js +++ b/tests/test.rfb.js @@ -582,12 +582,12 @@ describe('Remote Frame Buffer Protocol Client', function() { }); it('should interpret version 000.000 as a repeater', function () { - client._repeaterID = '\x01\x02\x03\x04\x05'; + client._repeaterID = '12345'; send_ver('000.000', client); expect(client._rfb_version).to.equal(0); var sent_data = client._sock._websocket._get_sent_data(); - expect(new Uint8Array(sent_data.buffer, 0, 5)).to.array.equal(new Uint8Array([1, 2, 3, 4, 5])); + expect(new Uint8Array(sent_data.buffer, 0, 9)).to.array.equal(new Uint8Array([73, 68, 58, 49, 50, 51, 52, 53, 0])); }); it('should interpret version 003.003 as version 3.3', function () { @@ -638,12 +638,12 @@ describe('Remote Frame Buffer Protocol Client', function() { }); it('should handle two step repeater negotiation', function () { - client._repeaterID = '\x01\x02\x03\x04\x05'; + client._repeaterID = '12345'; send_ver('000.000', client); expect(client._rfb_version).to.equal(0); var sent_data = client._sock._websocket._get_sent_data(); - expect(new Uint8Array(sent_data.buffer, 0, 5)).to.array.equal(new Uint8Array([1, 2, 3, 4, 5])); + expect(new Uint8Array(sent_data.buffer, 0, 9)).to.array.equal(new Uint8Array([73, 68, 58, 49, 50, 51, 52, 53, 0])); expect(sent_data).to.have.length(250); send_ver('003.008', client);