[Kimchi-devel] [Kimchi] Add support for websockify 0.7
Ramon Medeiros
ramonn at linux.vnet.ibm.com
Wed Jan 20 12:24:37 UTC 2016
The lastest update of websockify changes how the class instantiate
WebSocketProxy.
Signed-off-by: Ramon Medeiros <ramonn at linux.vnet.ibm.com>
---
vnc.py | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/vnc.py b/vnc.py
index 1a2e59d..00069d5 100644
--- a/vnc.py
+++ b/vnc.py
@@ -21,12 +21,20 @@
import base64
import errno
import os
+
from multiprocessing import Process
from websockify import WebSocketProxy
from wok.config import config, paths, PluginPaths
+websockifyOld = False
+try:
+ from websockify.token_plugins import TokenFile
+except ImportError:
+ websockifyOld = True
+
+
WS_TOKENS_DIR = os.path.join(PluginPaths('kimchi').state_dir, 'vnc-tokens')
@@ -43,10 +51,21 @@ 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'),
- 'target_cfg': WS_TOKENS_DIR,
- 'key': key, 'cert': cert, 'ssl_only': True}
+ # old websockify: do not use TokenFile
+ if websockifyOld:
+ params = {'web': os.path.join(paths.ui_dir, 'pages/websockify'),
+ 'listen_port': config.get('display', 'display_proxy_port'),
+ 'target_cfg': WS_TOKENS_DIR,
+ 'key': key, 'cert': cert, 'ssl_only': True}
+
+ # websockify 0.7 and higher: use TokenFile
+ else:
+ token_plugin = TokenFile(src=WS_TOKENS_DIR)
+
+ params = {'web': os.path.join(paths.ui_dir, 'pages/websockify'),
+ 'listen_port': config.get('display', 'display_proxy_port'),
+ 'token_plugin': token_plugin,
+ 'key': key, 'cert': cert, 'ssl_only': True}
def start_proxy():
server = WebSocketProxy(**params)
--
2.1.0
More information about the Kimchi-devel
mailing list