Ver código fonte

UltraVNC repeaterID cleanup.

https://github.com/kanaka/noVNC/issues/103
https://github.com/kanaka/noVNC/pull/170
Joel Martin 13 anos atrás
pai
commit
b50f340674
4 arquivos alterados com 13 adições e 10 exclusões
  1. 5 3
      include/rfb.js
  2. 6 5
      include/ui.js
  3. 1 1
      include/util.js
  4. 1 1
      vnc_auto.html

+ 5 - 3
include/rfb.js

@@ -134,7 +134,6 @@ Util.conf_defaults(conf, that, defaults, [
     ['focusContainer',     'wo', 'dom', document, 'DOM element that captures keyboard input'],
     ['focusContainer',     'wo', 'dom', document, 'DOM element that captures keyboard input'],
 
 
     ['encrypt',            'rw', 'bool', false, 'Use TLS/SSL/wss encryption'],
     ['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'],
     ['true_color',         'rw', 'bool', true,  'Request true color pixel data'],
     ['local_cursor',       'rw', 'bool', false, 'Request locally rendered cursor'],
     ['local_cursor',       'rw', 'bool', false, 'Request locally rendered cursor'],
     ['shared',             'rw', 'bool', true,  'Request shared mode'],
     ['shared',             'rw', 'bool', true,  'Request shared mode'],
@@ -143,6 +142,9 @@ Util.conf_defaults(conf, that, defaults, [
     ['connectTimeout',     'rw', 'int', def_con_timeout, 'Time (s) to wait for connection'],
     ['connectTimeout',     'rw', 'int', def_con_timeout, 'Time (s) to wait for connection'],
     ['disconnectTimeout',  'rw', 'int', 3,    'Time (s) to wait for disconnection'],
     ['disconnectTimeout',  'rw', 'int', 3,    'Time (s) to wait for disconnection'],
 
 
+    // UltraVNC repeater ID to connect to
+    ['repeaterID',         'rw', 'str',  '',    'RepeaterID to connect to'],
+
     ['viewportDrag',       'rw', 'bool', false, 'Move the viewport on mouse drags'],
     ['viewportDrag',       'rw', 'bool', false, 'Move the viewport on mouse drags'],
 
 
     ['check_rate',         'rw', 'int', 217,  'Timing (ms) of send/receive check'],
     ['check_rate',         'rw', 'int', 217,  'Timing (ms) of send/receive check'],
@@ -689,8 +691,9 @@ init_msg = function() {
         }
         }
         if (is_repeater) { 
         if (is_repeater) { 
             repeaterID = conf.repeaterID;
             repeaterID = conf.repeaterID;
-            while(repeaterID.length < 250)
+            while (repeaterID.length < 250) {
                 repeaterID += "\0";
                 repeaterID += "\0";
+            }
             ws.send_string(repeaterID);
             ws.send_string(repeaterID);
             break;
             break;
         }
         }
@@ -740,7 +743,6 @@ init_msg = function() {
             // Server decides
             // Server decides
             if (ws.rQwait("security scheme", 4)) { return false; }
             if (ws.rQwait("security scheme", 4)) { return false; }
             rfb_auth_scheme = ws.rQshift32();
             rfb_auth_scheme = ws.rQshift32();
-            //rfb_auth_scheme = ws.rQshiftStr(12);
         }
         }
         updateState('Authentication',
         updateState('Authentication',
                 "Authenticating using scheme: " + rfb_auth_scheme);
                 "Authenticating using scheme: " + rfb_auth_scheme);

+ 6 - 5
include/ui.js

@@ -49,13 +49,13 @@ load: function() {
     UI.initSetting('port', window.location.port);
     UI.initSetting('port', window.location.port);
     UI.initSetting('password', '');
     UI.initSetting('password', '');
     UI.initSetting('encrypt', (window.location.protocol === "https:"));
     UI.initSetting('encrypt', (window.location.protocol === "https:"));
-    UI.initSetting('repeaterID', '');
     UI.initSetting('true_color', true);
     UI.initSetting('true_color', true);
     UI.initSetting('cursor', false);
     UI.initSetting('cursor', false);
     UI.initSetting('shared', true);
     UI.initSetting('shared', true);
     UI.initSetting('view_only', false);
     UI.initSetting('view_only', false);
     UI.initSetting('connectTimeout', 2);
     UI.initSetting('connectTimeout', 2);
     UI.initSetting('path', 'websockify');
     UI.initSetting('path', 'websockify');
+    UI.initSetting('repeaterID', '');
 
 
     UI.rfb = RFB({'target': $D('noVNC_canvas'),
     UI.rfb = RFB({'target': $D('noVNC_canvas'),
                   'onUpdateState': UI.updateState,
                   'onUpdateState': UI.updateState,
@@ -259,7 +259,6 @@ toggleSettingsPanel: function() {
         UI.closeSettingsMenu();
         UI.closeSettingsMenu();
     } else {
     } else {
         UI.updateSetting('encrypt');
         UI.updateSetting('encrypt');
-        UI.updateSetting('repeaterID');
         UI.updateSetting('true_color');
         UI.updateSetting('true_color');
         if (UI.rfb.get_display().get_cursor_uri()) {
         if (UI.rfb.get_display().get_cursor_uri()) {
             UI.updateSetting('cursor');
             UI.updateSetting('cursor');
@@ -272,6 +271,7 @@ toggleSettingsPanel: function() {
         UI.updateSetting('view_only');
         UI.updateSetting('view_only');
         UI.updateSetting('connectTimeout');
         UI.updateSetting('connectTimeout');
         UI.updateSetting('path');
         UI.updateSetting('path');
+        UI.updateSetting('repeaterID');
         UI.updateSetting('stylesheet');
         UI.updateSetting('stylesheet');
         UI.updateSetting('logging');
         UI.updateSetting('logging');
 
 
@@ -306,7 +306,6 @@ closeSettingsMenu: function() {
 settingsApply: function() {
 settingsApply: function() {
     //Util.Debug(">> settingsApply");
     //Util.Debug(">> settingsApply");
     UI.saveSetting('encrypt');
     UI.saveSetting('encrypt');
-    UI.saveSetting('repeaterID');
     UI.saveSetting('true_color');
     UI.saveSetting('true_color');
     if (UI.rfb.get_display().get_cursor_uri()) {
     if (UI.rfb.get_display().get_cursor_uri()) {
         UI.saveSetting('cursor');
         UI.saveSetting('cursor');
@@ -316,6 +315,7 @@ settingsApply: function() {
     UI.saveSetting('view_only');
     UI.saveSetting('view_only');
     UI.saveSetting('connectTimeout');
     UI.saveSetting('connectTimeout');
     UI.saveSetting('path');
     UI.saveSetting('path');
+    UI.saveSetting('repeaterID');
     UI.saveSetting('stylesheet');
     UI.saveSetting('stylesheet');
     UI.saveSetting('logging');
     UI.saveSetting('logging');
 
 
@@ -418,7 +418,6 @@ updateVisualState: function() {
 
 
     //Util.Debug(">> updateVisualState");
     //Util.Debug(">> updateVisualState");
     $D('noVNC_encrypt').disabled = connected;
     $D('noVNC_encrypt').disabled = connected;
-    $D('noVNC_repeaterID').disabled = connected;
     $D('noVNC_true_color').disabled = connected;
     $D('noVNC_true_color').disabled = connected;
     if (UI.rfb && UI.rfb.get_display() &&
     if (UI.rfb && UI.rfb.get_display() &&
         UI.rfb.get_display().get_cursor_uri()) {
         UI.rfb.get_display().get_cursor_uri()) {
@@ -431,6 +430,7 @@ updateVisualState: function() {
     $D('noVNC_view_only').disabled = connected;
     $D('noVNC_view_only').disabled = connected;
     $D('noVNC_connectTimeout').disabled = connected;
     $D('noVNC_connectTimeout').disabled = connected;
     $D('noVNC_path').disabled = connected;
     $D('noVNC_path').disabled = connected;
+    $D('noVNC_repeaterID').disabled = connected;
 
 
     if (connected) {
     if (connected) {
         UI.setViewClip();
         UI.setViewClip();
@@ -488,14 +488,15 @@ connect: function() {
     }
     }
 
 
     UI.rfb.set_encrypt(UI.getSetting('encrypt'));
     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_true_color(UI.getSetting('true_color'));
     UI.rfb.set_local_cursor(UI.getSetting('cursor'));
     UI.rfb.set_local_cursor(UI.getSetting('cursor'));
     UI.rfb.set_shared(UI.getSetting('shared'));
     UI.rfb.set_shared(UI.getSetting('shared'));
     UI.rfb.set_view_only(UI.getSetting('view_only'));
     UI.rfb.set_view_only(UI.getSetting('view_only'));
     UI.rfb.set_connectTimeout(UI.getSetting('connectTimeout'));
     UI.rfb.set_connectTimeout(UI.getSetting('connectTimeout'));
+    UI.rfb.set_repeaterID(UI.getSetting('repeaterID'));
 
 
     UI.rfb.connect(host, port, password, path);
     UI.rfb.connect(host, port, password, path);
+
     //Close dialog.
     //Close dialog.
     setTimeout(UI.setBarPosition, 100);
     setTimeout(UI.setBarPosition, 100);
     $D('noVNC_logo').style.display = "none";
     $D('noVNC_logo').style.display = "none";

+ 1 - 1
include/util.js

@@ -146,7 +146,7 @@ Util.conf_default = function(cfg, api, defaults, v, mode, type, defval, desc) {
             }
             }
         } else if (type in {'integer':1, 'int':1}) {
         } else if (type in {'integer':1, 'int':1}) {
             val = parseInt(val, 10);
             val = parseInt(val, 10);
-        } else if (type === 'string') {
+        } else if (type === 'str') {
             val = String(val);
             val = String(val);
         } else if (type === 'func') {
         } else if (type === 'func') {
             if (!val) {
             if (!val) {

+ 1 - 1
vnc_auto.html

@@ -103,7 +103,7 @@
 
 
             password = WebUtil.getQueryVar('password', '');
             password = WebUtil.getQueryVar('password', '');
             path = WebUtil.getQueryVar('path', 'websockify');
             path = WebUtil.getQueryVar('path', 'websockify');
-            
+
             if ((!host) || (!port)) {
             if ((!host) || (!port)) {
                 updateState('failed',
                 updateState('failed',
                     "Must specify host and port in URL");
                     "Must specify host and port in URL");