diff --git a/client/src/uds/forward.py b/client/src/uds/forward.py index fcf4b17bf..98757f81d 100644 --- a/client/src/uds/forward.py +++ b/client/src/uds/forward.py @@ -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,18 +120,19 @@ class ForwardThread(threading.Thread): self.stop() def run(self): - self.client = paramiko.SSHClient() - self.client.load_system_host_keys() - self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + if self.client is None: + self.client = paramiko.SSHClient() + 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: - self.client.connect(self.server, self.port, username=self.username, password=self.password, timeout=5) - except Exception as e: - logger.exception('Exception connecting: ') - self.status = 2 # Error - return + try: + self.client.connect(self.server, self.port, username=self.username, password=self.password, timeout=5) + except Exception as e: + logger.exception('Exception connecting: ') + self.status = 2 # Error + return class SubHandler(Handler): chain_host = self.redirectHost @@ -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,7 +161,9 @@ class ForwardThread(threading.Thread): self.fs.shutdown() if self.client is not None: - self.client.close() + ForwardThread.clientUseCounter -= 1 + if ForwardThread.clientUseCounter == 0: + self.client.close() except Exception: logger.exception('Exception stopping') pass diff --git a/server/src/uds/REST/methods/services_pools.py b/server/src/uds/REST/methods/services_pools.py index 1e0af5de8..4bf7d109f 100644 --- a/server/src/uds/REST/methods/services_pools.py +++ b/server/src/uds/REST/methods/services_pools.py @@ -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: diff --git a/server/src/uds/static/adm/js/gui-d-servicespools.coffee b/server/src/uds/static/adm/js/gui-d-servicespools.coffee index abbca1394..280bc1909 100644 --- a/server/src/uds/static/adm/js/gui-d-servicespools.coffee +++ b/server/src/uds/static/adm/js/gui-d-servicespools.coffee @@ -39,9 +39,6 @@ gui.servicesPools.fastLink = (event, obj) -> $(".lnk-calendars").click(); , 50) - - - gui.servicesPools.link = (event) -> "use strict" gui.clearWorkspace() diff --git a/server/src/uds/templates/uds/semantic/snippets/navbar.html b/server/src/uds/templates/uds/semantic/snippets/navbar.html index 0c3f84567..b39f8fadf 100644 --- a/server/src/uds/templates/uds/semantic/snippets/navbar.html +++ b/server/src/uds/templates/uds/semantic/snippets/navbar.html @@ -1,7 +1,7 @@ {% load i18n html5 static %} {% preferences_allowed as show_prefs %} {% root_id as rootid %} -