mirror of
https://github.com/dkmstr/openuds.git
synced 2025-01-03 01:17:56 +03:00
* Fixed service pool group setup bug
* Fix to allow some kind of connections to (as spice), to open two different tunnels (We have to test the fix)
This commit is contained in:
parent
2021fd69ec
commit
0fb7d5ed1b
@ -73,6 +73,7 @@ class Handler(SocketServer.BaseRequestHandler):
|
|||||||
|
|
||||||
class ForwardThread(threading.Thread):
|
class ForwardThread(threading.Thread):
|
||||||
status = 0 # Connecting
|
status = 0 # Connecting
|
||||||
|
clientUseCounter = 0
|
||||||
|
|
||||||
def __init__(self, server, port, username, password, localPort, redirectHost, redirectPort, waitTime):
|
def __init__(self, server, port, username, password, localPort, redirectHost, redirectPort, waitTime):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
@ -95,6 +96,21 @@ class ForwardThread(threading.Thread):
|
|||||||
self.timer = None
|
self.timer = None
|
||||||
self.currentConnections = 0
|
self.currentConnections = 0
|
||||||
self.stoppable = False
|
self.stoppable = False
|
||||||
|
self.client = None
|
||||||
|
|
||||||
|
def clone(self, redirectHost, redirectPort, localPort=None):
|
||||||
|
if localPort is None:
|
||||||
|
localPort = random.randrange(40000, 50000)
|
||||||
|
|
||||||
|
ft = ForwardThread(self.server, self.port, self.username, self.password, localPort, redirectHost, redirectPort. self.waitTime)
|
||||||
|
ft.client = self.client
|
||||||
|
ft.start()
|
||||||
|
|
||||||
|
while ft.status == 0:
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
return ft
|
||||||
|
|
||||||
|
|
||||||
def _timerFnc(self):
|
def _timerFnc(self):
|
||||||
self.timer = None
|
self.timer = None
|
||||||
@ -104,18 +120,19 @@ class ForwardThread(threading.Thread):
|
|||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.client = paramiko.SSHClient()
|
if self.client is None:
|
||||||
self.client.load_system_host_keys()
|
self.client = paramiko.SSHClient()
|
||||||
self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
self.client.load_system_host_keys()
|
||||||
|
self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||||
|
|
||||||
logger.debug('Connecting to ssh host %s:%d ...' % (self.server, self.port))
|
logger.debug('Connecting to ssh host %s:%d ...' % (self.server, self.port))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.client.connect(self.server, self.port, username=self.username, password=self.password, timeout=5)
|
self.client.connect(self.server, self.port, username=self.username, password=self.password, timeout=5)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception('Exception connecting: ')
|
logger.exception('Exception connecting: ')
|
||||||
self.status = 2 # Error
|
self.status = 2 # Error
|
||||||
return
|
return
|
||||||
|
|
||||||
class SubHandler(Handler):
|
class SubHandler(Handler):
|
||||||
chain_host = self.redirectHost
|
chain_host = self.redirectHost
|
||||||
@ -130,6 +147,8 @@ class ForwardThread(threading.Thread):
|
|||||||
|
|
||||||
self.status = 1 # Ok, listening
|
self.status = 1 # Ok, listening
|
||||||
|
|
||||||
|
ForwardThread.clientUseCounter += 1
|
||||||
|
|
||||||
self.fs = ForwardServer(('', self.localPort), SubHandler)
|
self.fs = ForwardServer(('', self.localPort), SubHandler)
|
||||||
self.fs.serve_forever()
|
self.fs.serve_forever()
|
||||||
|
|
||||||
@ -142,7 +161,9 @@ class ForwardThread(threading.Thread):
|
|||||||
self.fs.shutdown()
|
self.fs.shutdown()
|
||||||
|
|
||||||
if self.client is not None:
|
if self.client is not None:
|
||||||
self.client.close()
|
ForwardThread.clientUseCounter -= 1
|
||||||
|
if ForwardThread.clientUseCounter == 0:
|
||||||
|
self.client.close()
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception('Exception stopping')
|
logger.exception('Exception stopping')
|
||||||
pass
|
pass
|
||||||
|
@ -264,7 +264,7 @@ class ServicesPools(ModelHandler):
|
|||||||
fields['servicesPoolGroup_id'] = None
|
fields['servicesPoolGroup_id'] = None
|
||||||
logger.debug('servicesPoolGroup_id: {}'.format(spgrpId))
|
logger.debug('servicesPoolGroup_id: {}'.format(spgrpId))
|
||||||
try:
|
try:
|
||||||
if imgId != '-1':
|
if spgrpId != '-1':
|
||||||
spgrp = ServicesPoolGroup.objects.get(uuid=processUuid(spgrpId))
|
spgrp = ServicesPoolGroup.objects.get(uuid=processUuid(spgrpId))
|
||||||
fields['servicesPoolGroup_id'] = spgrp.id
|
fields['servicesPoolGroup_id'] = spgrp.id
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -39,9 +39,6 @@ gui.servicesPools.fastLink = (event, obj) ->
|
|||||||
$(".lnk-calendars").click();
|
$(".lnk-calendars").click();
|
||||||
, 50)
|
, 50)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
gui.servicesPools.link = (event) ->
|
gui.servicesPools.link = (event) ->
|
||||||
"use strict"
|
"use strict"
|
||||||
gui.clearWorkspace()
|
gui.clearWorkspace()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{% load i18n html5 static %}
|
{% load i18n html5 static %}
|
||||||
{% preferences_allowed as show_prefs %}
|
{% preferences_allowed as show_prefs %}
|
||||||
{% root_id as rootid %}
|
{% root_id as rootid %}
|
||||||
<div class="ui inverted menu doubling grid">
|
<div class="ui menu doubling grid">
|
||||||
<a class="header item" href="/">
|
<a class="header item" href="/">
|
||||||
<img class="ui mini spaced image" src="{% get_static_prefix %}img/udsicon.png">Universal Desktop Services
|
<img class="ui mini spaced image" src="{% get_static_prefix %}img/udsicon.png">Universal Desktop Services
|
||||||
</a>
|
</a>
|
||||||
|
@ -38,7 +38,7 @@ else:
|
|||||||
port = -1
|
port = -1
|
||||||
|
|
||||||
if {m.secure_port} != -1: # @UndefinedVariable
|
if {m.secure_port} != -1: # @UndefinedVariable
|
||||||
forwardThread2, secure_port = forward('{m.tunHost}', '{m.tunPort}', '{m.tunUser}', '{m.tunPass}', '{m.ip}', {m.secure_port}) # @UndefinedVariable
|
forwardThread2, secure_port = forwardThread1.clone('{m.ip}', {m.secure_port}) # @UndefinedVariable
|
||||||
|
|
||||||
if forwardThread2.status == 2:
|
if forwardThread2.status == 2:
|
||||||
raise Exception('Unable to open tunnel')
|
raise Exception('Unable to open tunnel')
|
||||||
|
Loading…
Reference in New Issue
Block a user