@@ -33,15 +33,7 @@ def get_xpra_executable(prog):
33
33
34
34
35
35
def _xprahtml5_urlparams ():
36
- from getpass import getuser
37
-
38
- url_params = '?' + '&' .join ([
39
- 'username=' + getuser (),
40
- 'password=' + _xprahtml5_passwd ,
41
- 'encryption=AES' ,
42
- 'key=' + _xprahtml5_aeskey ,
43
- 'sharing=true' ,
44
- ])
36
+ url_params = '?sharing=true'
45
37
46
38
return url_params
47
39
@@ -60,48 +52,12 @@ def setup_xprahtml5():
60
52
""" Setup commands and and return a dictionary compatible
61
53
with jupyter-server-proxy.
62
54
"""
63
- from pathlib import Path
64
- from tempfile import gettempdir , mkstemp , mkdtemp
65
- from random import choice
66
- from string import ascii_letters , digits
67
-
68
- global _xprahtml5_passwd , _xprahtml5_aeskey
69
-
70
- # password generator
71
- def _get_random_alphanumeric_string (length ):
72
- letters_and_digits = ascii_letters + digits
73
- return ('' .join ((choice (letters_and_digits ) for i in range (length ))))
55
+ from tempfile import mkdtemp
74
56
75
57
# ensure a known secure sockets directory exists, as /run/user/$UID might not be available
76
- socket_path = mkdtemp (prefix = 'xpra_sockets_' + str (os .getuid ()))
58
+ socket_path = mkdtemp (prefix = 'xpra_sockets_' + str (os .getuid ()) + '_' )
77
59
logger .info ('Created secure socket directory for Xpra: ' + socket_path )
78
60
79
- # generate file with random one-time-password
80
- _xprahtml5_passwd = _get_random_alphanumeric_string (16 )
81
- try :
82
- fd_passwd , fpath_passwd = mkstemp ()
83
- logger .info ('Created secure password file for Xpra: ' + fpath_passwd )
84
-
85
- with open (fd_passwd , 'w' ) as f :
86
- f .write (_xprahtml5_passwd )
87
-
88
- except Exception :
89
- logger .error ("Passwd generation in temp file FAILED" )
90
- raise FileNotFoundError ("Passwd generation in temp file FAILED" )
91
-
92
- # generate file with random encryption key
93
- _xprahtml5_aeskey = _get_random_alphanumeric_string (16 )
94
- try :
95
- fd_aeskey , fpath_aeskey = mkstemp ()
96
- logger .info ('Created secure encryption key file for Xpra: ' + fpath_aeskey )
97
-
98
- with open (fd_aeskey , 'w' ) as f :
99
- f .write (_xprahtml5_aeskey )
100
-
101
- except Exception :
102
- logger .error ("Encryption key generation in temp file FAILED" )
103
- raise FileNotFoundError ("Encryption key generation in temp file FAILED" )
104
-
105
61
# launchers url file including url parameters
106
62
path_info = 'xprahtml5/index.html' + _xprahtml5_urlparams ()
107
63
@@ -110,15 +66,9 @@ def _get_random_alphanumeric_string(length):
110
66
get_xpra_executable ('xpra' ),
111
67
'start' ,
112
68
'--html=on' ,
113
- '--bind-tcp=0.0.0.0:{port}' ,
114
- # '--socket-dir="' + socket_path + '/"', # fixme: socket_dir not recognized
115
- # '--server-idle-timeout=86400', # stop server after 24h with no client connection
116
- # '--exit-with-client=yes', # stop Xpra when the browser disconnects
69
+ '--bind={unix_socket},auth=none' , # using sockets + jupyter-server-proxy => auth is not needed here
70
+ '--socket-dir=' + socket_path ,
117
71
'--start=xterm -fa "DejaVu Sans Mono" -fs 14' ,
118
- # '--start-child=xterm', '--exit-with-children',
119
- '--tcp-auth=file:filename=' + fpath_passwd ,
120
- '--tcp-encryption=AES' ,
121
- '--tcp-encryption-keyfile=' + fpath_aeskey ,
122
72
'--clipboard-direction=both' ,
123
73
'--no-keyboard-sync' , # prevent keys from repeating unexpectedly on high latency
124
74
'--no-mdns' , # do not advertise the xpra session on the local network
@@ -127,18 +77,19 @@ def _get_random_alphanumeric_string(length):
127
77
'--no-printing' ,
128
78
'--no-microphone' ,
129
79
'--no-notifications' ,
80
+ # '--dbus-control=no',
130
81
'--no-systemd-run' , # do not delegated start-cmd to the system wide proxy server instance
131
- # '--dpi=96', # only needed if Xserver does not support dynamic dpi change
132
82
'--sharing' , # this allows to open the desktop in multiple browsers at the same time
133
83
'--no-daemon' , # mandatory
134
84
]
135
85
logger .info ('Xpra command: ' + ' ' .join (cmd ))
136
86
137
87
return {
138
- 'environment' : { # as '--socket-dir' does not work as expected, we set this
88
+ 'environment' : {
139
89
'XDG_RUNTIME_DIR' : socket_path ,
140
90
},
141
91
'command' : cmd ,
92
+ 'unix_socket' : socket_path + '/xpra-server' ,
142
93
'mappath' : _xprahtml5_mappath ,
143
94
'absolute_url' : False ,
144
95
'timeout' : 90 ,
0 commit comments