diff --git a/include/rfb.js b/include/rfb.js index c9fd92a9..1c9d6711 100644 --- a/include/rfb.js +++ b/include/rfb.js @@ -40,6 +40,7 @@ var that = {}, // Public API methods rfb_port = 5900, rfb_password = '', rfb_path = '', + rfb_queryargs = '', rfb_state = 'disconnected', rfb_version = 0, @@ -305,6 +306,12 @@ function connect() { } uri += rfb_host + ":" + rfb_port + "/" + rfb_path; } + if (rfb_queryargs != null) { + var querystr = WebUtil.objToQueryString(rfb_queryargs); + if (querystr != "") { + uri += "?" + querystr; + } + } Util.Info("connecting to " + uri); // TODO: make protocols a configurable ws.open(uri, conf.wsProtocols); @@ -1880,13 +1887,14 @@ clientCutText = function(text) { // Public API interface functions // -that.connect = function(host, port, password, path) { +that.connect = function(host, port, password, path, queryargs) { //Util.Debug(">> connect"); rfb_host = host; rfb_port = port; rfb_password = (password !== undefined) ? password : ""; rfb_path = (path !== undefined) ? path : ""; + rfb_queryargs = (queryargs !== undefined) ? queryargs : null; if ((!rfb_host) || (!rfb_port)) { return fail("Must set host and port"); diff --git a/include/webutil.js b/include/webutil.js index 5ceccbef..fdb63607 100644 --- a/include/webutil.js +++ b/include/webutil.js @@ -219,3 +219,12 @@ WebUtil.selectStylesheet = function(sheet) { } return sheet; }; + +// Method to help create query string from simple map +WebUtil.objToQueryString = function(obj) { + var str = []; + for(var p in obj) { + str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); + } + return str.join("&"); +} diff --git a/vnc_auto.html b/vnc_auto.html index 53b8220c..11216ef2 100644 --- a/vnc_auto.html +++ b/vnc_auto.html @@ -149,7 +149,7 @@ } window.onscriptsload = function () { - var host, port, password, path, token; + var host, port, password, path, token, queryargs; $D('sendCtrlAltDelButton').style.display = "inline"; $D('sendCtrlAltDelButton').onclick = sendCtrlAltDel; @@ -178,6 +178,7 @@ // This is used by nova-novncproxy. token = WebUtil.getQueryVar('token', null); if (token) { + queryargs = {token: token}; WebUtil.createCookie('token', token, 1) } @@ -201,7 +202,7 @@ 'updateState': updateState, 'onXvpInit': xvpInit, 'onPasswordRequired': passwordRequired}); - rfb.connect(host, port, password, path); + rfb.connect(host, port, password, path, queryargs); };