From 8d0c7fb5aca8251ff72d9727c7e6997f761d89e2 Mon Sep 17 00:00:00 2001 From: William Lightning Date: Wed, 6 Jun 2012 23:10:13 -0700 Subject: [PATCH 1/4] Add ultravnc_repeater.pl support to rfb.js and vnc_auto.html --- include/rfb.js | 18 +++++++++++++++--- vnc_auto.html | 6 ++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/include/rfb.js b/include/rfb.js index 4362ce14..4de9be9d 100644 --- a/include/rfb.js +++ b/include/rfb.js @@ -39,6 +39,7 @@ var that = {}, // Public API methods rfb_port = 5900, rfb_password = '', rfb_path = '', + rfb_repeaterID = '', rfb_state = 'disconnected', rfb_version = 0, @@ -659,10 +660,10 @@ mouseMove = function(x, y) { init_msg = function() { //Util.Debug(">> init_msg [rfb_state '" + rfb_state + "']"); - var strlen, reason, length, sversion, cversion, + var strlen, reason, length, sversion, cversion, repeaterID, i, types, num_types, challenge, response, bpp, depth, big_endian, red_max, green_max, blue_max, red_shift, - green_shift, blue_shift, true_color, name_length; + green_shift, blue_shift, true_color, name_length, is_repeater; //Util.Debug("ws.rQ (" + ws.rQlen() + ") " + ws.rQslice(0)); switch (rfb_state) { @@ -673,7 +674,9 @@ init_msg = function() { } sversion = ws.rQshiftStr(12).substr(4,7); Util.Info("Server ProtocolVersion: " + sversion); + is_repeater = 0; switch (sversion) { + case "000.000": is_repeater = 1; break; // UltraVNC repeater case "003.003": rfb_version = 3.3; break; case "003.006": rfb_version = 3.3; break; // UltraVNC case "003.889": rfb_version = 3.3; break; // Apple Remote Desktop @@ -684,6 +687,13 @@ init_msg = function() { default: return fail("Invalid server version " + sversion); } + if (is_repeater) { + repeaterID = rfb_repeaterID; + while(repeaterID.length < 250) + repeaterID += "\0"; + ws.send_string(repeaterID); + break; + } if (rfb_version > rfb_max_version) { rfb_version = rfb_max_version; } @@ -730,6 +740,7 @@ init_msg = function() { // Server decides if (ws.rQwait("security scheme", 4)) { return false; } rfb_auth_scheme = ws.rQshift32(); + //rfb_auth_scheme = ws.rQshiftStr(12); } updateState('Authentication', "Authenticating using scheme: " + rfb_auth_scheme); @@ -1748,13 +1759,14 @@ clientCutText = function(text) { // Public API interface functions // -that.connect = function(host, port, password, path) { +that.connect = function(host, port, password, path, repeaterID) { //Util.Debug(">> connect"); rfb_host = host; rfb_port = port; rfb_password = (password !== undefined) ? password : ""; rfb_path = (path !== undefined) ? path : ""; + rfb_repeaterID = (repeaterID !== undefined) ? repeaterID : ""; if ((!rfb_host) || (!rfb_port)) { return fail("Must set host and port"); diff --git a/vnc_auto.html b/vnc_auto.html index 8d370b55..0969dbea 100644 --- a/vnc_auto.html +++ b/vnc_auto.html @@ -84,7 +84,7 @@ } window.onload = function () { - var host, port, password, path, token; + var host, port, password, path, token, repeaterID; $D('sendCtrlAltDelButton').style.display = "inline"; $D('sendCtrlAltDelButton').onclick = sendCtrlAltDel; @@ -103,6 +103,8 @@ password = WebUtil.getQueryVar('password', ''); path = WebUtil.getQueryVar('path', 'websockify'); + repeaterID = WebUtil.getQueryVar('repeaterid',''); + if ((!host) || (!port)) { updateState('failed', "Must specify host and port in URL"); @@ -118,7 +120,7 @@ 'view_only': WebUtil.getQueryVar('view_only', false), 'updateState': updateState, 'onPasswordRequired': passwordRequired}); - rfb.connect(host, port, password, path); + rfb.connect(host, port, password, path, repeaterID); }; From 12acb663ebae597e70d3b23aeb61330522102f5d Mon Sep 17 00:00:00 2001 From: William Lightning Date: Fri, 22 Jun 2012 22:30:05 -0700 Subject: [PATCH 2/4] Change RepeaterID to be a config option --- include/rfb.js | 7 +++---- include/util.js | 2 ++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/rfb.js b/include/rfb.js index 4de9be9d..74b45feb 100644 --- a/include/rfb.js +++ b/include/rfb.js @@ -39,7 +39,6 @@ var that = {}, // Public API methods rfb_port = 5900, rfb_password = '', rfb_path = '', - rfb_repeaterID = '', rfb_state = 'disconnected', rfb_version = 0, @@ -135,6 +134,7 @@ Util.conf_defaults(conf, that, defaults, [ ['focusContainer', 'wo', 'dom', document, 'DOM element that captures keyboard input'], ['encrypt', 'rw', 'bool', false, 'Use TLS/SSL/wss encryption'], + ['repeaterID', 'rw', 'string', '', 'RepeaterID to connect to'], ['true_color', 'rw', 'bool', true, 'Request true color pixel data'], ['local_cursor', 'rw', 'bool', false, 'Request locally rendered cursor'], ['shared', 'rw', 'bool', true, 'Request shared mode'], @@ -688,7 +688,7 @@ init_msg = function() { return fail("Invalid server version " + sversion); } if (is_repeater) { - repeaterID = rfb_repeaterID; + repeaterID = conf.repeaterID; while(repeaterID.length < 250) repeaterID += "\0"; ws.send_string(repeaterID); @@ -1759,14 +1759,13 @@ clientCutText = function(text) { // Public API interface functions // -that.connect = function(host, port, password, path, repeaterID) { +that.connect = function(host, port, password, path) { //Util.Debug(">> connect"); rfb_host = host; rfb_port = port; rfb_password = (password !== undefined) ? password : ""; rfb_path = (path !== undefined) ? path : ""; - rfb_repeaterID = (repeaterID !== undefined) ? repeaterID : ""; if ((!rfb_host) || (!rfb_port)) { return fail("Must set host and port"); diff --git a/include/util.js b/include/util.js index 2c0e4ed5..b410506d 100644 --- a/include/util.js +++ b/include/util.js @@ -146,6 +146,8 @@ Util.conf_default = function(cfg, api, defaults, v, mode, type, defval, desc) { } } else if (type in {'integer':1, 'int':1}) { val = parseInt(val, 10); + } else if (type === 'string') { + val = String(val); } else if (type === 'func') { if (!val) { val = function () {}; From a997c5fd942350450fbe62bfaded1e2abc08be1b Mon Sep 17 00:00:00 2001 From: William Lightning Date: Fri, 22 Jun 2012 22:30:57 -0700 Subject: [PATCH 3/4] Make repeaterID show up in config options on vnc.html --- include/ui.js | 5 +++++ vnc.html | 1 + 2 files changed, 6 insertions(+) diff --git a/include/ui.js b/include/ui.js index eddfa6cd..77ba46a4 100644 --- a/include/ui.js +++ b/include/ui.js @@ -49,6 +49,7 @@ load: function() { UI.initSetting('port', window.location.port); UI.initSetting('password', ''); UI.initSetting('encrypt', (window.location.protocol === "https:")); + UI.initSetting('repeaterID', ''); UI.initSetting('true_color', true); UI.initSetting('cursor', false); UI.initSetting('shared', true); @@ -258,6 +259,7 @@ toggleSettingsPanel: function() { UI.closeSettingsMenu(); } else { UI.updateSetting('encrypt'); + UI.updateSetting('repeaterID'); UI.updateSetting('true_color'); if (UI.rfb.get_display().get_cursor_uri()) { UI.updateSetting('cursor'); @@ -304,6 +306,7 @@ closeSettingsMenu: function() { settingsApply: function() { //Util.Debug(">> settingsApply"); UI.saveSetting('encrypt'); + UI.saveSetting('repeaterID'); UI.saveSetting('true_color'); if (UI.rfb.get_display().get_cursor_uri()) { UI.saveSetting('cursor'); @@ -415,6 +418,7 @@ updateVisualState: function() { //Util.Debug(">> updateVisualState"); $D('noVNC_encrypt').disabled = connected; + $D('noVNC_repeaterID').disabled = connected; $D('noVNC_true_color').disabled = connected; if (UI.rfb && UI.rfb.get_display() && UI.rfb.get_display().get_cursor_uri()) { @@ -484,6 +488,7 @@ connect: function() { } UI.rfb.set_encrypt(UI.getSetting('encrypt')); + UI.rfb.set_repeaterID(UI.getSetting('repeaterID')); UI.rfb.set_true_color(UI.getSetting('true_color')); UI.rfb.set_local_cursor(UI.getSetting('cursor')); UI.rfb.set_shared(UI.getSetting('shared')); diff --git a/vnc.html b/vnc.html index b6cf85ba..ac1aa770 100644 --- a/vnc.html +++ b/vnc.html @@ -140,6 +140,7 @@
  • View Only
  • Connect Timeout (s)
  • Path
  • +
  • Repeater ID