Skip to content

Commit

Permalink
api changes to support spice-web-client
Browse files Browse the repository at this point in the history
  • Loading branch information
pgurenko committed Apr 22, 2019
1 parent 8fc9e44 commit 389241b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 17 deletions.
48 changes: 32 additions & 16 deletions ui/js/src/kimchi.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,22 +372,38 @@ var kimchi = {
}).done(function(data, textStatus, xhr) {
url = 'https://' + location.hostname + ':' + proxy_port;
url += server_root;
url += "/plugins/kimchi/spice_auto.html";
/*
* When using server_root we need pass the value with port
* argument to be used correctly by spice_auto.html scripts
*/
url += "?port=" + proxy_port + server_root;
url += "&listen=" + location.hostname;
/*
* From python documentation base64.urlsafe_b64encode(s)
* substitutes - instead of + and _ instead of / in the
* standard Base64 alphabet, BUT the result can still
* contain = which is not safe in a URL query component.
* So remove it when needed as base64 can work well without it.
* */
url += "&token=" + wok.urlSafeB64Encode(vm).replace(/=*$/g, "");
url += '&encrypt=1';

let spice_html5 = true;
if(spice_html5)
{
url += "/plugins/kimchi/spice_auto.html";
/*
* When using server_root we need pass the value with port
* argument to be used correctly by spice_auto.html scripts
*/
url += "?port=" + proxy_port + server_root;
url += "&listen=" + location.hostname;
/*
* From python documentation base64.urlsafe_b64encode(s)
* substitutes - instead of + and _ instead of / in the
* standard Base64 alphabet, BUT the result can still
* contain = which is not safe in a URL query component.
* So remove it when needed as base64 can work well without it.
* */
url += "&token=" + wok.urlSafeB64Encode(vm).replace(/=*$/g, "");
url += '&encrypt=1';
}
else
{
/*
* Slightly different api for spice-web-client
*/
url += "/plugins/kimchi/spice-web-client/index.html";
url += "?port=" + proxy_port + server_root;
url += "&host=" + location.hostname;
url += "&vmInfoToken=" + wok.urlSafeB64Encode(vm).replace(/=*$/g, "");
url += '&protocol=wss';
}
window.open(url);
});
},
Expand Down
2 changes: 1 addition & 1 deletion ui/spice-web-client/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ wdi.Utils = {
* If not, an URL with destInfoToken is generated, host and port are resolved by backend service.
*/
if ( ! destHost || ! destPort ) {
url = protocol + '://' + host + ':' + port + '/websockify/destInfoToken/' + destInfoToken + '/type/' + type;
url = protocol + '://' + host + ':' + port + '/websockify?token=' + destInfoToken;
} else {
url = protocol + '://' + host + ':' + port + '/websockify/host/' + destHost + '/port/' + destPort + '/type/' + type;
}
Expand Down

0 comments on commit 389241b

Please sign in to comment.