forked from shaba/openuds
Fixing up a bit transports
This commit is contained in:
parent
903664b7c5
commit
7c916397e4
@ -62,10 +62,13 @@ class Transport(Module):
|
||||
# Linux
|
||||
supportedOss = OsDetector.desktopOss # Supported operating systems
|
||||
|
||||
# If this transport is visible via Web, via Thick Client or both
|
||||
# If this transport is visible via Web, via Thin Client or both
|
||||
webTransport = False
|
||||
tcTransport = False
|
||||
|
||||
# Protocol "type". This is not mandatory, but will help
|
||||
protocol = protocols.NONE
|
||||
|
||||
def __init__(self, environment, values):
|
||||
super(Transport, self).__init__(environment, values)
|
||||
self.initialize(values)
|
||||
@ -139,7 +142,7 @@ class Transport(Module):
|
||||
DeployedService or UserService. In case of processUserPassword for an DeployedService, no transformation
|
||||
is done, because there is no relation at that level between user and service.
|
||||
'''
|
||||
return {'protocol': protocols.NONE, 'username': '', 'password': '', 'domain': ''}
|
||||
return {'protocol': self.protocol, 'username': '', 'password': '', 'domain': ''}
|
||||
|
||||
def preAccessScript(self, userService, user):
|
||||
'''
|
||||
@ -149,7 +152,6 @@ class Transport(Module):
|
||||
'''
|
||||
return None
|
||||
|
||||
|
||||
def renderForHtml(self, userService, idUserService, idTransport, ip, os, user, password):
|
||||
'''
|
||||
Requests the html rendering of connector for the destination ip, (dbUser) and password
|
||||
|
@ -43,4 +43,5 @@ HDX = 'hdx'
|
||||
ICA = 'ica'
|
||||
NX = 'nx'
|
||||
X11 = 'x11'
|
||||
X2GO = 'x2go'
|
||||
OTHER = 'other'
|
||||
|
@ -38,6 +38,7 @@ from uds.core.ui.UserInterface import gui
|
||||
from uds.core.util.Cache import Cache
|
||||
from uds.core.util import net
|
||||
from uds.core.transports.BaseTransport import Transport
|
||||
from uds.core.transports import protocols
|
||||
from uds.core.util import connection
|
||||
from uds.core.util import OsDetector
|
||||
|
||||
@ -47,6 +48,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
READY_CACHE_TIMEOUT = 30
|
||||
|
||||
|
||||
class HTML5RDPTransport(Transport):
|
||||
'''
|
||||
Provides access via RDP to service.
|
||||
@ -58,6 +60,7 @@ class HTML5RDPTransport(Transport):
|
||||
iconFile = 'rdp.png'
|
||||
needsJava = False # If this transport needs java for rendering
|
||||
supportedOss = OsDetector.allOss
|
||||
protocol = protocols.RDP
|
||||
|
||||
guacamoleServer = gui.TextField(label=_('Tunnel Server'), order=1, tooltip=_('Host of the tunnel server (use http/https & port if needed) as accesible from users'), defvalue='https://', length=64, required=True)
|
||||
useEmptyCreds = gui.CheckBoxField(label=_('Empty creds'), order=2, tooltip=_('If checked, the credentials used to connect will be emtpy'))
|
||||
|
@ -4,27 +4,27 @@
|
||||
# Copyright (c) 2012 Virtual Cable S.L.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
@ -37,6 +37,7 @@ from django.utils.translation import ugettext_noop as _
|
||||
from uds.core.managers.UserPrefsManager import CommonPrefs
|
||||
from uds.core.ui.UserInterface import gui
|
||||
from uds.core.transports.BaseTransport import Transport
|
||||
from uds.core.transports import protocols
|
||||
from uds.core.util import connection
|
||||
from web import generateHtmlForNX, getHtmlComponent
|
||||
|
||||
@ -46,6 +47,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
READY_CACHE_TIMEOUT = 30
|
||||
|
||||
|
||||
class NXTransport(Transport):
|
||||
'''
|
||||
Provides access via RDP to service.
|
||||
@ -54,44 +56,45 @@ class NXTransport(Transport):
|
||||
typeName = _('NX Transport (direct)')
|
||||
typeType = 'NXTransport'
|
||||
typeDescription = _('NX Transport for direct connection')
|
||||
iconFile = 'nx.png'
|
||||
iconFile = 'nx.png'
|
||||
needsJava = True # If this transport needs java for rendering
|
||||
protocol = protocols.NX
|
||||
|
||||
useEmptyCreds = gui.CheckBoxField(label = _('Empty creds'), order = 1, tooltip = _('If checked, the credentials used to connect will be emtpy'))
|
||||
fixedName = gui.TextField(label=_('Username'), order = 2, tooltip = _('If not empty, this username will be always used as credential'))
|
||||
fixedPassword = gui.PasswordField(label=_('Password'), order = 3, tooltip = _('If not empty, this password will be always used as credential'))
|
||||
listenPort = gui.NumericField(label=_('Listen port'), length = 5, order = 4, tooltip = _('Listening port of NX (ssh) at client machine'), defvalue = '22')
|
||||
connection = gui.ChoiceField(label=_('Connection'), order = 6, tooltip = _('Connection speed for this transport (quality)'), values = [
|
||||
useEmptyCreds = gui.CheckBoxField(label=_('Empty creds'), order=1, tooltip=_('If checked, the credentials used to connect will be emtpy'))
|
||||
fixedName = gui.TextField(label=_('Username'), order=2, tooltip=_('If not empty, this username will be always used as credential'))
|
||||
fixedPassword = gui.PasswordField(label=_('Password'), order=3, tooltip=_('If not empty, this password will be always used as credential'))
|
||||
listenPort = gui.NumericField(label=_('Listen port'), length=5, order=4, tooltip=_('Listening port of NX (ssh) at client machine'), defvalue='22')
|
||||
connection = gui.ChoiceField(label=_('Connection'), order=6, tooltip=_('Connection speed for this transport (quality)'), values=[
|
||||
{'id' : 'modem', 'text' : 'modem'},
|
||||
{'id' : 'isdn', 'text' : 'isdn'},
|
||||
{'id' : 'adsl', 'text' : 'adsl'},
|
||||
{'id' : 'wan', 'text' : 'wan'},
|
||||
{'id' : 'lan', 'text' : 'lan'},
|
||||
] )
|
||||
session = gui.ChoiceField(label=_('Session'), order = 7, tooltip = _('Desktop session'), values = [
|
||||
])
|
||||
session = gui.ChoiceField(label=_('Session'), order=7, tooltip=_('Desktop session'), values=[
|
||||
{'id' : 'gnome', 'text' : 'gnome'},
|
||||
{'id' : 'kde', 'text' : 'kde'},
|
||||
{'id' : 'cde', 'text' : 'cde'},
|
||||
] )
|
||||
cacheDisk = gui.ChoiceField(label=_('Disk Cache'), order = 8, tooltip = _('Cache size en Mb stored at disk'), values = [
|
||||
])
|
||||
cacheDisk = gui.ChoiceField(label=_('Disk Cache'), order=8, tooltip=_('Cache size en Mb stored at disk'), values=[
|
||||
{'id' : '0', 'text' : '0 Mb'},
|
||||
{'id' : '32', 'text' : '32 Mb'},
|
||||
{'id' : '64', 'text' : '64 Mb'},
|
||||
{'id' : '128', 'text' : '128 Mb'},
|
||||
{'id' : '256', 'text' : '256 Mb'},
|
||||
{'id' : '512', 'text' : '512 Mb'},
|
||||
] )
|
||||
cacheMem = gui.ChoiceField(label=_('Memory Cache'), order = 9, tooltip = _('Cache size en Mb keept at memory'), values = [
|
||||
])
|
||||
cacheMem = gui.ChoiceField(label=_('Memory Cache'), order=9, tooltip=_('Cache size en Mb keept at memory'), values=[
|
||||
{'id' : '4', 'text' : '4 Mb'},
|
||||
{'id' : '8', 'text' : '8 Mb'},
|
||||
{'id' : '16', 'text' : '16 Mb'},
|
||||
{'id' : '32', 'text' : '32 Mb'},
|
||||
{'id' : '64', 'text' : '64 Mb'},
|
||||
{'id' : '128', 'text' : '128 Mb'},
|
||||
] )
|
||||
|
||||
|
||||
def __init__(self, environment, values = None):
|
||||
])
|
||||
|
||||
|
||||
def __init__(self, environment, values=None):
|
||||
super(NXTransport, self).__init__(environment, values)
|
||||
if values != None:
|
||||
self._useEmptyCreds = gui.strToBool(values['useEmptyCreds'])
|
||||
@ -111,23 +114,23 @@ class NXTransport(Transport):
|
||||
self._session = ''
|
||||
self._cacheDisk = ''
|
||||
self._cacheMem = ''
|
||||
|
||||
|
||||
def marshal(self):
|
||||
'''
|
||||
Serializes the transport data so we can store it in database
|
||||
'''
|
||||
return str.join( '\t', [ 'v1', gui.boolToStr(self._useEmptyCreds), self._fixedName, self._fixedPassword, self._listenPort,
|
||||
self._connection, self._session, self._cacheDisk, self._cacheMem ] )
|
||||
|
||||
return str.join('\t', [ 'v1', gui.boolToStr(self._useEmptyCreds), self._fixedName, self._fixedPassword, self._listenPort,
|
||||
self._connection, self._session, self._cacheDisk, self._cacheMem ])
|
||||
|
||||
def unmarshal(self, string):
|
||||
data = string.split('\t')
|
||||
if data[0] == 'v1':
|
||||
self._useEmptyCreds = gui.strToBool(data[1])
|
||||
self._fixedName, self._fixedPassword, self._listenPort, self._connection, self._session, self._cacheDisk, self._cacheMem = data[2:]
|
||||
|
||||
|
||||
|
||||
|
||||
def valuesDict(self):
|
||||
return { 'useEmptyCreds' : gui.boolToStr(self._useEmptyCreds), 'fixedName' : self._fixedName,
|
||||
return { 'useEmptyCreds' : gui.boolToStr(self._useEmptyCreds), 'fixedName' : self._fixedName,
|
||||
'fixedPassword' : self._fixedPassword, 'listenPort': self._listenPort,
|
||||
'connection' : self._connection, 'session' : self._session, 'cacheDisk' : self._cacheDisk,
|
||||
'cacheMem' : self._cacheMem }
|
||||
@ -147,11 +150,11 @@ class NXTransport(Transport):
|
||||
else:
|
||||
self.cache().put(ip, 'N', READY_CACHE_TIMEOUT)
|
||||
return ready == 'Y'
|
||||
|
||||
|
||||
def renderForHtml(self, userService, idUserService, idTransport, ip, os, user, password):
|
||||
|
||||
|
||||
prefs = user.prefs('nx')
|
||||
|
||||
|
||||
username = user.getUsernameForAuth()
|
||||
proc = username.split('@')
|
||||
username = proc[0]
|
||||
@ -160,24 +163,23 @@ class NXTransport(Transport):
|
||||
if self._fixedPassword is not '':
|
||||
password = self._fixedPassword
|
||||
if self._useEmptyCreds is True:
|
||||
username, password = '',''
|
||||
|
||||
username, password = '', ''
|
||||
|
||||
# We have the credentials right now, let os manager
|
||||
|
||||
|
||||
width, height = CommonPrefs.getWidthHeight(prefs)
|
||||
|
||||
|
||||
# Extra data
|
||||
extra = { 'width': width, 'height' : height,
|
||||
'port' : self._listenPort, 'connection' : self._connection,
|
||||
'session' : self._session, 'cacheDisk': self._cacheDisk,
|
||||
'cacheMem' : self._cacheMem }
|
||||
|
||||
|
||||
# Fix username/password acording to os manager
|
||||
username, password = userService.processUserPassword(username, password)
|
||||
|
||||
|
||||
return generateHtmlForNX(self, idUserService, idTransport, ip, os, username, password, extra)
|
||||
|
||||
|
||||
def getHtmlComponent(self, theId, os, componentId):
|
||||
# We use helper to keep this clean
|
||||
return getHtmlComponent(self.__module__, componentId)
|
||||
|
@ -37,6 +37,7 @@ from django.utils.translation import ugettext_noop as _
|
||||
from uds.core.managers.UserPrefsManager import CommonPrefs
|
||||
from uds.core.ui.UserInterface import gui
|
||||
from uds.core.transports.BaseTransport import Transport
|
||||
from uds.core.transports import protocols
|
||||
from uds.core.util.Cache import Cache
|
||||
from uds.core.util import connection
|
||||
from web import generateHtmlForNX, getHtmlComponent
|
||||
@ -53,8 +54,7 @@ READY_CACHE_TIMEOUT = 30
|
||||
|
||||
class TSNXTransport(Transport):
|
||||
'''
|
||||
Provides access via RDP 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
|
||||
Provides access via NX to service. using tunnel
|
||||
'''
|
||||
typeName = _('NX Transport (tunneled)')
|
||||
typeType = 'TSNXTransport'
|
||||
@ -62,6 +62,7 @@ class TSNXTransport(Transport):
|
||||
iconFile = 'nx.png'
|
||||
needsJava = True # If this transport needs java for rendering
|
||||
supportedOss = ['Windows', 'Macintosh', 'Linux']
|
||||
protocol = protocols.NX
|
||||
|
||||
tunnelServer = gui.TextField(label=_('Tunnel server'), order=1, tooltip=_('IP or Hostname of tunnel server send to client device ("public" ip) and port. (use HOST:PORT format)'))
|
||||
tunnelCheckServer = gui.TextField(label=_('Tunnel host check'), order=2, tooltip=_('If not empty, this server will be used to check if service is running before assigning it to user. (use HOST:PORT format)'))
|
||||
|
@ -4,27 +4,27 @@
|
||||
# Copyright (c) 2012 Virtual Cable S.L.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
'''
|
||||
@ -48,20 +48,19 @@ def simpleScrambler(data):
|
||||
n = ord('M')
|
||||
pos = 0
|
||||
for c in data:
|
||||
res.append( chr(ord(c) ^ n) )
|
||||
res.append(chr(ord(c) ^ n))
|
||||
n = n ^ pos
|
||||
pos = pos + 1
|
||||
return "".join(res).encode('hex')
|
||||
|
||||
|
||||
|
||||
def generateHtmlForNX(transport, idUserService, idTransport, ip, os, user, password, extra):
|
||||
isMac = os['OS'] == OsDetector.Macintosh
|
||||
applet = reverse('uds.web.views.transcomp', kwargs = { 'idTransport' : idTransport, 'componentId' : '1' })
|
||||
applet = reverse('uds.web.views.transcomp', kwargs={ 'idTransport' : idTransport, 'componentId' : '1' })
|
||||
# Gets the codebase, simply remove last char from applet
|
||||
codebase = applet[:-1]
|
||||
# We generate the "data" parameter
|
||||
data = simpleScrambler( '\t'.join([
|
||||
data = simpleScrambler('\t'.join([
|
||||
'user:' + user,
|
||||
'pass:' + password,
|
||||
'ip:' + ip,
|
||||
@ -73,27 +72,29 @@ def generateHtmlForNX(transport, idUserService, idTransport, ip, os, user, passw
|
||||
'width:' + str(extra['width']),
|
||||
'height:' + str(extra['height']),
|
||||
'is:' + idUserService
|
||||
]))
|
||||
]
|
||||
))
|
||||
if isMac is True:
|
||||
msg = '<p>' + _('In order to use this transport, you need to install first OpenNX Client for mac') + '</p>'
|
||||
msg += '<p>' + _('You can oibtain it from ') + '<a href="{0}">'.format(Config.section('NX').value('downloadUrlMACOS').get()) + _('OpenNx Website') + '</a></p>'
|
||||
else:
|
||||
msg = '<p>' + _('In order to use this transport, you need to install first Nomachine Nx Client version 3.5.x') + '</p>'
|
||||
msg +='<p>' + _('you can obtain it for your platform from') + '<a href="{0}">'.format(Config.section('NX').value('downloadUrl').get()) + _('nochamine web site') + '</a></p>'
|
||||
res = '<div idTransport="applet"><applet code="NxTransportApplet.class" codebase="%s" archive="%s" width="140" height="22"><param name="data" value="%s"/><param name="permissions" value="all-permissions"/></applet></div>' % (codebase, '1', data )
|
||||
msg += '<p>' + _('you can obtain it for your platform from') + '<a href="{0}">'.format(Config.section('NX').value('downloadUrl').get()) + _('nochamine web site') + '</a></p>'
|
||||
res = '<div idTransport="applet"><applet code="NxTransportApplet.class" codebase="%s" archive="%s" width="140" height="22"><param name="data" value="%s"/><param name="permissions" value="all-permissions"/></applet></div>' % (codebase, '1', data)
|
||||
res += '<div>' + msg + '</div>'
|
||||
return res
|
||||
|
||||
|
||||
|
||||
def getHtmlComponent(module, componentId):
|
||||
dict = { '1' : ['nxtransport.jar', 'application/java-archive' ]}
|
||||
|
||||
if dict.has_key(componentId) == False:
|
||||
comps = {
|
||||
'1': ['nxtransport.jar', 'application/java-archive']
|
||||
}
|
||||
|
||||
if componentId not in comps:
|
||||
return ['text/plain', 'no component']
|
||||
fname = os.path.dirname(sys.modules[module].__file__) + '/applet/' + dict[componentId][0]
|
||||
fname = os.path.dirname(sys.modules[module].__file__) + '/applet/' + comps[componentId][0]
|
||||
logger.debug('Loading component {0} from {1}'.format(componentId, fname))
|
||||
|
||||
f = open(fname, 'rb')
|
||||
data = f.read()
|
||||
f.close()
|
||||
return [ dict[componentId][1], data ]
|
||||
with open(fname, 'rb') as f:
|
||||
data = f.read()
|
||||
return [comps[componentId][1], data]
|
||||
|
@ -35,6 +35,7 @@ from django.utils.translation import ugettext_noop as _
|
||||
from uds.core.managers.UserPrefsManager import CommonPrefs
|
||||
from uds.core.ui.UserInterface import gui
|
||||
from uds.core.transports.BaseTransport import Transport
|
||||
from uds.core.transports import protocols
|
||||
from uds.core.util import connection
|
||||
from web import generateHtmlForRdp, getHtmlComponent
|
||||
|
||||
@ -44,6 +45,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
READY_CACHE_TIMEOUT = 30
|
||||
|
||||
|
||||
class RDPTransport(Transport):
|
||||
'''
|
||||
Provides access via RDP to service.
|
||||
@ -54,6 +56,7 @@ class RDPTransport(Transport):
|
||||
typeDescription = _('RDP Transport for direct connection')
|
||||
iconFile = 'rdp.png'
|
||||
needsJava = True # If this transport needs java for rendering
|
||||
protocol = protocols.RDP
|
||||
|
||||
useEmptyCreds = gui.CheckBoxField(label=_('Empty creds'), order=1, tooltip=_('If checked, the credentials used to connect will be emtpy'))
|
||||
fixedName = gui.TextField(label=_('Username'), order=2, tooltip=_('If not empty, this username will be always used as credential'))
|
||||
|
@ -35,6 +35,7 @@ from django.utils.translation import ugettext_noop as _
|
||||
from uds.core.managers.UserPrefsManager import CommonPrefs
|
||||
from uds.core.ui.UserInterface import gui
|
||||
from uds.core.transports.BaseTransport import Transport
|
||||
from uds.core.transports import protocols
|
||||
from uds.core.util import connection
|
||||
from uds.core.util.Cache import Cache
|
||||
from web import generateHtmlForRdp, getHtmlComponent
|
||||
@ -59,6 +60,7 @@ class TSRDPTransport(Transport):
|
||||
typeDescription = _('RDP Transport for tunneled connection')
|
||||
iconFile = 'rdp.png'
|
||||
needsJava = True # If this transport needs java for rendering
|
||||
protocol = protocols.RDP
|
||||
|
||||
tunnelServer = gui.TextField(label=_('Tunnel server'), order=1, tooltip=_('IP or Hostname of tunnel server send to client device ("public" ip) and port. (use HOST:PORT format)'))
|
||||
tunnelCheckServer = gui.TextField(label=_('Tunnel host check'), order=2, tooltip=_('If not empty, this server will be used to check if service is running before assigning it to user. (use HOST:PORT format)'))
|
||||
|
@ -51,35 +51,35 @@ def scramble(data):
|
||||
return "".join(res).encode('hex')
|
||||
|
||||
|
||||
|
||||
def generateHtmlForRdp(transport, idUserService, idTransport, os, ip, port, user, password, domain, extra):
|
||||
isMac = os['OS'] == OsDetector.Macintosh
|
||||
applet = reverse('uds.web.views.transcomp', kwargs={ 'idTransport' : idTransport, 'componentId' : '1' })
|
||||
applet = reverse('uds.web.views.transcomp', kwargs={'idTransport': idTransport, 'componentId': '1'})
|
||||
logger.debug('Applet: {0}'.format(applet))
|
||||
# Gets the codebase, simply remove last char from applet
|
||||
codebase = applet[:-1]
|
||||
# We generate the "data" parameter
|
||||
data = [ 'u:' + user,
|
||||
'p:' + password,
|
||||
'd:' + domain,
|
||||
's:' + ip,
|
||||
'po:' + port,
|
||||
'sc:' + (extra['smartcards'] and '1' or '0'),
|
||||
'pr:' + (extra['printers'] and '1' or '0'),
|
||||
'se:' + (extra['serials'] and '1' or '0'),
|
||||
'dr:' + (extra['drives'] and '1' or '0'),
|
||||
'au:' + '1', # Audio, 0 do not play, 1 play
|
||||
'w:' + str(extra['width']),
|
||||
'h:' + str(extra['height']),
|
||||
'c:' + str(extra['depth']),
|
||||
'cr:' + (extra['compression'] and '1' or '0'),
|
||||
'is:' + idUserService,
|
||||
'sw:' + (extra['wallpaper'] and '1' or '0'),
|
||||
]
|
||||
data = [
|
||||
'u:' + user,
|
||||
'p:' + password,
|
||||
'd:' + domain,
|
||||
's:' + ip,
|
||||
'po:' + port,
|
||||
'sc:' + (extra['smartcards'] and '1' or '0'),
|
||||
'pr:' + (extra['printers'] and '1' or '0'),
|
||||
'se:' + (extra['serials'] and '1' or '0'),
|
||||
'dr:' + (extra['drives'] and '1' or '0'),
|
||||
'au:' + '1', # Audio, 0 do not play, 1 play
|
||||
'w:' + str(extra['width']),
|
||||
'h:' + str(extra['height']),
|
||||
'c:' + str(extra['depth']),
|
||||
'cr:' + (extra['compression'] and '1' or '0'),
|
||||
'is:' + idUserService,
|
||||
'sw:' + (extra['wallpaper'] and '1' or '0'),
|
||||
]
|
||||
|
||||
logger.debug('Data: {0}'.format(data))
|
||||
|
||||
if extra.has_key('tun'):
|
||||
if 'tun' in extra:
|
||||
data.append('tun:' + extra['tun'])
|
||||
|
||||
data = scramble('\t'.join(data))
|
||||
@ -91,16 +91,20 @@ def generateHtmlForRdp(transport, idUserService, idTransport, os, ip, port, user
|
||||
)
|
||||
return res
|
||||
|
||||
def getHtmlComponent(module, componentId):
|
||||
filesDict = { '1' : ['rdp.jar', 'application/java-archive' ], '2' : ['rdppass.dll', 'application/x-msdos-program' ],
|
||||
'3' : ['launcher.jar', 'application/java-archive'] }
|
||||
|
||||
if filesDict.has_key(componentId) == False:
|
||||
def getHtmlComponent(module, componentId):
|
||||
filesDict = {
|
||||
'1': ['rdp.jar', 'application/java-archive'],
|
||||
'2': ['rdppass.dll', 'application/x-msdos-program'],
|
||||
'3': ['launcher.jar', 'application/java-archive']
|
||||
}
|
||||
|
||||
if componentId not in filesDict:
|
||||
return ['text/plain', 'no component']
|
||||
fname = os.path.dirname(sys.modules[module].__file__) + '/applet/' + filesDict[componentId][0]
|
||||
logger.debug('Loading component {0} from {1}'.format(componentId, fname))
|
||||
|
||||
f = open(fname, 'rb')
|
||||
data = f.read()
|
||||
f.close()
|
||||
return [ filesDict[componentId][1], data ]
|
||||
with open(fname, 'rb') as f:
|
||||
data = f.read()
|
||||
|
||||
return [filesDict[componentId][1], data]
|
||||
|
@ -47,6 +47,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
READY_CACHE_TIMEOUT = 30
|
||||
|
||||
|
||||
class TSNXTransport(Transport):
|
||||
'''
|
||||
Provides access via RDP to service.
|
||||
|
Loading…
x
Reference in New Issue
Block a user