From 743773e256298e72c554b7c0b97be64d25300546 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Could not connect to tunnel server. Please, check your network settings. Could not connect to tunnel server. Please, check your network settings. You need to have installed NX Client version 3.5 in order to connect to this UDS service. Please, install appropriate package for your system. You need to have installed NX Client version 3.5 in order to connect to this UDS service. Please, install appropriate package for your system. Could not connect to tunnel server. Please, check your network settings. Microsoft Remote Desktop or xfreerdp not found In order to connect to UDS RDP Sessions, you need to have a
Microsoft Remote Desktop or xfreerdp not found In order to connect to UDS RDP Sessions, you need to have a
Could not connect to tunnel server. Please, check your network settings. Could not connect to tunnel server. Please, check your network settings.
@@ -63,7 +63,7 @@ if executable is None:
''')
elif executable == msrdc:
- theFile = sp['as_file']
+ theFile = sp['as_file'] # type: ignore
filename = tools.saveTempFile(theFile)
# Rename as .rdp, so open recognizes it
shutil.move(filename, filename + '.rdp')
@@ -75,8 +75,8 @@ elif executable == xfreerdp:
try:
xfparms = fixResolution()
except Exception as e:
- xfparms = list(map(lambda x: x.replace('#WIDTH#', '1400').replace('#HEIGHT#', '800'), sp['as_new_xfreerdp_params']))
+ xfparms = list(map(lambda x: x.replace('#WIDTH#', '1400').replace('#HEIGHT#', '800'), sp['as_new_xfreerdp_params'])) # type: ignore
- params = [executable] + xfparms + ['/v:{}'.format(sp['address'])] # @UndefinedVariable
+ params = [executable] + xfparms + ['/v:{}'.format(sp['address'])] # type: ignore
subprocess.Popen(params)
diff --git a/server/src/uds/transports/RDP/scripts/macosx/direct.py.signature b/server/src/uds/transports/RDP/scripts/macosx/direct.py.signature
index ac47080a..d5e1fb52 100644
--- a/server/src/uds/transports/RDP/scripts/macosx/direct.py.signature
+++ b/server/src/uds/transports/RDP/scripts/macosx/direct.py.signature
@@ -1 +1 @@
-noBupbQ4cXphbjY5YyaiPhqdv7z47GKvj++IvZHyyyit+9wWgZGxaPx+bLmqvr6Rz+ZJrxXYcW4qk5+CN+AKDe2ao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h/ZeEEm0Nj8e+uIYzOmA9/ftsQOWyhTkwRqK4o+bylQFWSQJhGWPB7hF4jY01yPo7sLY9H/YMci2ds1emys0K4tyyBDQOjcqRz6H0owvjPmWAPflJ6w+g39yklzPdegj4zHzbCtj0NFkWY0xGxhEclG/meTh1txl1SflU1k2E7LtLlV8x3Lgm1FF/QNFH/u0bBlXHg8AMik6Qi9fcf5NEveKY=
\ No newline at end of file
diff --git a/server/src/uds/transports/RDP/scripts/macosx/tunnel.py b/server/src/uds/transports/RDP/scripts/macosx/tunnel.py
index 5528515e..d62e37d2 100644
--- a/server/src/uds/transports/RDP/scripts/macosx/tunnel.py
+++ b/server/src/uds/transports/RDP/scripts/macosx/tunnel.py
@@ -18,9 +18,9 @@ def fixResolution():
import re
import subprocess
results = str(subprocess.Popen(['system_profiler SPDisplaysDataType'],stdout=subprocess.PIPE, shell=True).communicate()[0])
- res = re.search(': \d* x \d*', results).group(0).split(' ')
+ res = re.search(r': \d* x \d*', results).group(0).split(' ')
width, height = str(int(res[1])-4), str(int(int(res[3])-128)) # Width and Height
- return list(map(lambda x: x.replace('#WIDTH#', width).replace('#HEIGHT#', height), sp['as_new_xfreerdp_params']))
+ return list(map(lambda x: x.replace('#WIDTH#', width).replace('#HEIGHT#', height), sp['as_new_xfreerdp_params'])) # type: ignore
msrdc = '/Applications/Microsoft Remote Desktop.app/Contents/MacOS/Microsoft Remote Desktop'
@@ -30,11 +30,11 @@ executable = None
# Check first xfreerdp, allow password redir
if os.path.isfile(xfreerdp):
executable = xfreerdp
-elif os.path.isfile(msrdc) and sp['as_file']:
+elif os.path.isfile(msrdc) and sp['as_file']: # type: ignore
executable = msrdc
if executable is None:
- if sp['as_rdp_url']:
+ if sp['as_rdp_url']: # type: ignore
raise Exception('''
@@ -67,15 +67,16 @@ if executable is None:
''')
# Open tunnel
-fs = forward(remote=(sp['tunHost'], int(sp['tunPort'])), ticket=sp['ticket'], timeout=sp['tunWait'], check_certificate=sp['tunChk'])
+fs = forward(remote=(sp['tunHost'], int(sp['tunPort'])), ticket=sp['ticket'], timeout=sp['tunWait'], check_certificate=sp['tunChk']) # type: ignore
+address = '127.0.0.1:{}'.format(fs.server_address[1])
# Check that tunnel works..
if fs.check() is False:
raise Exception('
Could not connect to tunnel server.
Please, check your network settings.
') - if forwardThread1.status == 2: - raise Exception('Unable to open tunnel') -else: - port = -1 +fss = None +if sp['ticket_secure']: # type: ignore + # Open tunnel + fss = forward(remote=(sp['tunHost'], int(sp['tunPort'])), ticket=sp['ticket_secure'], timeout=sp['tunWait'], check_certificate=sp['tunChk']) # type: ignore -if sp['secure_port'] != '-1': - theFile = sp['as_file'] - if port != -1: - forwardThread2, secure_port = forwardThread1.clone(sp['ip'], sp['secure_port']) - else: - forwardThread2, secure_port = forward(sp['tunHost'], sp['tunPort'], sp['tunUser'], sp['tunPass'], sp['ip'], sp['secure_port']) - - if forwardThread2.status == 2: - raise Exception('Unable to open tunnel') -else: - secure_port = -1 + # Check that tunnel works.. + if fss.check() is False: + raise Exception('Could not connect to tunnel server 2.
Please, check your network settings.
') theFile = theFile.format( - secure_port=secure_port, - port=port + secure_port='-1' if not fss else fss.server_address[1], + port='-1' if not fs else fs.server_address[1] ) filename = tools.saveTempFile(theFile) diff --git a/server/src/uds/transports/SPICE/scripts/linux/tunnel.py.signature b/server/src/uds/transports/SPICE/scripts/linux/tunnel.py.signature index 9a012b64..70730d6d 100644 --- a/server/src/uds/transports/SPICE/scripts/linux/tunnel.py.signature +++ b/server/src/uds/transports/SPICE/scripts/linux/tunnel.py.signature @@ -1 +1 @@ -MwVxZsoxUK+gcMchgM9c3iYky6K7KZ+3z34uZCgpJzvad8dH7lwihqrJ+7tlk55mZU/ea+J4dqk4EgMX1LGzzm9SyE6/9Yz86lfNlj/bH4AtnwkWUHEtKUizTOCpZlhFjRs5Cif6LICeVzGLnPx27vpKzHhbre95kpsmCzJ33vmMnB0IsCrFBSmJw4BdxUcf/+n1CyA5WiUqzIXC1cIkJ212plpl6n+WP0tc40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c5Ak6u9nRaupnn5DHGnKNcR4DRxmCYjLdHhzjzfE61ErQ8PnVI7Yc4j23hYEMd+TM= \ No newline at end of file diff --git a/server/src/uds/transports/SPICE/scripts/macosx/direct.py b/server/src/uds/transports/SPICE/scripts/macosx/direct.py index 0828af6b..a50dae5a 100644 --- a/server/src/uds/transports/SPICE/scripts/macosx/direct.py +++ b/server/src/uds/transports/SPICE/scripts/macosx/direct.py @@ -6,7 +6,7 @@ from __future__ import unicode_literals import os import subprocess -from uds import tools # @UnresolvedImport +from uds import tools # type: ignore remoteViewer = '/Applications/RemoteViewer.app/Contents/MacOS/RemoteViewer' @@ -25,7 +25,7 @@ if not os.path.isfile(remoteViewer): ''') -theFile = sp['as_file'] +theFile = sp['as_file'] # type: ignore filename = tools.saveTempFile(theFile) diff --git a/server/src/uds/transports/SPICE/scripts/macosx/direct.py.signature b/server/src/uds/transports/SPICE/scripts/macosx/direct.py.signature index 6582b17a..f58eea1e 100644 --- a/server/src/uds/transports/SPICE/scripts/macosx/direct.py.signature +++ b/server/src/uds/transports/SPICE/scripts/macosx/direct.py.signature @@ -1 +1 @@ -omMUcXLu3wGpKRISFlcEG9j0GWbhkud++umoXOoAREnLPlqwxxlIiWEaB5fkTR2ZjPFIXB/lQzGN28PEDbCkxagXb8KA+zXWmYvwkj3uB0QpCkfk0I+5/0cy5p1njxaAyENGZQFVZorqWvtWzuaFsDZrDZvV0qygWK/a7TTwQOxr2xFElnG+u/HzSNx09VzAIeVNkIu/3xP3LA6fo5/uzswDDFmRSch02aFp7AL6PBroq2mdN4aopu/xsdSAEdRzSumPWRLNLVd/yttfW+OOvMX6liUQr0CkFP0BQrHeAJnZVHXVnUNYDqRvnb3m9DjVfjUbFRs5vljxgr9zlcmFRdUXOJMYgDZelMqY0MidOPStoxnx/VHNijurMyBF4rlra0jIAkojqwNMxe788A9WJwKmPxkgeBiqVrVNYgSUpGWixSp3UpNGOtyD6jbY0ghnABoED/3NQl2NZj93SUHliUV14shf6pkrcxk7I4AB0BSIvvLRX6B3sN5hk6wm5rgzLpPl1DlgRGLvCLuLyp8cqiXQalntWPThck9OZLL9MATRK5BkPqNx5M2eEl3gqNNYKwnm+cEFvwbUhSQKsnyqpKCdzQJzp6LkgO4XuSdP4GrNCjUObL4X6Ogq2kb/tc3//ouvES81M11aeS84jBV7+PRcibLXc0t7gcyAUuRxlnc= \ No newline at end of file +dqg89d/khZKFk2SUIrROrthcq22mzSffp2JwLDEMqt6RVwvpT9hHY3eajSauVFJXdAl/DfLnUB1W0mQHWp1FyFQsFzprQhvOxROmnsa+vju2TnwjJHpGFMGIT7AWs3pGlxs1399gGcTXoU09m2/qtHxGgzxTyLprdlqMD1WivN2T+8o1QjLvfPIkXX/A252zJ2GEgZPRW9eni4TjAPY7jUVyoFs3wXkAO5uqBZcB2tGnCkxQ9UuGIa2ladff6o00m9TgAuSvCikVDnknVWFIOguJ+WZ8TDfYVCmHLAH43JI+EWwPcn4OvIgdDc6E9GAn71Mnv33yI48/VTtzV/KFu9aQiAuPoUV1JPCP++jcfsZ7vs1Qe8PdI6gBeHM/3j48oREoQRGpn//q0xpwfbKvBm8qHQ+GI9tv9gDi4sva7tJPNELK4xzMBhCZcG3bHt0tq984oid6o3e8q6sgkVdUE7Jvh3gjlk6H8x596rX2f8hPvqzPEEB8JERl3iJTEGBYWl0l+d9LJiMQcSaMyKSoySoYT9btcdK6p3Dr1uurZxOjgjF/jHi/5yP3H8i5XspiEY/u4Dcehf8Y2rd7K3sFRh1GVSROCdUhBFXbvE4nDRxwUKehwmE769jLOWsq21L0TYtq3ErFahr5QxVjGP3yAmFWGjY2ToTKTqBveCb8DmU= \ No newline at end of file diff --git a/server/src/uds/transports/SPICE/scripts/macosx/tunnel.py b/server/src/uds/transports/SPICE/scripts/macosx/tunnel.py index fd402709..ea87b1b1 100644 --- a/server/src/uds/transports/SPICE/scripts/macosx/tunnel.py +++ b/server/src/uds/transports/SPICE/scripts/macosx/tunnel.py @@ -6,8 +6,8 @@ from __future__ import unicode_literals import os import subprocess -from uds import tools # @UnresolvedImport -from uds.forward import forward # @UnresolvedImport +from uds import tools # type: ignore +from uds.tunnel import forward # type: ignore remoteViewer = '/Applications/RemoteViewer.app/Contents/MacOS/RemoteViewer' @@ -25,31 +25,28 @@ if not os.path.isfile(remoteViewer): ''') -theFile = sp['as_file_ns'] -if sp['port'] != '-1': - forwardThread1, port = forward(sp['tunHost'], sp['tunPort'], sp['tunUser'], sp['tunPass'], sp['ip'], sp['port']) +theFile = sp['as_file_ns'] # type: ignore +fs = None +if sp['ticket']: # type: ignore + # Open tunnel + fs = forward(remote=(sp['tunHost'], int(sp['tunPort'])), ticket=sp['ticket'], timeout=sp['tunWait'], check_certificate=sp['tunChk']) # type: ignore + # Check that tunnel works.. + if fs.check() is False: + raise Exception('Could not connect to tunnel server.
Please, check your network settings.
') - if forwardThread1.status == 2: - raise Exception('Unable to open tunnel') -else: - port = -1 +fss = None +if sp['ticket_secure']: # type: ignore + # Open tunnel + fss = forward(remote=(sp['tunHost'], int(sp['tunPort'])), ticket=sp['ticket_secure'], timeout=sp['tunWait'], check_certificate=sp['tunChk']) # type: ignore -if sp['secure_port'] != '-1': - theFile = sp['as_file'] - if port != -1: - forwardThread2, secure_port = forwardThread1.clone(sp['ip'], sp['secure_port']) - else: - forwardThread2, secure_port = forward(sp['tunHost'], sp['tunPort'], sp['tunUser'], sp['tunPass'], sp['ip'], sp['secure_port']) - - if forwardThread2.status == 2: - raise Exception('Unable to open tunnel') -else: - secure_port = -1 + # Check that tunnel works.. + if fss.check() is False: + raise Exception('Could not connect to tunnel server 2.
Please, check your network settings.
') theFile = theFile.format( - secure_port=secure_port, - port=port + secure_port='-1' if not fss else fss.server_address[1], + port='-1' if not fs else fs.server_address[1] ) filename = tools.saveTempFile(theFile) diff --git a/server/src/uds/transports/SPICE/scripts/macosx/tunnel.py.signature b/server/src/uds/transports/SPICE/scripts/macosx/tunnel.py.signature index 8657b7da..c2fc0d8c 100644 --- a/server/src/uds/transports/SPICE/scripts/macosx/tunnel.py.signature +++ b/server/src/uds/transports/SPICE/scripts/macosx/tunnel.py.signature @@ -1 +1 @@ -dR+uIC5WKTM3Iicua7Jv7YEksMy8gIf3U5MfYzh6pCNYkkdEywpuszoIxHqgn/ltIjuvY4s2kATXqQtuZ7BYCNhB7vGw/nA/PDGqpOPNDCAamRL+N15Ctjb1+olmhQgqR+D/lv7GaScO+5n579OSmrHPaZkDbRo3U9wRiMzg+FLaL6Rknz8Hirpeas4kAculg+s3BeCRmf0fghz6UI9/xf+At0sd6M76p1E/3oFiIBjBNw9yKkLiPgDzq5DrrxA0SLWBwl15IPYqNpBCGo/VMV2pBQsSWmFGS62C3R6KdjMHN9jmO+seWcfhcNF2eCk3ODcoFeZUTfvXT+GoN7u7z3Dt4CyWx9k01RqSMxXcnf+vv2MqgBZde5Lu75ZqIpYP4qBkO4h6CH5isg1KVZJW/tGWGgU3fyVAkY9oxt6B8R2xo3mQeTkY+AGH+7KQHsB9l/OU0R1jHllbEIo9wopb4/SzZLMrECDMgOscA69BFodoFt6suT+QimzPHcgCQLE8xGY9KUZ7rrEn82rr3O7bAKXlJIti+UaT+zbgOizekA5+9CJRNVsWTmFsZ+6ghqY6L/QdyWJhere3Rrzh/0mg36Jk4XEaI8GI/VI/TmtmTwgut6B5gH/6fg+yaVAqYexIcINVMSSdIZyBVeX1QXbzcgYc5QJo9+EOJrzP5U0K+pI= \ No newline at end of file +NCdcJPSAu3yby5d/PiANn+iTTGsOt/GF8Kp9XxhdE1hZKFsR2USQob6tGTdM0HIIuL6i0KDOOvSa5JiD4Tq4OPE4sYSmaK4eDNo+RO7Fa4qP91ksOc3EcUCBGCru9+BNBVrWmAmlaJIfywvowodv8cP70yQxWqz93VomWvVUfJXhF6ylomzYN+gtLqjueKATWznf2d8pQ63g6p9j7p5yVJUGGZQCbuepS1Y3WUhSkf1EHrA233O+ZRK3YP6XDS75WnGkBEr/d/LrkzyYxlHX1UNFYaOay1I5cRXPJ9n2AVkmmZX8wyKxoCvAjwVZWaHoQWSZxNaDQ4YaEh14JK1JBnkpDQUDmgwVq1M0iY+aNlLg4VIMlFz6pVk3jcLk/CZfxMpH7ZkzYkL41vFlzG4lpFnQYoCCb3dPTZdAzg0EdtMy/Sk0X3Bn3dJzz+S2S4RjcLRHgy9hI5YeSVhFksruirWsbryb1WXIWjkjUIlMc/WVN17457onNpNQI2u7bebtoRopIox3gx06Afb3u5f0r7fUus+/1jWwoI8H73ES/RqpL2zXwXh9Ks1+5gFD1TDNkQn98Ia717DKwWoqZtjiJ+thY5Q3rgfLhgzJxRXm+XWDDSIVFdviyFB6m8U7/51xKME7ll5Tx4lVrwhMjFkfJj1TbOlnuvEiVrn4/9XDqo8= \ No newline at end of file diff --git a/server/src/uds/transports/SPICE/scripts/windows/direct.py b/server/src/uds/transports/SPICE/scripts/windows/direct.py index 39d9047f..b76b8c41 100644 --- a/server/src/uds/transports/SPICE/scripts/windows/direct.py +++ b/server/src/uds/transports/SPICE/scripts/windows/direct.py @@ -7,14 +7,14 @@ import os import glob import subprocess -from uds import tools # @UnresolvedImport +from uds import tools # type: ignore # Lets find remote viewer # There is a bug that when installed, the remote viewer (at least 64 bits version) does not store correctly its path, so lets find it "a las bravas" extraPaths = () for env in ('PROGRAMFILES', 'PROGRAMW6432'): if env in os.environ: - extraPaths += tuple(p + '\\bin' for p in glob.glob(os.environ[env] + '\\VirtViewer*')) + extraPaths += tuple(p + '\\bin' for p in glob.glob(os.environ[env] + '\\VirtViewer*')) # type: ignore executable = tools.findApp('remote-viewer.exe', extraPaths) @@ -28,7 +28,7 @@ if executable is None: ''') -theFile = sp['as_file'] +theFile = sp['as_file'] # type: ignore filename = tools.saveTempFile(theFile) diff --git a/server/src/uds/transports/SPICE/scripts/windows/direct.py.signature b/server/src/uds/transports/SPICE/scripts/windows/direct.py.signature index ad57f3c9..c97163a7 100644 --- a/server/src/uds/transports/SPICE/scripts/windows/direct.py.signature +++ b/server/src/uds/transports/SPICE/scripts/windows/direct.py.signature @@ -1 +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IpWODGTN2DHIHwZ1s3ghIfgm/REC7Q33pz7/pAQ0LthjJ77H41rePMig6aaO8yWhTuEk4K0XHJVq5fHaDAWCTvUdUiuRQuEjjJOhC8wSE0uMjCJ9hARVk+66xbrgllgbQwnDlmLVeA61+DQo6ygOCpqrHDlRFyPjVUvBThSehYM/eyUXY+Rsf9YLNx8FfCZQxmyUvb4r97EtCKadyDecumS/KHgeyA8gbosJLu2nNeHDYgOAFX5fewOt0leUHsqNTMpVznSMOFjO8wIv/XAJsfjkCkct0HVYVW3erQ2FVWyE= \ No newline at end of file diff --git a/server/src/uds/transports/SPICE/scripts/windows/tunnel.py b/server/src/uds/transports/SPICE/scripts/windows/tunnel.py index 0277df67..3a5a487c 100644 --- a/server/src/uds/transports/SPICE/scripts/windows/tunnel.py +++ b/server/src/uds/transports/SPICE/scripts/windows/tunnel.py @@ -7,15 +7,15 @@ import os import glob import subprocess -from uds import tools # @UnresolvedImport -from uds.forward import forward # @UnresolvedImport +from uds import tools # type: ignore +from uds.tunnel import forward # type: ignore # Lets find remote viewer # There is a bug that when installed, the remote viewer (at least 64 bits version) does not store correctly its path, so lets find it "a las bravas" extraPaths = () for env in ('PROGRAMFILES', 'PROGRAMW6432'): if env in os.environ: - extraPaths += tuple(p + '\\bin' for p in glob.glob(os.environ[env] + '\\VirtViewer*')) + extraPaths += tuple(p + '\\bin' for p in glob.glob(os.environ[env] + '\\VirtViewer*')) # type: ignore executable = tools.findApp('remote-viewer.exe', extraPaths) @@ -28,31 +28,28 @@ if executable is None: Open download page ''') -theFile = sp['as_file_ns'] -if sp['port'] != '-1': - forwardThread1, port = forward(sp['tunHost'], sp['tunPort'], sp['tunUser'], sp['tunPass'], sp['ip'], sp['port']) +theFile = sp['as_file_ns'] # type: ignore +fs = None +if sp['ticket']: # type: ignore + # Open tunnel + fs = forward(remote=(sp['tunHost'], int(sp['tunPort'])), ticket=sp['ticket'], timeout=sp['tunWait'], check_certificate=sp['tunChk']) # type: ignore + # Check that tunnel works.. + if fs.check() is False: + raise Exception('Could not connect to tunnel server.
Please, check your network settings.
') - if forwardThread1.status == 2: - raise Exception('Unable to open tunnel') -else: - port = -1 +fss = None +if sp['ticket_secure']: # type: ignore + # Open tunnel + fss = forward(remote=(sp['tunHost'], int(sp['tunPort'])), ticket=sp['ticket_secure'], timeout=sp['tunWait'], check_certificate=sp['tunChk']) # type: ignore -if sp['secure_port'] != '-1': - theFile = sp['as_file'] - if port != -1: - forwardThread2, secure_port = forwardThread1.clone(sp['ip'], sp['secure_port']) - else: - forwardThread2, secure_port = forward(sp['tunHost'], sp['tunPort'], sp['tunUser'], sp['tunPass'], sp['ip'], sp['secure_port']) - - if forwardThread2.status == 2: - raise Exception('Unable to open tunnel') -else: - secure_port = -1 + # Check that tunnel works.. + if fss.check() is False: + raise Exception('Could not connect to tunnel server 2.
Please, check your network settings.
') theFile = theFile.format( - secure_port=secure_port, - port=port + secure_port='-1' if not fss else fss.server_address[1], + port='-1' if not fs else fs.server_address[1] ) filename = tools.saveTempFile(theFile) diff --git a/server/src/uds/transports/SPICE/scripts/windows/tunnel.py.signature b/server/src/uds/transports/SPICE/scripts/windows/tunnel.py.signature index 88d4e94f..37291596 100644 --- a/server/src/uds/transports/SPICE/scripts/windows/tunnel.py.signature +++ b/server/src/uds/transports/SPICE/scripts/windows/tunnel.py.signature @@ -1 +1 @@ -WxhSxSYZISZNlj+Slprz8cdzstKFghx3zuQXdMmakzg5mLDyetwR9cSdWRkYd9vcP8j6aeufbK1io4rwvsdxu+7jRLSL9GVwB+MbIQYrBZ7RbiA2hqWhzQ/LCncSL73Jq9jZtt3i2pgWyA691z8UUbpts6wimsn6cDXQtEHda7MOFIi4Nzlzjf8AMpPTCkPldIDiXhyH+nuCXdzpOY32Gvrq8w6eTQrUWF8dswa1er0SQJENc2StEh9Tt1378QwTBtPQNgyop++sv/FhLdDB8hBQliX5LX7t9NxzZcvyFBYHqFnfXEsYc2bWWkt264CWfULREPLRQK11UWZ51ldvY1+xFOEg1eGAna8nWhapZ9R5DagSfehokpAov30Y0PwjTx5MGxiubd0gMeP4Vr2YZ77qBb5JnPKplEH2VsHS7TRgJyKNf2xI9Yw80iGSrO8LUC6L+9+cLDACyrmFINUA/2sFbRLjqdogY7CREIMzP07DUOluEcNgMnPLBKrTZ5U9nxnwgdgptLZgDNJHagitAiW5zMS10lEnJKRLZ0zVgWdiFna29SB7o75jO5M0LA+adIOzRH4G0C5vFYiiMVwsfLhqT3nUvaacTMLslFxWbr5T4QxWJkuLNjIMypw0cOzSaPsXW1tuZXwL0CjgnXDat7iNFQZCzEDQuoDaGDWvYpE= \ No newline at end of file +LNhHPgRKio48GqUpYgPIokcVEV6XHf/I17eSLSNabQ34QWiZybvlq2O7Gfztdag+1Zvig5urzFVbjuOfR3kIWAlt6hDRBo32cOveMngzUNnZfrpfehmMiFoCD91+/R/lXNm6x/fSpisbnThDejzk5vnG/xUZEls9qazSJLvpgRYR95IJxoArkhUMrAhkK7n0/0RDGQmhNJV50TYYYlnRcXCzeRaOJcReK1JkuovVHGFwTDDiLYa/irr5gWZqIhCgIzW7yGHeQGMAUoJkgPXexV9mWjMPIRbx3rBnPhtOJnywyILN+HQZ6SU2lsvGZMQQ2d/4WAZ+uP0k7CNS/81Cm6PZAL3LpnZ0zfszcWaAAF4rLbkimm1aKUXHoUwWkXfxjxodlQRXD3oE/jnTuMucl8WLUNnP7AwH5VQNxVTn33EoE8C3jRR5LcjL1ut7qSPno7Lf/UW2Yx1GGOCR0GLtuB5OPq0cIRjdqckibkL4jXRMX7QsXnh5uEYG+wih7gohzdcprFnhzQjFy4esQsKXqWTSaMgBVtUMOSGHylsQAps1j7Co6EGCMu/g7jrevk0f9T8moETA2fRPEmdV2Md/DFezsP2a042g8Git8llLGtibq329K/XAwC2mAwN768BHVu+WlZQmYcyz7iEU/tR9Dxq7y05ljiOCgAS4oK8ucQE= \ No newline at end of file diff --git a/server/src/uds/transports/SPICE/spice_tunnel.py b/server/src/uds/transports/SPICE/spice_tunnel.py index b66f4c97..672e0050 100644 --- a/server/src/uds/transports/SPICE/spice_tunnel.py +++ b/server/src/uds/transports/SPICE/spice_tunnel.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- - # -# Copyright (c) 2012-2019 Virtual Cable S.L. +# Copyright (c) 2012-2021 Virtual Cable S.L.U. # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, @@ -57,15 +56,44 @@ logger = logging.getLogger(__name__) class TSPICETransport(BaseSpiceTransport): """ Provides access via SPICE to service. - This transport can use an domain. If username processed by authenticator contains '@', it will split it and left-@-part will be username, and right password """ + typeName = _('SPICE') typeType = 'TSSPICETransport' typeDescription = _('SPICE Protocol. Tunneled connection.') protocol = transports.protocols.SPICE group: typing.ClassVar[str] = transports.TUNNELED_GROUP - tunnelServer = gui.TextField(label=_('Tunnel server'), order=1, tooltip=_('IP or Hostname of tunnel server sent to client device ("public" ip) and port. (use HOST:PORT format)'), tab=gui.TUNNEL_TAB) + tunnelServer = gui.TextField( + label=_('Tunnel server'), + order=1, + tooltip=_( + 'IP or Hostname of tunnel server sent to client device ("public" ip) and port. (use HOST:PORT format)' + ), + tab=gui.TUNNEL_TAB, + ) + + tunnelWait = gui.NumericField( + length=3, + label=_('Tunnel wait time'), + defvalue='30', + minValue=5, + maxValue=65536, + order=2, + tooltip=_('Maximum time to wait before closing the tunnel listener'), + required=True, + tab=gui.TUNNEL_TAB, + ) + + verifyCertificate = gui.CheckBoxField( + label=_('Force SSL certificate verification'), + order=23, + tooltip=_( + 'If enabled, the certificate of tunnel server will be verified (recommended).' + ), + defvalue=gui.TRUE, + tab=gui.TUNNEL_TAB, + ) serverCertificate = BaseSpiceTransport.serverCertificate fullScreen = BaseSpiceTransport.fullScreen @@ -76,34 +104,52 @@ class TSPICETransport(BaseSpiceTransport): def initialize(self, values: 'Module.ValuesType'): if values: if values['tunnelServer'].count(':') != 1: - raise transports.Transport.ValidationException(_('Must use HOST:PORT in Tunnel Server Field')) + raise transports.Transport.ValidationException( + _('Must use HOST:PORT in Tunnel Server Field') + ) def getUDSTransportScript( # pylint: disable=too-many-locals - self, - userService: 'models.UserService', - transport: 'models.Transport', - ip: str, - os: typing.Dict[str, str], - user: 'models.User', - password: str, - request: 'HttpRequest' - ) -> typing.Tuple[str, str, typing.Dict[str, typing.Any]]: + self, + userService: 'models.UserService', + transport: 'models.Transport', + ip: str, + os: typing.Dict[str, str], + user: 'models.User', + password: str, + request: 'HttpRequest', + ) -> typing.Tuple[str, str, typing.Dict[str, typing.Any]]: userServiceInstance: typing.Any = userService.getInstance() # Spice connection con = userServiceInstance.getConsoleConnection() - port: str = con['port'] or '-1' - secure_port: str = con['secure_port'] or '-1' - # Ticket - tunpass = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits) for _i in range(12)) - tunuser = TicketStore.create(tunpass) + # We MAY need two tickets, one for 'insecure' port an one for secure + ticket = '' + if con['port']: + ticket = TicketStore.create_for_tunnel( + userService=userService, + port=int(con['port']), + validity=self.tunnelWait.num() + 60, # Ticket overtime + ) - sshHost, sshPort = self.tunnelServer.value.split(':') + ticket_secure = '' + if con['secure_port']: + ticket_secure = TicketStore.create_for_tunnel( + userService=userService, + port=int(con['secure_port']), + validity=self.tunnelWait.num() + 60, # Ticket overtime + ) + + tunHost, tunPort = self.tunnelServer.value.split(':') r = RemoteViewerFile( - '127.0.0.1', '{port}', '{secure_port}', con['ticket']['value'], - self.serverCertificate.value.strip(), con['cert_subject'], fullscreen=self.fullScreen.isTrue() + '127.0.0.1', + '{port}', + '{secure_port}', + con['ticket']['value'], # This is secure ticket from kvm, not UDS ticket + self.serverCertificate.value.strip(), + con['cert_subject'], + fullscreen=self.fullScreen.isTrue(), ) r.usb_auto_share = self.usbShare.isTrue() r.new_usb_auto_share = self.autoNewUsbShare.isTrue() @@ -112,11 +158,13 @@ class TSPICETransport(BaseSpiceTransport): osName = { OsDetector.Windows: 'windows', OsDetector.Linux: 'linux', - OsDetector.Macintosh: 'macosx' + OsDetector.Macintosh: 'macosx', }.get(os['OS']) if osName is None: - return super().getUDSTransportScript(userService, transport, ip, os, user, password, request) + return super().getUDSTransportScript( + userService, transport, ip, os, user, password, request + ) # if sso: # If SSO requested, and when supported by platform # userServiceInstance.desktopLogin(user, password, '') @@ -124,13 +172,12 @@ class TSPICETransport(BaseSpiceTransport): sp = { 'as_file': r.as_file, 'as_file_ns': r.as_file_ns, - 'tunUser': tunuser, - 'tunPass': tunpass, - 'tunHost': sshHost, - 'tunPort': sshPort, - 'ip': con['address'], - 'port': port, - 'secure_port': secure_port + 'tunHost': tunHost, + 'tunPort': tunPort, + 'tunWait': self.tunnelWait.num(), + 'tunChk': self.verifyCertificate.isTrue(), + 'ticket': ticket, + 'ticket_secure': ticket_secure, } return self.getScript('scripts/{}/tunnel.py', osName, sp) diff --git a/server/src/uds/transports/X2GO/scripts/linux/direct.py b/server/src/uds/transports/X2GO/scripts/linux/direct.py index 84587265..3bdaa088 100644 --- a/server/src/uds/transports/X2GO/scripts/linux/direct.py +++ b/server/src/uds/transports/X2GO/scripts/linux/direct.py @@ -6,11 +6,11 @@ from __future__ import unicode_literals import subprocess from os.path import expanduser -from uds import tools # @UnresolvedImport +from uds import tools # type: ignore home = expanduser('~') + ':1;/media:1;' -keyFile = tools.saveTempFile(sp['key']) -theFile = sp['xf'].format(export=home, keyFile=keyFile.replace('\\', '/'), ip=sp['ip'], port=sp['port']) +keyFile = tools.saveTempFile(sp['key']) # type: ignore +theFile = sp['xf'].format(export=home, keyFile=keyFile.replace('\\', '/'), ip=sp['ip'], port=sp['port']) # type: ignore filename = tools.saveTempFile(theFile) # HOME=[temporal folder, where we create a .x2goclient folder and a sessions inside] pyhoca-cli -P UDS/test-session diff --git a/server/src/uds/transports/X2GO/scripts/linux/direct.py.signature b/server/src/uds/transports/X2GO/scripts/linux/direct.py.signature index b54fea1e..0668f966 100644 --- a/server/src/uds/transports/X2GO/scripts/linux/direct.py.signature +++ b/server/src/uds/transports/X2GO/scripts/linux/direct.py.signature @@ -1 +1 @@ -Td27A1n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iRa3ie1YSuxzbnpuysFkuTg8rl23cYLFyWRy/zdokJAdX9FC5b1KsFZ3slGI4iy1Q9WEIrNuFTvgZCE44V4HgP7IwadfMceF/RKOUs3L8Y1JAktqhe6bWjt/7e+ZLz0hIgoRj+OqCEkfp7xqp9eYNGTscUfQRcrqjN73786l34NNqYeWBkTnJNBcgZrp5NnKF3avzNDnMHTRnCZSSuGzKcXDP+UXdI2EUlk2oWQ0cZpuXe4JKH6fvWqtZ9E+TpywVMp3JEtlFZOmao+KKIst8Wdw= \ No newline at end of file diff --git a/server/src/uds/transports/X2GO/scripts/linux/tunnel.py b/server/src/uds/transports/X2GO/scripts/linux/tunnel.py index d101f43d..3419f1cc 100644 --- a/server/src/uds/transports/X2GO/scripts/linux/tunnel.py +++ b/server/src/uds/transports/X2GO/scripts/linux/tunnel.py @@ -5,20 +5,21 @@ from __future__ import unicode_literals # pylint: disable=import-error, no-name-in-module, too-many-format-args, undefined-variable import subprocess -from uds.forward import forward # @UnresolvedImport +from uds.tunnel import forward # type: ignore from os.path import expanduser -from uds import tools # @UnresolvedImport +from uds import tools # type: ignore -forwardThread, port = forward(sp['tunHost'], sp['tunPort'], sp['tunUser'], sp['tunPass'], sp['ip'], sp['port']) +# Open tunnel +fs = forward(remote=(sp['tunHost'], int(sp['tunPort'])), ticket=sp['ticket'], timeout=sp['tunWait'], check_certificate=sp['tunChk']) # type: ignore -if forwardThread.status == 2: - raise Exception('Unable to open tunnel') +# Check that tunnel works.. +if fs.check() is False: + raise Exception('Could not connect to tunnel server.
Please, check your network settings.
') -tools.addTaskToWait(forwardThread) home = expanduser('~') + ':1;/media:1;' -keyFile = tools.saveTempFile(sp['key']) -theFile = sp['xf'].format(export=home, keyFile=keyFile.replace('\\', '/'), ip='127.0.0.1', port=port) +keyFile = tools.saveTempFile(sp['key']) # type: ignore +theFile = sp['xf'].format(export=home, keyFile=keyFile.replace('\\', '/'), ip='127.0.0.1', port=fs.server_address[1]) # type: ignore filename = tools.saveTempFile(theFile) # HOME=[temporal folder, where we create a .x2goclient folder and a sessions inside] pyhoca-cli -P UDS/test-session diff --git a/server/src/uds/transports/X2GO/scripts/linux/tunnel.py.signature b/server/src/uds/transports/X2GO/scripts/linux/tunnel.py.signature index ec8f29ec..9d414085 100644 --- a/server/src/uds/transports/X2GO/scripts/linux/tunnel.py.signature +++ b/server/src/uds/transports/X2GO/scripts/linux/tunnel.py.signature @@ -1 +1 @@ -CnCqJRFLyii+jk4neecfXQ1tK3pKsdJ0b4z6XmLKPSLtzP+mMyrr5EK7RStN02KwvRhLwuXoH3lSp6ydGSwGtnRn44E6V2wIHkb/2dm09guR/KlTw21uBVabyYvH62yRjs54il0gL6YmTku3qWA7LeEEg7YuSxtXuNUgyEx28B1sTNBnW9E/FjIUSYF7vPgxiUaSbntmPvQehuqgaYKREtfVyB8cbTctqaJhz7sUtcetu461N9me4Lz7dxqAA3aAI2N1JV5QR/ATJAx29VuH0pG7iqhaXGe+K9oNbQyaS4sNIGHX+u/WR5a/ngr/m0llIcewHu/WxrAnSJLv6e+4+xpB5NQko0HR42cG6hy+IsaGMpid9Ubwilje1w+R0jWVZr3Xt14NnJKktysNhqLTEWw/hoCaJThJhzvEtM8B4H9Um65lPXGwTgvi2S71Hlql+IVJqxoj4DGdC7emU+MtwdHc3H4/YyCJC7X27PA1Hnmvr+BIjciQZC6BjuCyyppP3DozplmptAs0+FVZZs8BvJSsqm0pnFI5NM5Tf1WF/56JxBaAz0u4ugEwx4w/JnxorrydezOmP/xADIjFY3Xh7fkAGg1a48+WFGB+gpmXohbHnR8u4tnY30gnkCUqoJe/ZVJuK2Wyzs+8508+1A7ztTUGamZjhQPoXIrn0EDA5bs= \ No newline at end of file +OQ3g4Z39LoR6k8LseDP2Kktk3QCj14WeJ7RlqLcyXN5QXJTdu86lKQhLHapS4GUX9apcgcF1I+o5NyPeXoE8iXBQr0456Cz6k+O35jzlwrO1BXPby9bWEuUwlXvyQuHPY9wThQA++jWiKDV9UD5UC+BHP3BWWZVj1aVEunHJa2uqnMLQMVb63vIndclQXJcLXNuQk1v2jD6f2INxG0iojzfxJ95XrCN5OjgfhStimuFC3dCjm1shq1vSgpPVgampzMYO8ViJCzIk9dg6UKO+aWUmd617wRf0ZHJvez2Oerc8PDu/uYKSjPOChUapvkWRX84S8Ydn/4wUhUK9TKQt9iIBW4HOCVxB8gzX1fZwu5LqEii5f/LJWybFgrh33eJIBBJDyUU0Y+fp9IS8ayvOnEj1xONNTKpo0ZO407H1yTjcwoWAhT9Uob2BaMxCk90qy/OTN6mjtYbUvgKayUkV3OhbbSS8B/+t/wpyk2N6w74Qx2SqB5EqNIZT82raz4QM/Rggjq2im2F3gWwKUMkldt4u0Zf0qt6x8ov8qr/xeVuP+lUfnHJyYXvIOyUI6QZmdTem+lIATs/0a/Dp02yb+khW0TyDc3kc6F3Igf32PzleCiwXVkKfC/QZzKTLPPjaRZL+vEWu0tfh9qOZAutSRzs5nCuhIbvmnH19sbvBr4w= \ No newline at end of file diff --git a/server/src/uds/transports/X2GO/scripts/windows/direct.py b/server/src/uds/transports/X2GO/scripts/windows/direct.py index 20223156..0a7046fc 100644 --- a/server/src/uds/transports/X2GO/scripts/windows/direct.py +++ b/server/src/uds/transports/X2GO/scripts/windows/direct.py @@ -7,12 +7,12 @@ import os import subprocess from os.path import expanduser -from uds import tools # @UnresolvedImport +from uds import tools # type: ignore home = expanduser('~').replace('\\', '\\\\') + '#1;' -keyFile = tools.saveTempFile(sp['key']) +keyFile = tools.saveTempFile(sp['key']) # type: ignore # On windows, the separator beween active and not is "#" -theFile = sp['xf'].format(export='c:\\\\#1;', keyFile=keyFile.replace('\\', '/'), ip=sp['ip'], port=sp['port']) +theFile = sp['xf'].format(export='c:\\\\#1;', keyFile=keyFile.replace('\\', '/'), ip=sp['ip'], port=sp['port']) # type: ignore filename = tools.saveTempFile(theFile) x2goPath = os.environ['PROGRAMFILES(X86)'] + '\\x2goclient' diff --git a/server/src/uds/transports/X2GO/scripts/windows/direct.py.signature b/server/src/uds/transports/X2GO/scripts/windows/direct.py.signature index 5cece95b..79ae0b9c 100644 --- a/server/src/uds/transports/X2GO/scripts/windows/direct.py.signature +++ b/server/src/uds/transports/X2GO/scripts/windows/direct.py.signature @@ -1 +1 @@ -LuB4norDe9e4uHcdO158ENqlTNC9Wyp3xE7p/usaTGkJiQ8xgEbojPpXlJcbL9ovhRdcbkM499iJ8+tpd2XNNPkq3kEa3yy8ZbfKQWvcoDArJsi3MaWsTBfL48BpsPAwpgFgXwTNYLldWJ2uOp1RJijfNce1zD3NdC6JEWsewwoR0H+BjfHGHHvFtXSx5No35onSGS3g3Y1igmkg9/6GEqmANHCNyfegyFHIfaDJZwynm19Fk4A7ZQIY3PTq/kxWq5PXaVcHB6nC0UJBXHsEXePBFek9zaKViWiA5ZFlGYiaqKp1dj87QDEuwJ7GWrktDBRrbt8ZARAV/odhozx14V0Uxh6IiSvNUECb1pJ76H/Nqm1oQW3eRnWXZHjgN2rfsL9+988AZymJluC9acNcPHZw6TjaWksGrCu2qSIYAc62dxHSOJlov6/4/AqDPdmj2VSO8yRrmLkjhmlAZ1mcH29s8E1tw0HpBjPPiFRN+Hw4PCXdI3Qm5TkTbpWWYX14rm5u+KoNviUi1G0r9S0ZVM0e/xtUa9WKuOwUs81D3vHrAzgjHRGL7MaUWgXNHb1dB7SpogGsPmV05r4FMrZ9ip4qdVgM6391oETGzc+kWrWn6U8/Hm/N7aiUF19ipDN3U5ICiOMfeQqwb3oHJyvyoZUR2+x0q95FFND7O/gx0mg= \ No newline at end of file +HW48ZI/UF5SKfE5vTqyfKKOm2CZDoRVPyrJrmL2z6B9kuBQMB+o4T6RYsOPYMNQaII7ynG2YTSwfrFC3vQ5qNcWQtYbED0oRxGVW8Vl+sxFW3AvIcxhC3LMcO6+sRr5MUA5E8gGAq01AWbIE/lXBF8n/jovqT6sv1mApBQ3qlBwPq+YgqsvKdOXsNKWcZCc7Ig9xPGvVAQwSyiQCUUfyw2zk4l1LlAEklKpOcjy4c19dmO6wiU4ZWB3UZdMbu1vFRVMHTcKe5r/I0yUgB/2OcylniCvqM4+10OJAZKIEsK+mHz7+hF1rbBdey4qlXgUGtnCd5YLfctp6+lpsqr/awgl0h3BPRz+uPUMEQWqPxnqKMsP6sLrz4WJYnqP4yFnlUJKNqt1XZShMrzCz7VkT91RWHrIi7Mzz+QVlpC+PZS+0c2APiU1yfTPeXaaLKOQYjcKwHtFc4wZOJquwRbYFQbf/g/33zkRcmRQEueli6AHqKwxhpOPyuunNgY6itoS+PNIvyHK/xURrsao3kO7RhDavBOIiWiaIpvsaDCYPdpGTtgD/yVjlAMQnvQMqPUhg8Gxjxc5h3KaNNMJrLjFjXicY9Xh5P3sx0SgJKUxvg3UdYgyJHlNNLa5dJBQSEUfiP6zzX88w2h73rMP+BE6u1Yv0YsSY3967ctLMRO2/fWA= \ No newline at end of file diff --git a/server/src/uds/transports/X2GO/scripts/windows/tunnel.py b/server/src/uds/transports/X2GO/scripts/windows/tunnel.py index fd7260fc..8dc404b4 100644 --- a/server/src/uds/transports/X2GO/scripts/windows/tunnel.py +++ b/server/src/uds/transports/X2GO/scripts/windows/tunnel.py @@ -6,22 +6,22 @@ import os import subprocess -from uds.forward import forward # @UnresolvedImport +from uds.tunnel import forward # type: ignore from os.path import expanduser -from uds import tools # @UnresolvedImport +from uds import tools # type: ignore +# Open tunnel +fs = forward(remote=(sp['tunHost'], int(sp['tunPort'])), ticket=sp['ticket'], timeout=sp['tunWait'], check_certificate=sp['tunChk']) # type: ignore -forwardThread, port = forward(sp['tunHost'], sp['tunPort'], sp['tunUser'], sp['tunPass'], sp['ip'], sp['port']) +# Check that tunnel works.. +if fs.check() is False: + raise Exception('Could not connect to tunnel server.
Please, check your network settings.
') -if forwardThread.status == 2: - raise Exception('Unable to open tunnel') - -tools.addTaskToWait(forwardThread) -# Care, expanduser is encoding using "mcbs", so treat it as bytes always +# Care, expanduser is encoding using "mcbs", so treat it as bytes on python 2.7 home = expanduser('~').replace('\\', '\\\\') + '#1;' -keyFile = tools.saveTempFile(sp['key']) -theFile = sp['xf'].format(export=home, keyFile=keyFile.replace('\\', '/'), ip='127.0.0.1', port=port) +keyFile = tools.saveTempFile(sp['key']) # type: ignore +theFile = sp['xf'].format(export=home, keyFile=keyFile.replace('\\', '/'), ip='127.0.0.1', port=fs.server_address[1]) # type: ignore filename = tools.saveTempFile(theFile) x2goPath = os.environ['PROGRAMFILES(X86)'] + '\\x2goclient' diff --git a/server/src/uds/transports/X2GO/scripts/windows/tunnel.py.signature b/server/src/uds/transports/X2GO/scripts/windows/tunnel.py.signature index c5ce2bc7..094b302b 100644 --- a/server/src/uds/transports/X2GO/scripts/windows/tunnel.py.signature +++ b/server/src/uds/transports/X2GO/scripts/windows/tunnel.py.signature @@ -1 +1 @@ -pKLTspUmlmfjY7Ei6aiNFtCh+8mQ8TkZztS7D/kjGRj25FxmfG5Y0HMOdlu8kouiLTAwkzpyj+J+GjebWwcPCJv7hFJ8kWFJ7XaX8b3uX8BREq+G1p4UYSiZDM7qSaPviM9VFoTLNwRa+yBknbyosLBRCpesKSbaUlis9tsAHByU98peQ0QSOrrUvfFBIl5EUzx+frgKTS67tCNGJ+L4POOnOakKNoqDYiJ0z4/S4vMC2w/JQ1OxZPgXsyPRAwM7KqCOA5zhzB1Pjucoj9lfZvJz8T7DDpX05eN8dUU0dsgUZHKbm92Tn6MnMDpNbUH/CIIeQMfbBThTNlr2vvYYzdAjbpNlg4R4s10RCfIWb0Tqfvu9jRs/8dUOMkfOZSbv3DVukXIadQt1ednzbagBXoMPE3jiLe5OKQqAg4LFcU9vm1HJB/EIenpeCo/Oxmytb6VLatl5RF4COwC0WfFAZoku9qXW6BFzTWhGMGkzuXYS0C8rnDb1m53DBXNp3aPkVJ8ktoDCQ4fWbb9YDFZ2GNDVt5QppyizkblvbQoy4gVxPXlo+aPc9b92/hKmMha9RA1FByhDB7Lzx4a0iYZicv3LjX3N/VPvrTGpmfeiSDovqMWfBR9au3qneNmndxM4LnXL6wbyVyfeJey6XRIshRAE+gWlz9Ew1vzD0llnfN8= \ No newline at end of file +mYksg6meXqkKrrIES6xDkYeWsb78ejjJqA7EV7H3OgExs3gpxYr35fJR5IpVKrxUu1uT3mZK8PqmQ2ZA4beZkB+1IqdOZk5OWBpm4a1IGzU+KsPsCw+F1auvizJioZtM2JaG5FSSuskzu/Gflm1/akq3F4Ttkv0+Jt6daiEOnXioO0I+Jiv/fgaaI2DVDl2kc6bcPP+A/oS/cLO7RVrjLf+rcIeK1sUrhLhwhtD/8NyN/5nP5Xfq4jjNxEl2SFQZC3SUyXDfWY2LhbSt24O6rkYG9WkX/eNUwGK0ojdX4jdPlRq3gsu2rlkhIW91IBOztGoWZRWOi0vkqWODQdd7uTHA0Wrbi+5YZb07gv4K4r1TFPTEVWjEiY/xox3fZIJYhSIbGxFZXd9LlVOhpZ8Q2tEME/18rjDxuEsr5AdBihv9JEvsYIwfjHoOY9a5LK7FExnTWwEHlzscQ7f3sq9CihT3QnAwKBhqp2hQbZxT/28SAQF+0JAehWCSAi6hCk3ZYs3US5SmPcm32jwsHxh93Ae64Vfm1R/HA/QH9J1EEVA0pVS0H9H3mCAaPz2qq/oLLnXh5qbsbrXKFl/2pi3haYhGR0FSxbG625d7ZoAVTFrF8BMFErWerQjx9X9UDftbf5moBJZiTyk2cwnCnG4Q3DDddukudKiLwPzEnHaN1Zo= \ No newline at end of file diff --git a/server/src/uds/transports/X2GO/x2go_tunnel.py b/server/src/uds/transports/X2GO/x2go_tunnel.py index 86d12d7d..2ba654bf 100644 --- a/server/src/uds/transports/X2GO/x2go_tunnel.py +++ b/server/src/uds/transports/X2GO/x2go_tunnel.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- - # -# Copyright (c) 2016-2019 Virtual Cable S.L. +# Copyright (c) 2016-2021 Virtual Cable S.L.U. # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, @@ -60,12 +59,43 @@ class TX2GOTransport(BaseX2GOTransport): Provides access via X2GO to service. This transport can use an domain. If username processed by authenticator contains '@', it will split it and left-@-part will be username, and right password """ + typeName = _('X2Go') typeType = 'TX2GOTransport' typeDescription = _('X2Go access (Experimental). Tunneled connection.') group = transports.TUNNELED_GROUP - tunnelServer = gui.TextField(label=_('Tunnel server'), order=1, tooltip=_('IP or Hostname of tunnel server sent to client device ("public" ip) and port. (use HOST:PORT format)'), tab=gui.TUNNEL_TAB) + tunnelServer = gui.TextField( + label=_('Tunnel server'), + order=1, + tooltip=_( + 'IP or Hostname of tunnel server sent to client device ("public" ip) and port. (use HOST:PORT format)' + ), + tab=gui.TUNNEL_TAB, + ) + + tunnelWait = gui.NumericField( + length=3, + label=_('Tunnel wait time'), + defvalue='30', + minValue=5, + maxValue=65536, + order=2, + tooltip=_('Maximum time to wait before closing the tunnel listener'), + required=True, + tab=gui.TUNNEL_TAB, + ) + + verifyCertificate = gui.CheckBoxField( + label=_('Force SSL certificate verification'), + order=23, + tooltip=_( + 'If enabled, the certificate of tunnel server will be verified (recommended).' + ), + defvalue=gui.TRUE, + tab=gui.TUNNEL_TAB, + ) + fixedName = BaseX2GOTransport.fixedName screenSize = BaseX2GOTransport.screenSize @@ -83,18 +113,20 @@ class TX2GOTransport(BaseX2GOTransport): def initialize(self, values: 'Module.ValuesType'): if values: if values['tunnelServer'].count(':') != 1: - raise BaseX2GOTransport.ValidationException(_('Must use HOST:PORT in Tunnel Server Field')) + raise BaseX2GOTransport.ValidationException( + _('Must use HOST:PORT in Tunnel Server Field') + ) def getUDSTransportScript( # pylint: disable=too-many-locals - self, - userService: 'models.UserService', - transport: 'models.Transport', - ip: str, - os: typing.Dict[str, str], - user: 'models.User', - password: str, - request: 'HttpRequest' - ) -> typing.Tuple[str, str, typing.Dict[str, typing.Any]]: + self, + userService: 'models.UserService', + transport: 'models.Transport', + ip: str, + os: typing.Dict[str, str], + user: 'models.User', + password: str, + request: 'HttpRequest', + ) -> typing.Tuple[str, str, typing.Dict[str, typing.Any]]: ci = self.getConnectionInfo(userService, user, password) username = ci['username'] @@ -120,13 +152,16 @@ class TX2GOTransport(BaseX2GOTransport): rootless=rootless, width=width, height=height, - user=username + user=username, ) - tunpass = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits) for _i in range(12)) - tunuser = TicketStore.create(tunpass) + ticket = TicketStore.create_for_tunnel( + userService=userService, + port=22, + validity=self.tunnelWait.num() + 60, # Ticket overtime + ) - sshHost, sshPort = self.tunnelServer.value.split(':') + tunHost, tunPort = self.tunnelServer.value.split(':') # data data = { @@ -140,7 +175,7 @@ class TX2GOTransport(BaseX2GOTransport): 'drives': self.exports.isTrue(), 'fullScreen': width == -1 or height == -1, 'this_server': request.build_absolute_uri('/'), - 'xf': xf + 'xf': xf, } m = tools.DictAsObj(data) @@ -152,17 +187,18 @@ class TX2GOTransport(BaseX2GOTransport): }.get(os['OS']) if osName is None: - return super().getUDSTransportScript(userService, transport, ip, os, user, password, request) + return super().getUDSTransportScript( + userService, transport, ip, os, user, password, request + ) sp = { - 'tunUser': tunuser, - 'tunPass': tunpass, - 'tunHost': sshHost, - 'tunPort': sshPort, - 'ip': ip, - 'port': '22', + 'tunHost': tunHost, + 'tunPort': tunPort, + 'tunWait': self.tunnelWait.num(), + 'tunChk': self.verifyCertificate.isTrue(), + 'ticket': ticket, 'key': priv, - 'xf': xf + 'xf': xf, } return self.getScript('scripts/{}/tunnel.py', osName, sp) diff --git a/tunnel-server/src/forwarder/udstunnel.py b/tunnel-server/src/forwarder/udstunnel.py index 452bfb0b..d9b79c36 100644 --- a/tunnel-server/src/forwarder/udstunnel.py +++ b/tunnel-server/src/forwarder/udstunnel.py @@ -57,6 +57,7 @@ class ForwardServer(socketserver.ThreadingTCPServer): remote: typing.Tuple[str, int] ticket: str stop_flag: threading.Event + can_stop: bool timeout: int timer: typing.Optional[threading.Timer] check_certificate: bool @@ -79,20 +80,22 @@ class ForwardServer(socketserver.ThreadingTCPServer): ) self.remote = remote self.ticket = ticket - self.timeout = int(time.time()) + timeout if timeout else 0 + # Negative values for timeout, means "accept always connections" + # "but if no connection is stablished on timeout (positive)" + # "stop the listener" + self.timeout = int(time.time()) + timeout if timeout > 0 else 0 self.check_certificate = check_certificate self.stop_flag = threading.Event() # False initial self.current_connections = 0 self.status = TUNNEL_LISTENING + self.can_stop = False - if timeout: - self.timer = threading.Timer( - timeout, ForwardServer.__checkStarted, args=(self,) - ) - self.timer.start() - else: - self.timer = None + timeout = abs(timeout) or 60 + self.timer = threading.Timer( + abs(timeout), ForwardServer.__checkStarted, args=(self,) + ) + self.timer.start() def stop(self) -> None: if not self.stop_flag.is_set(): @@ -120,6 +123,9 @@ class ForwardServer(socketserver.ThreadingTCPServer): return context.wrap_socket(rsocket, server_hostname=self.remote[0]) def check(self) -> bool: + if self.status == TUNNEL_ERROR: + return False + try: with self.connect() as ssl_socket: ssl_socket.sendall(HANDSHAKE_V1 + b'TEST') @@ -135,11 +141,14 @@ class ForwardServer(socketserver.ThreadingTCPServer): @property def stoppable(self) -> bool: - return self.timeout != 0 and int(time.time()) > self.timeout + logger.debug('Is stoppable: %s', self.can_stop) + return self.can_stop or (self.timeout != 0 and int(time.time()) > self.timeout) @staticmethod def __checkStarted(fs: 'ForwardServer') -> None: + logger.debug('New connection limit reached') fs.timer = None + fs.can_stop = True if fs.current_connections <= 0: fs.stop() @@ -150,15 +159,17 @@ class Handler(socketserver.BaseRequestHandler): # server: ForwardServer def handle(self) -> None: - self.server.current_connections += 1 self.server.status = TUNNEL_OPENING # If server processing is over time if self.server.stoppable: - logger.info('Rejected timedout connection try') + self.server.status = TUNNEL_ERROR + logger.info('Rejected timedout connection') self.request.close() # End connection without processing it return + self.server.current_connections += 1 + # Open remote connection try: logger.debug('Ticket %s', self.server.ticket) @@ -169,7 +180,9 @@ class Handler(socketserver.BaseRequestHandler): data = ssl_socket.recv(2) if data != b'OK': data += ssl_socket.recv(128) - raise Exception(f'Error received: {data.decode(errors="ignore")}') # Notify error + raise Exception( + f'Error received: {data.decode(errors="ignore")}' + ) # Notify error # All is fine, now we can tunnel data self.process(remote=ssl_socket) @@ -251,15 +264,12 @@ if __name__ == "__main__": handler.setFormatter(formatter) log.addHandler(handler) - ticket = 'qcdn2jax6tx4nljdyed61hm3iqbld5nf44zxbh9gf355ofw2' + ticket = 'mffqg7q4s61fvx0ck2pe0zke6k0c5ipb34clhbkbs4dasb4g' fs = forward( ('172.27.0.1', 7777), ticket, local_port=49999, - timeout=60, + timeout=-20, check_certificate=False, ) - - print(fs.check()) - fs.stop() From d8fb0deef20410ea201f555c0b9e13ca61aef134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?=