[Kimchi-devel] [PATCH] [Kimchi 3/3] Start up websockify on localhost
Aline Manera
alinefm at linux.vnet.ibm.com
Tue Jan 19 00:29:08 UTC 2016
From: Rob Lemley <rob.lemley at rochester.edu>
Wok is proxing the websockets port on 'websockify' target. That way, the
user does not need to open the websockets port on Firewall configuration.
Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
Signed-off-by: Rob Lemley <rob.lemley at rochester.edu>
---
ui/js/src/kimchi.api.js | 29 ++++++++++++++---------------
ui/spice-html5/pages/spice_auto.html | 2 +-
vnc.py | 8 ++++----
3 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
index 40f9f4f..af3034b 100644
--- a/ui/js/src/kimchi.api.js
+++ b/ui/js/src/kimchi.api.js
@@ -1,7 +1,7 @@
/*
* Project Kimchi
*
- * Copyright IBM, Corp. 2013-2015
+ * Copyright IBM, Corp. 2013-2016
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -293,20 +293,20 @@ var kimchi = {
vncToVM : function(vm) {
wok.requestJSON({
- url : 'plugins/kimchi/config',
+ url : 'config/',
type : 'GET',
dataType : 'json'
}).done(function(data, textStatus, xhr) {
- proxy_port = data['display_proxy_port'];
+ proxy_port = data['websockets_port'];
+ ssl_port = data['ssl_port'];
wok.requestJSON({
url : "plugins/kimchi/vms/" + encodeURIComponent(vm) + "/connect",
type : "POST",
dataType : "json"
}).done(function() {
- url = 'https://' + location.hostname + ':' + proxy_port;
- url += "/console.html?url=";
- url += encodeURIComponent("plugins/kimchi/novnc/vnc_auto.html");
- url += "&port=" + proxy_port;
+ url = 'https://' + location.hostname + ':' + ssl_port;
+ url += "/plugins/kimchi/novnc/vnc_auto.html";
+ url += "?port=" + ssl_port;
/*
* From python documentation base64.urlsafe_b64encode(s)
* substitutes - instead of + and _ instead of / in the
@@ -314,8 +314,7 @@ var kimchi = {
* contain = which is not safe in a URL query component.
* So remove it when needed as base64 can work well without it.
* */
- url += "&path=?token=" + wok.urlSafeB64Encode(vm).replace(/=*$/g, "");
- url += "&wok=" + location.port;
+ url += "&path=websockify?token=" + wok.urlSafeB64Encode(vm).replace(/=*$/g, "");
url += '&encrypt=1';
window.open(url);
});
@@ -326,19 +325,20 @@ var kimchi = {
spiceToVM : function(vm) {
wok.requestJSON({
- url : 'plugins/kimchi/config',
+ url : 'config/',
type : 'GET',
dataType : 'json'
}).done(function(data, textStatus, xhr) {
- proxy_port = data['display_proxy_port'];
+ proxy_port = data['websockets_port'];
+ ssl_port = data['ssl_port'];
wok.requestJSON({
url : "plugins/kimchi/vms/" + encodeURIComponent(vm) + "/connect",
type : "POST",
dataType : "json"
}).done(function(data, textStatus, xhr) {
- url = 'https://' + location.hostname + ':' + proxy_port;
- url += "/console.html?url=plugins/kimchi/spice_auto.html";
- url += "&port=" + proxy_port + "&listen=" + location.hostname;
+ url = 'https://' + location.hostname + ':' + ssl_port;
+ url += "/plugins/kimchi/spice_auto.html";
+ url += "?port=" + ssl_port + "&listen=" + location.hostname;
/*
* From python documentation base64.urlsafe_b64encode(s)
* substitutes - instead of + and _ instead of / in the
@@ -347,7 +347,6 @@ var kimchi = {
* So remove it when needed as base64 can work well without it.
* */
url += "&token=" + wok.urlSafeB64Encode(vm).replace(/=*$/g, "");
- url += "&wok=" + location.port;
url += '&encrypt=1';
window.open(url);
});
diff --git a/ui/spice-html5/pages/spice_auto.html b/ui/spice-html5/pages/spice_auto.html
index c87f5c2..91ddadb 100644
--- a/ui/spice-html5/pages/spice_auto.html
+++ b/ui/spice-html5/pages/spice_auto.html
@@ -143,7 +143,7 @@
* to point wok.user to a specific console represented by
* token value.
*/
- uri = scheme + host + ":" + port + "/?token=" + token;
+ uri = scheme + host + ":" + port + "/websockify?token=" + token;
try
{
diff --git a/vnc.py b/vnc.py
index 1a2e59d..9a25f50 100644
--- a/vnc.py
+++ b/vnc.py
@@ -2,7 +2,7 @@
#
# Project Kimchi
#
-# Copyright IBM, Corp. 2013-2015
+# Copyright IBM, Corp. 2013-2016
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -43,10 +43,10 @@ def new_ws_proxy():
cert = '%s/wok-cert.pem' % paths.conf_dir
key = '%s/wok-key.pem' % paths.conf_dir
- params = {'web': os.path.join(paths.ui_dir, 'pages/websockify'),
- 'listen_port': config.get('display', 'display_proxy_port'),
+ params = {'listen_host': '127.0.0.1',
+ 'listen_port': config.get('server', 'websockets_port'),
'target_cfg': WS_TOKENS_DIR,
- 'key': key, 'cert': cert, 'ssl_only': True}
+ 'ssl_only': False}
def start_proxy():
server = WebSocketProxy(**params)
--
2.5.0
More information about the Kimchi-devel
mailing list