Skip to content

Instantly share code, notes, and snippets.

@dmamolina
Created November 10, 2015 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmamolina/0c76d5b9b6e329e44060 to your computer and use it in GitHub Desktop.
Save dmamolina/0c76d5b9b6e329e44060 to your computer and use it in GitHub Desktop.
diff --git a/src/sunstone/public/app/console/vnc.js b/src/sunstone/public/app/console/vnc.js
index 5e4e05d..231bb49 100644
--- a/src/sunstone/public/app/console/vnc.js
+++ b/src/sunstone/public/app/console/vnc.js
@@ -29,19 +29,31 @@ define(function(require) {
require('vnc-keysym');
var rfb;
+ var encrypt = WebUtil.getQueryVar('encrypt', (window.location.protocol === "https:"));
+ var repeaterID = WebUtil.getQueryVar('repeaterID', '');
+ var true_color = WebUtil.getQueryVar('true_color', true);
+ var local_cursor = WebUtil.getQueryVar('cursor', true);
+ var shared = WebUtil.getQueryVar('shared', true);
+ var view_only = WebUtil.getQueryVar('view_only', false);
+ var host = WebUtil.getQueryVar('host', window.location.hostname);
+ var port = WebUtil.getQueryVar('port', window.location.port);
+ var token = WebUtil.getQueryVar('token', null);
+ var path = WebUtil.getQueryVar('path', 'websockify');
function passwordRequired(rfb) {
var msg;
- msg = '<form onsubmit="return setPassword();"';
+ msg = '<form id="setPasswordForm"';
msg += ' style="margin-bottom: 0px">';
msg += 'Password Required: ';
msg += '<input type=password size=10 id="password_input" class="noVNC_status">';
msg += '<\/form>';
$D('noVNC_status_bar').setAttribute("class", "noVNC_status_warn");
$D('noVNC_status').innerHTML = msg;
+ document.getElementById("setPasswordForm").addEventListener("submit", setPassword);
}
- function setPassword() {
+ function setPassword(event) {
rfb.sendPassword($D('password_input').value);
+ event.preventDefault();
return false;
}
function sendCtrlAltDel() {
@@ -108,8 +120,6 @@ define(function(require) {
WebUtil.init_logging(WebUtil.getQueryVar('logging', 'warn'));
document.title = unescape(WebUtil.getQueryVar('title', 'noVNC'));
// By default, use the host and port of server that served this file
- host = WebUtil.getQueryVar('host', window.location.hostname);
- port = WebUtil.getQueryVar('port', window.location.port);
// if port == 80 (or 443) then it won't be present and should be
// set manually
@@ -123,14 +133,10 @@ define(function(require) {
// If a token variable is passed in, set the parameter in a cookie.
// This is used by nova-novncproxy.
- token = WebUtil.getQueryVar('token', null);
if (token) {
WebUtil.createCookie('token', token, 1)
}
- password = WebUtil.getQueryVar('password', '');
- path = WebUtil.getQueryVar('path', 'websockify');
-
if ((!host) || (!port)) {
updateState('failed',
"Must specify host and port in URL");
@@ -138,16 +144,15 @@ define(function(require) {
}
rfb = new RFB({'target': $D('noVNC_canvas'),
- 'encrypt': WebUtil.getQueryVar('encrypt',
- (window.location.protocol === "https:")),
- 'repeaterID': WebUtil.getQueryVar('repeaterID', ''),
- 'true_color': WebUtil.getQueryVar('true_color', true),
- 'local_cursor': WebUtil.getQueryVar('cursor', true),
- 'shared': WebUtil.getQueryVar('shared', true),
- 'view_only': WebUtil.getQueryVar('view_only', false),
+ 'encrypt': encrypt,
+ 'repeaterID': repeaterID,
+ 'true_color': true_color,
+ 'local_cursor': local_cursor,
+ 'shared': shared,
+ 'view_only': view_only,
'onUpdateState': updateState,
'onXvpInit': xvpInit,
'onPasswordRequired': passwordRequired});
- rfb.connect(host, port, password, path + "?token=" + token);
+ rfb.connect(host, port, undefined, path + "?token=" + token);
})
diff --git a/src/sunstone/public/app/utils/vnc.js b/src/sunstone/public/app/utils/vnc.js
index dd3e8ca..25666b5 100644
--- a/src/sunstone/public/app/utils/vnc.js
+++ b/src/sunstone/public/app/utils/vnc.js
@@ -74,7 +74,7 @@ define(function(require) {
url += "host=" + proxy_host;
url += "&port=" + proxy_port;
url += "&token=" + token;
- url += "&password=" + pw;
+ //url += "&password=" + pw;
url += "&encrypt=" + Config.vncWSS;
url += "&title=" + vm_name;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment