[Kimchi-devel] [PATCH v2][Kimchi] Add support for websockify 0.7

Ramon Medeiros ramonn at linux.vnet.ibm.com
Wed Jan 20 13:02:07 UTC 2016


The lastest update of websockify changes how the class instantiate
WebSocketProxy.

Signed-off-by: Ramon Medeiros <ramonn at linux.vnet.ibm.com>
---
Changes: 

v2:
Change variable name
Instead of create params dictionary from begining, just append the changes


 vnc.py | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/vnc.py b/vnc.py
index 1a2e59d..f866126 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
 
 
+try:
+    from websockify.token_plugins import TokenFile
+    tokenFile = True
+except ImportError:
+    tokenFile = False
+
+
 WS_TOKENS_DIR = os.path.join(PluginPaths('kimchi').state_dir, 'vnc-tokens')
 
 
@@ -45,9 +53,16 @@ def new_ws_proxy():
 
     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 not tokenFile:
+        params['target_cfg'] = WS_TOKENS_DIR
+
+    # websockify 0.7 and higher: use TokenFile
+    else:
+        params['token_plugin'] = TokenFile(src=WS_TOKENS_DIR)
+
     def start_proxy():
         server = WebSocketProxy(**params)
         server.start_server()
-- 
2.1.0




More information about the Kimchi-devel mailing list