1
0
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:
Adolfo Gómez García 2016-04-28 08:34:47 +02:00
parent 2021fd69ec
commit 0fb7d5ed1b
5 changed files with 35 additions and 17 deletions

View File

@ -73,6 +73,7 @@ class Handler(SocketServer.BaseRequestHandler):
class ForwardThread(threading.Thread):
status = 0 # Connecting
clientUseCounter = 0
def __init__(self, server, port, username, password, localPort, redirectHost, redirectPort, waitTime):
threading.Thread.__init__(self)
@ -95,6 +96,21 @@ class ForwardThread(threading.Thread):
self.timer = None
self.currentConnections = 0
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):
self.timer = None
@ -104,6 +120,7 @@ class ForwardThread(threading.Thread):
self.stop()
def run(self):
if self.client is None:
self.client = paramiko.SSHClient()
self.client.load_system_host_keys()
self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
@ -130,6 +147,8 @@ class ForwardThread(threading.Thread):
self.status = 1 # Ok, listening
ForwardThread.clientUseCounter += 1
self.fs = ForwardServer(('', self.localPort), SubHandler)
self.fs.serve_forever()
@ -142,6 +161,8 @@ class ForwardThread(threading.Thread):
self.fs.shutdown()
if self.client is not None:
ForwardThread.clientUseCounter -= 1
if ForwardThread.clientUseCounter == 0:
self.client.close()
except Exception:
logger.exception('Exception stopping')

View File

@ -264,7 +264,7 @@ class ServicesPools(ModelHandler):
fields['servicesPoolGroup_id'] = None
logger.debug('servicesPoolGroup_id: {}'.format(spgrpId))
try:
if imgId != '-1':
if spgrpId != '-1':
spgrp = ServicesPoolGroup.objects.get(uuid=processUuid(spgrpId))
fields['servicesPoolGroup_id'] = spgrp.id
except Exception:

View File

@ -39,9 +39,6 @@ gui.servicesPools.fastLink = (event, obj) ->
$(".lnk-calendars").click();
, 50)
gui.servicesPools.link = (event) ->
"use strict"
gui.clearWorkspace()

View File

@ -1,7 +1,7 @@
{% load i18n html5 static %}
{% preferences_allowed as show_prefs %}
{% root_id as rootid %}
<div class="ui inverted menu doubling grid">
<div class="ui menu doubling grid">
<a class="header item" href="/">
<img class="ui mini spaced image" src="{% get_static_prefix %}img/udsicon.png">Universal Desktop Services
</a>

View File

@ -38,7 +38,7 @@ else:
port = -1
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:
raise Exception('Unable to open tunnel')