1
1
import os
2
2
import shlex
3
- import tempfile
4
3
from shutil import which
5
4
6
5
HERE = os .path .dirname (os .path .abspath (__file__ ))
@@ -12,8 +11,6 @@ def setup_websockify():
12
11
raise RuntimeError (
13
12
"vncserver executable not found, please install a VNC server"
14
13
)
15
- if not which ('websockify' ):
16
- raise RuntimeError ("websockify executable not found, please install websockify" )
17
14
18
15
# TurboVNC and TigerVNC share the same origin and both use a Perl script
19
16
# as the executable vncserver. We can determine if vncserver is TigerVNC
@@ -30,16 +27,10 @@ def setup_websockify():
30
27
is_tigervnc = "tigervnc" in vncserver_file .read ().casefold ()
31
28
32
29
if is_tigervnc :
33
- # Make a secure temporary directory for sockets that is only readable,
34
- # writeable, and searchable by our uid - TigerVNC can listen to a Unix
35
- # socket!
36
- sockets_dir = tempfile .mkdtemp ()
37
- sockets_path = os .path .join (sockets_dir , 'vnc-socket' )
38
-
39
- websockify_args = ['--unix-target' , sockets_path ]
40
- vnc_args = [vncserver , '-rfbunixpath' , sockets_path ]
30
+ unix_socket = True
31
+ vnc_args = [vncserver , '-rfbunixpath' , "{unix_socket}" ]
41
32
else :
42
- websockify_args = []
33
+ unix_socket = False
43
34
vnc_args = [vncserver , '-localhost' , '-rfbport' , '{port}' ]
44
35
45
36
if not os .path .exists (os .path .expanduser ('~/.vnc/xstartup' )):
@@ -58,18 +49,13 @@ def setup_websockify():
58
49
)
59
50
60
51
return {
61
- 'command' : [
62
- 'websockify' ,
63
- '--verbose' ,
64
- '--heartbeat=30' ,
65
- '{port}' ,
66
- ]
67
- + websockify_args
68
- + ['--' , '/bin/sh' , '-c' , f'cd { os .getcwd ()} && { vnc_command } ' ],
52
+ 'command' : ['/bin/sh' , '-c' , f'cd { os .getcwd ()} && { vnc_command } ' ],
69
53
'timeout' : 30 ,
70
54
'new_browser_window' : True ,
71
55
# We want the launcher entry to point to /desktop/, not to /desktop-websockify/
72
56
# /desktop/ is the user facing URL, while /desktop-websockify/ now *only* serves
73
57
# websockets.
74
58
"launcher_entry" : {"title" : "Desktop" , "path_info" : "desktop" },
59
+ "unix_socket" : unix_socket ,
60
+ "raw_socket_proxy" : True ,
75
61
}
0 commit comments