mirror of
https://github.com/dkmstr/openuds.git
synced 2024-12-24 21:34:41 +03:00
Started experimental x2go support (for linux clients only right now)
This commit is contained in:
parent
cba154944d
commit
397bd29ce6
@ -44,7 +44,7 @@ HDX = 'hdx'
|
||||
ICA = 'ica'
|
||||
NX = 'nx'
|
||||
X11 = 'x11'
|
||||
X2GO = 'x2go'
|
||||
X2GO = 'x2go' # Based on NX
|
||||
OTHER = 'other'
|
||||
|
||||
GENERIC = (RDP, RGS, VNC, NX, X11, X2GO, PCOIP, OTHER)
|
||||
|
@ -59,7 +59,6 @@ class NXTransport(Transport):
|
||||
typeType = 'NXTransport'
|
||||
typeDescription = _('NX Transport for direct connection')
|
||||
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'), tab=gui.CREDENTIALS_TAB)
|
||||
|
@ -46,7 +46,7 @@ import logging
|
||||
import random
|
||||
import string
|
||||
|
||||
__updated__ = '2016-05-27'
|
||||
__updated__ = '2016-09-07'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -59,7 +59,6 @@ class TSPICETransport(BaseSpiceTransport):
|
||||
typeName = _('RHEV/oVirt SPICE Transport (tunneled)')
|
||||
typeType = 'TSSPICETransport'
|
||||
typeDescription = _('SPICE Transport for tunneled connection (EXPERIMENTAL)')
|
||||
needsJava = True # If this transport needs java for rendering
|
||||
protocol = protocols.SPICE
|
||||
|
||||
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)
|
||||
|
122
server/src/uds/transports/X2GO/BaseX2GOTransport.py
Normal file
122
server/src/uds/transports/X2GO/BaseX2GOTransport.py
Normal file
@ -0,0 +1,122 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#
|
||||
# Copyright (c) 2012 Virtual Cable S.L.
|
||||
# All rights reserved.
|
||||
#
|
||||
# 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,
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
'''
|
||||
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
|
||||
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 OsDetector
|
||||
|
||||
# This transport is specific for oVirt, so we need to point to it
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
__updated__ = '2016-09-07'
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
READY_CACHE_TIMEOUT = 30
|
||||
|
||||
|
||||
class BaseX2GOTransport(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
|
||||
'''
|
||||
iconFile = 'x2go.png'
|
||||
protocol = protocols.X2GO
|
||||
supportedOss = OsDetector.Linux
|
||||
|
||||
useEmptyCreds = gui.CheckBoxField(
|
||||
order=1,
|
||||
label=_('Empty credentials'),
|
||||
tooltip=_('If checked, the credentials used to connect will be emtpy'),
|
||||
tab=gui.CREDENTIALS_TAB
|
||||
)
|
||||
fixedName = gui.TextField(
|
||||
order=2,
|
||||
label=_('Username'),
|
||||
tooltip=_('If not empty, this username will be always used as credential'),
|
||||
tab=gui.CREDENTIALS_TAB
|
||||
)
|
||||
fixedPassword = gui.PasswordField(
|
||||
order=3,
|
||||
label=_('Password'),
|
||||
tooltip=_('If not empty, this password will be always used as credential'),
|
||||
tab=gui.CREDENTIALS_TAB
|
||||
)
|
||||
fullScreen = gui.CheckBoxField(
|
||||
order=5,
|
||||
label=_('Show fullscreen'),
|
||||
tooltip=_('If checked, viewer will be shown on fullscreen mode-'),
|
||||
tab=gui.ADVANCED_TAB
|
||||
)
|
||||
|
||||
def isAvailableFor(self, userService, ip):
|
||||
'''
|
||||
Checks if the transport is available for the requested destination ip
|
||||
Override this in yours transports
|
||||
'''
|
||||
logger.debug('Checking availability for {0}'.format(ip))
|
||||
return True # Spice is available, no matter what IP machine has (even if it does not have one)
|
||||
|
||||
def processedUser(self, userService, userName):
|
||||
v = self.processUserPassword(userService, userName, '')
|
||||
return v['username']
|
||||
|
||||
def processUserPassword(self, service, user, password):
|
||||
username = user.getUsernameForAuth()
|
||||
|
||||
if self.fixedName.value != '':
|
||||
username = self.fixedName.value
|
||||
|
||||
if self.fixedPassword.value != '':
|
||||
password = self.fixedPassword.value
|
||||
if self.useEmptyCreds.isTrue():
|
||||
username, password = '', '', ''
|
||||
|
||||
# Fix username/password acording to os manager
|
||||
username, password = service.processUserPassword(username, password)
|
||||
|
||||
return {'protocol': self.protocol, 'username': username, 'password': password}
|
||||
|
||||
def getConnectionInfo(self, service, user, password):
|
||||
return self.processUserPassword(service, user, password)
|
||||
|
||||
def getScript(self, script):
|
||||
with open(os.path.join(os.path.dirname(__file__), script)) as f:
|
||||
data = f.read()
|
||||
return data
|
72
server/src/uds/transports/X2GO/TX2GOTransport.py
Normal file
72
server/src/uds/transports/X2GO/TX2GOTransport.py
Normal file
@ -0,0 +1,72 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#
|
||||
# Copyright (c) 2012 Virtual Cable S.L.
|
||||
# All rights reserved.
|
||||
#
|
||||
# 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,
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
'''
|
||||
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
|
||||
from django.utils.translation import ugettext_noop as _
|
||||
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 OsDetector
|
||||
from uds.core.util import tools
|
||||
from uds.models import TicketStore
|
||||
|
||||
from .BaseX2GOTransport import BaseX2GOTransport
|
||||
|
||||
import logging
|
||||
import random
|
||||
import string
|
||||
|
||||
__updated__ = '2016-09-07'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TX2GOTransport(BaseX2GOTransport):
|
||||
'''
|
||||
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 = _('X2Go Transport (tunneled)')
|
||||
typeType = 'TX2GOTransport'
|
||||
typeDescription = _('X2Go Transport for tunneled connection (EXPERIMENTAL)')
|
||||
protocol = protocols.SPICE
|
||||
|
||||
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)
|
||||
|
||||
|
||||
def initialize(self, values):
|
||||
if values is not None:
|
||||
if values['tunnelServer'].count(':') != 1:
|
||||
raise Transport.ValidationException(_('Must use HOST:PORT in Tunnel Server Field'))
|
||||
|
||||
def getUDSTransportScript(self, userService, transport, ip, os, user, password, request):
|
||||
pass
|
60
server/src/uds/transports/X2GO/X2GOTransport.py
Normal file
60
server/src/uds/transports/X2GO/X2GOTransport.py
Normal file
@ -0,0 +1,60 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#
|
||||
# Copyright (c) 2012 Virtual Cable S.L.
|
||||
# All rights reservem.
|
||||
#
|
||||
# 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,
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
'''
|
||||
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
|
||||
from django.utils.translation import ugettext_noop as _
|
||||
from uds.core.util import OsDetector
|
||||
from uds.core.util import tools
|
||||
from .BaseX2GOTransport import BaseX2GOTransport
|
||||
|
||||
import logging
|
||||
|
||||
__updated__ = '2016-09-07'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class X2GOTransport(BaseX2GOTransport):
|
||||
'''
|
||||
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 = _('X2Go Transport (direct)')
|
||||
typeType = 'X2GOTransport'
|
||||
typeDescription = _('X2Go Transport for direct connection (EXPERIMENTAL)')
|
||||
|
||||
# useEmptyCreds = BaseSpiceTransport.useEmptyCreds
|
||||
# fixedName = BaseSpiceTransport.fixedName
|
||||
# fixedPassword = BaseSpiceTransport.fixedPassword
|
||||
|
||||
def getUDSTransportScript(self, userService, transport, ip, os, user, password, request):
|
||||
pass
|
37
server/src/uds/transports/X2GO/__init__.py
Normal file
37
server/src/uds/transports/X2GO/__init__.py
Normal file
@ -0,0 +1,37 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#
|
||||
# Copyright (c) 2012 Virtual Cable S.L.
|
||||
# All rights reserved.
|
||||
#
|
||||
# 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,
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
'''
|
||||
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
|
||||
from django.utils.translation import ugettext_noop as _
|
||||
from uds.core.managers.UserPrefsManager import UserPrefsManager, CommonPrefs
|
||||
from .X2GOTransport import X2GOTransport
|
||||
from .TX2GOTransport import TX2GOTransport
|
25
server/src/uds/transports/X2GO/scripts/linux/direct.py
Normal file
25
server/src/uds/transports/X2GO/scripts/linux/direct.py
Normal file
@ -0,0 +1,25 @@
|
||||
# This is a template
|
||||
# Saved as .py for easier editing
|
||||
from __future__ import unicode_literals
|
||||
|
||||
# pylint: disable=import-error, no-name-in-module
|
||||
import subprocess
|
||||
|
||||
from uds import tools # @UnresolvedImport
|
||||
|
||||
executable = tools.findApp('remote-viewer')
|
||||
|
||||
if executable is None:
|
||||
raise Exception('''<p>You need to have installed virt-viewer to connect to this UDS service.</p>
|
||||
<p>
|
||||
Please, install appropriate package for your Linux system. (probably named something like <b>remote-viewer</b>)
|
||||
</p>
|
||||
''')
|
||||
|
||||
theFile = '''{m.r.as_file}'''
|
||||
|
||||
filename = tools.saveTempFile(theFile)
|
||||
|
||||
subprocess.Popen([executable, filename])
|
||||
|
||||
# QtGui.QMessageBox.critical(parent, 'Notice', filename + ", " + executable, QtGui.QMessageBox.Ok)
|
48
server/src/uds/transports/X2GO/scripts/linux/tunnel.py
Normal file
48
server/src/uds/transports/X2GO/scripts/linux/tunnel.py
Normal file
@ -0,0 +1,48 @@
|
||||
# This is a template
|
||||
# Saved as .py for easier editing
|
||||
from __future__ import unicode_literals
|
||||
|
||||
# pylint: disable=import-error, no-name-in-module, undefined-variable
|
||||
import subprocess
|
||||
|
||||
from uds import tools # @UnresolvedImport
|
||||
from uds.forward import forward # @UnresolvedImport
|
||||
|
||||
executable = tools.findApp('remote-viewer')
|
||||
|
||||
if executable is None:
|
||||
raise Exception('''<p>You need to have installed virt-viewer to connect to this UDS service.</p>
|
||||
<p>
|
||||
Please, install appropriate package for your system.
|
||||
</p>
|
||||
<p>
|
||||
Please, install appropriate package for your Linux system. (probably named something like <b>virt-viewer</b>)
|
||||
</p>
|
||||
''')
|
||||
|
||||
|
||||
if {m.port} != -1: # @UndefinedVariable
|
||||
forwardThread1, port = forward('{m.tunHost}', '{m.tunPort}', '{m.tunUser}', '{m.tunPass}', '{m.ip}', {m.port}) # @UndefinedVariable
|
||||
|
||||
if forwardThread1.status == 2:
|
||||
raise Exception('Unable to open tunnel')
|
||||
else:
|
||||
port = -1
|
||||
|
||||
if {m.secure_port} != -1: # @UndefinedVariable
|
||||
forwardThread2, secure_port = forwardThread1.clone('{m.ip}', {m.secure_port}) # @UndefinedVariable
|
||||
|
||||
if forwardThread2.status == 2:
|
||||
raise Exception('Unable to open tunnel')
|
||||
else:
|
||||
secure_port = -1
|
||||
|
||||
theFile = '''{m.r.as_file}'''.format(
|
||||
secure_port=secure_port,
|
||||
port=port
|
||||
)
|
||||
|
||||
filename = tools.saveTempFile(theFile)
|
||||
|
||||
|
||||
subprocess.Popen([executable, filename])
|
BIN
server/src/uds/transports/X2GO/x2go.png
Normal file
BIN
server/src/uds/transports/X2GO/x2go.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.7 KiB |
Loading…
Reference in New Issue
Block a user