Commit 53ff0b98 authored by Wolfgang Bumiller's avatar Wolfgang Bumiller Committed by Dietmar Maurer

work around ipv6 browser inconsistencies

Browsers seem to disagree on whether window.location.hostname
shouldinclude the brackets around an ipv6 address.
Adding PVE.Utils.windowHostname() to always strip them away.
parent a01ed43d
...@@ -44,6 +44,7 @@ var IPV6_REGEXP = "(?:" + ...@@ -44,6 +44,7 @@ var IPV6_REGEXP = "(?:" +
var IP6_match = new RegExp("^(?:" + IPV6_REGEXP + ")$"); var IP6_match = new RegExp("^(?:" + IPV6_REGEXP + ")$");
var IP6_cidr_match = new RegExp("^(?:" + IPV6_REGEXP + ")\/[0-9]{1,3}?$"); var IP6_cidr_match = new RegExp("^(?:" + IPV6_REGEXP + ")\/[0-9]{1,3}?$");
var IP6_bracket_match = new RegExp("^\\[(" + IPV6_REGEXP + ")\\]");
var IP64_match = new RegExp("^(?:" + IPV6_REGEXP + "|" + IPV4_REGEXP + ")$"); var IP64_match = new RegExp("^(?:" + IPV6_REGEXP + "|" + IPV4_REGEXP + ")$");
...@@ -921,6 +922,11 @@ Ext.define('PVE.Utils', { statics: { ...@@ -921,6 +922,11 @@ Ext.define('PVE.Utils', { statics: {
} }
}, },
windowHostname: function() {
return window.location.hostname.replace(IP6_bracket_match,
function(m, addr, offset, original) { return addr; });
},
openDefaultConsoleWindow: function(allowSpice, vmtype, vmid, nodename, vmname) { openDefaultConsoleWindow: function(allowSpice, vmtype, vmid, nodename, vmname) {
var dv = PVE.Utils.defaultViewer(allowSpice); var dv = PVE.Utils.defaultViewer(allowSpice);
PVE.Utils.openConsoleWindow(dv, vmtype, vmid, nodename, vmname); PVE.Utils.openConsoleWindow(dv, vmtype, vmid, nodename, vmname);
...@@ -941,7 +947,7 @@ Ext.define('PVE.Utils', { statics: { ...@@ -941,7 +947,7 @@ Ext.define('PVE.Utils', { statics: {
PVE.Utils.openVNCViewer(vmtype, vmid, nodename, vmname, viewer === 'html5'); PVE.Utils.openVNCViewer(vmtype, vmid, nodename, vmname, viewer === 'html5');
} else if (viewer === 'vv') { } else if (viewer === 'vv') {
var url; var url;
var params = { proxy: window.location.hostname }; var params = { proxy: PVE.Utils.windowHostname() };
if (vmtype === 'kvm') { if (vmtype === 'kvm') {
url = '/nodes/' + nodename + '/qemu/' + vmid.toString() + '/spiceproxy'; url = '/nodes/' + nodename + '/qemu/' + vmid.toString() + '/spiceproxy';
PVE.Utils.openSpiceViewer(url, params); PVE.Utils.openSpiceViewer(url, params);
......
...@@ -45,6 +45,7 @@ var IPV6_REGEXP = "(?:" + ...@@ -45,6 +45,7 @@ var IPV6_REGEXP = "(?:" +
var IP6_match = new RegExp("^(?:" + IPV6_REGEXP + ")$"); var IP6_match = new RegExp("^(?:" + IPV6_REGEXP + ")$");
var IP6_cidr_match = new RegExp("^(?:" + IPV6_REGEXP + ")\/[0-9]{1,3}?$"); var IP6_cidr_match = new RegExp("^(?:" + IPV6_REGEXP + ")\/[0-9]{1,3}?$");
var IP6_bracket_match = new RegExp("^\\[(" + IPV6_REGEXP + ")\\]");
var IP64_match = new RegExp("^(?:" + IPV6_REGEXP + "|" + IPV4_REGEXP + ")$"); var IP64_match = new RegExp("^(?:" + IPV6_REGEXP + "|" + IPV4_REGEXP + ")$");
...@@ -922,6 +923,11 @@ Ext.define('PVE.Utils', { statics: { ...@@ -922,6 +923,11 @@ Ext.define('PVE.Utils', { statics: {
} }
}, },
windowHostname: function() {
return window.location.hostname.replace(IP6_bracket_match,
function(m, addr, offset, original) { return addr; });
},
openDefaultConsoleWindow: function(allowSpice, vmtype, vmid, nodename, vmname) { openDefaultConsoleWindow: function(allowSpice, vmtype, vmid, nodename, vmname) {
var dv = PVE.Utils.defaultViewer(allowSpice); var dv = PVE.Utils.defaultViewer(allowSpice);
PVE.Utils.openConsoleWindow(dv, vmtype, vmid, nodename, vmname); PVE.Utils.openConsoleWindow(dv, vmtype, vmid, nodename, vmname);
...@@ -942,7 +948,7 @@ Ext.define('PVE.Utils', { statics: { ...@@ -942,7 +948,7 @@ Ext.define('PVE.Utils', { statics: {
PVE.Utils.openVNCViewer(vmtype, vmid, nodename, vmname, viewer === 'html5'); PVE.Utils.openVNCViewer(vmtype, vmid, nodename, vmname, viewer === 'html5');
} else if (viewer === 'vv') { } else if (viewer === 'vv') {
var url; var url;
var params = { proxy: window.location.hostname }; var params = { proxy: PVE.Utils.windowHostname() };
if (vmtype === 'kvm') { if (vmtype === 'kvm') {
url = '/nodes/' + nodename + '/qemu/' + vmid.toString() + '/spiceproxy'; url = '/nodes/' + nodename + '/qemu/' + vmid.toString() + '/spiceproxy';
PVE.Utils.openSpiceViewer(url, params); PVE.Utils.openSpiceViewer(url, params);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment