From e83b9e03ebecf6da7e3d7641d2d92a838353a328 Mon Sep 17 00:00:00 2001 From: Will Rouesnel Date: Sat, 13 Apr 2013 18:45:56 +1000 Subject: [PATCH 1/3] Detect port properly in vnc_auto.html when used on port 80 or 443. Browsers (such as Chrome) don't report port numbers in window.location.port when used on standard ports such as 80 and 443. This causes vnc_auto.html to not automatically find the port as it should. This simple change checks if window.location.port is blank, and sets port as appropriate from the name of the protocol in use. --- vnc_auto.html | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/vnc_auto.html b/vnc_auto.html index 064b3899..d8eb0a5a 100644 --- a/vnc_auto.html +++ b/vnc_auto.html @@ -122,6 +122,17 @@ 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 + if (!port) { + if (window.location.protocol.substring(0,4) == 'http') { + port = 80; + } + else if (window.location.protocol.substring(0,5) == 'https') { + port = 443; + } + } + // If a token variable is passed in, set the parameter in a cookie. // This is used by nova-novncproxy. token = WebUtil.getQueryVar('token', null); From c42136d537372f3fdf2310111d4505b72a39957e Mon Sep 17 00:00:00 2001 From: Will Rouesnel Date: Mon, 22 Apr 2013 20:07:20 +1000 Subject: [PATCH 2/3] Add default port logic to include/ui.js Correctly identifies the use of http/https and forces the value of port to 80 and 443 respectively, as in this situation window.location.port is blank. This is patch includes the same changes as made in vnc_auto.html --- include/ui.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/ui.js b/include/ui.js index 25bf162b..e9880af4 100644 --- a/include/ui.js +++ b/include/ui.js @@ -55,6 +55,18 @@ start: function(callback) { // call twice to get around webkit bug WebUtil.selectStylesheet(UI.getSetting('stylesheet')); + // if port == 80 (or 443) then it won't be present and should be + // set manually + port = window.location.port; + if (!port) { + if (window.location.protocol.substring(0,4) == 'http') { + port = 80; + } + else if (window.location.protocol.substring(0,5) == 'https') { + port = 443; + } + } + /* Populate the controls if defaults are provided in the URL */ UI.initSetting('host', window.location.hostname); UI.initSetting('port', window.location.port); From 58873b322228f2dadc9d583144c3333bf6dabd92 Mon Sep 17 00:00:00 2001 From: Will Rouesnel Date: Tue, 23 Apr 2013 14:32:02 +1000 Subject: [PATCH 3/3] Use port in UI.initSetting in include/ui.js Because apparently it is simple enough for me to forget to include in the previous commit. --- include/ui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ui.js b/include/ui.js index e9880af4..8e33672a 100644 --- a/include/ui.js +++ b/include/ui.js @@ -69,7 +69,7 @@ start: function(callback) { /* Populate the controls if defaults are provided in the URL */ UI.initSetting('host', window.location.hostname); - UI.initSetting('port', window.location.port); + UI.initSetting('port', port); UI.initSetting('password', ''); UI.initSetting('encrypt', (window.location.protocol === "https:")); UI.initSetting('true_color', true);