mirror of
https://github.com/dkmstr/openuds.git
synced 2025-01-10 01:17:59 +03:00
Several fixes... :)
This commit is contained in:
parent
e7a3c7ebeb
commit
18c9406900
@ -111,6 +111,17 @@ STATICFILES_FINDERS = (
|
||||
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
|
||||
)
|
||||
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
|
||||
'LOCATION': 'uds_response_cache',
|
||||
'OPTIONS': {
|
||||
'MAX_ENTRIES': 5000,
|
||||
'CULL_FREQUENCY': 3, # 0 = Entire cache will be erased once MAX_ENTRIES is reached, this is faster on DB. if other value, will remove 1/this number items fromm cache
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Related to file uploading
|
||||
FILE_UPLOAD_PERMISSIONS = 0o640
|
||||
FILE_UPLOAD_DIRECTORY_PERMISSIONS = 0o750
|
||||
|
@ -33,6 +33,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from uds.core.util.Cache import Cache as uCache
|
||||
from django.core.cache import cache as djCache
|
||||
from uds.REST import Handler, RequestError, NotFound
|
||||
|
||||
import logging
|
||||
@ -71,4 +72,5 @@ class Cache(Handler):
|
||||
raise RequestError('Invalid Request')
|
||||
|
||||
uCache.purge()
|
||||
djCache.clear()
|
||||
return 'done'
|
||||
|
@ -34,11 +34,12 @@ from __future__ import unicode_literals
|
||||
|
||||
NONE = ''
|
||||
RDP = 'rdp'
|
||||
RDS = 'rds' # In fact, RDS (Remote Desktop Services) is RDP, but have "more info" for connection that RDP
|
||||
RGS = 'rgs'
|
||||
SPICE = 'spice'
|
||||
VNC = 'vnc'
|
||||
PCOIP = 'pcoip'
|
||||
REMOTEFX = 'remotefx'
|
||||
REMOTEFX = 'remotefx' # This in fact is RDP als
|
||||
HDX = 'hdx'
|
||||
ICA = 'ica'
|
||||
NX = 'nx'
|
||||
|
@ -296,6 +296,7 @@ class GlobalConfig(object):
|
||||
|
||||
# Gui vars
|
||||
UDS_THEME = Config.section(GLOBAL_SECTION).value('UDS Theme', 'html5', type=Config.TEXT_FIELD)
|
||||
RELOAD_TIME = Config.section(GLOBAL_SECTION).value('Page reload Time', '60', type=Config.NUMERIC_FIELD)
|
||||
|
||||
# This is used so templates can change "styles" from admin interface
|
||||
UDS_THEME_VISUAL = Config.section(GLOBAL_SECTION).value('UDS Theme Enhaced', '1', type=Config.BOOLEAN_FIELD)
|
||||
|
@ -32,7 +32,7 @@
|
||||
'''
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from uds.models import UniqueId as dbUniqueId
|
||||
from uds.models.UniqueId import UniqueId
|
||||
from uds.models import getSqlDatetime
|
||||
import logging
|
||||
|
||||
@ -51,7 +51,7 @@ class UniqueIDGenerator(object):
|
||||
self._baseName = newBaseName
|
||||
|
||||
def __filter(self, rangeStart, rangeEnd=MAX_SEQ):
|
||||
return dbUniqueId.objects.filter(basename=self._baseName, seq__gte=rangeStart, seq__lte=rangeEnd) # @UndefinedVariable
|
||||
return UniqueId.objects.filter(basename=self._baseName, seq__gte=rangeStart, seq__lte=rangeEnd) # @UndefinedVariable
|
||||
|
||||
def get(self, rangeStart=0, rangeEnd=MAX_SEQ):
|
||||
'''
|
||||
@ -60,12 +60,13 @@ class UniqueIDGenerator(object):
|
||||
'''
|
||||
# First look for a name in the range defined
|
||||
stamp = getSqlDatetime(True)
|
||||
logger.debug(UniqueId)
|
||||
try:
|
||||
dbUniqueId.objects.lock() # @UndefinedVariable
|
||||
UniqueId.objects.lock() # @UndefinedVariable
|
||||
flt = self.__filter(rangeStart, rangeEnd)
|
||||
try:
|
||||
item = flt.filter(assigned=False).order_by('seq')[0]
|
||||
dbUniqueId.objects.filter(id=item.id).update(owner=self._owner, assigned=True, stamp=stamp) # @UndefinedVariable
|
||||
UniqueId.objects.filter(id=item.id).update(owner=self._owner, assigned=True, stamp=stamp) # @UndefinedVariable
|
||||
seq = item.seq
|
||||
except Exception: # No free element found
|
||||
try:
|
||||
@ -76,19 +77,20 @@ class UniqueIDGenerator(object):
|
||||
logger.debug('Found seq {0}'.format(seq))
|
||||
if seq > rangeEnd:
|
||||
return -1 # No ids free in range
|
||||
dbUniqueId.objects.create(owner=self._owner, basename=self._baseName, seq=seq, assigned=True, stamp=stamp) # @UndefinedVariable
|
||||
UniqueId.objects.create(owner=self._owner, basename=self._baseName, seq=seq, assigned=True, stamp=stamp) # @UndefinedVariable
|
||||
logger.debug('Seq: {}'.format(seq))
|
||||
return seq
|
||||
except Exception:
|
||||
logger.exception('Generating unique id sequence')
|
||||
return None
|
||||
finally:
|
||||
dbUniqueId.objects.unlock() # @UndefinedVariable
|
||||
UniqueId.objects.unlock() # @UndefinedVariable
|
||||
|
||||
def transfer(self, seq, toUidGen):
|
||||
try:
|
||||
dbUniqueId.objects.lock() # @UndefinedVariable
|
||||
UniqueId.objects.lock() # @UndefinedVariable
|
||||
|
||||
obj = dbUniqueId.objects.get(owner=self._owner, seq=seq) # @UndefinedVariable
|
||||
obj = UniqueId.objects.get(owner=self._owner, seq=seq) # @UndefinedVariable
|
||||
obj.owner = toUidGen._owner
|
||||
obj.basename = toUidGen._baseName
|
||||
obj.stamp = getSqlDatetime(True)
|
||||
@ -99,17 +101,17 @@ class UniqueIDGenerator(object):
|
||||
logger.exception('EXCEPTION AT transfer')
|
||||
return False
|
||||
finally:
|
||||
dbUniqueId.objects.unlock() # @UndefinedVariable
|
||||
UniqueId.objects.unlock() # @UndefinedVariable
|
||||
|
||||
def free(self, seq):
|
||||
try:
|
||||
logger.debug('Freeing seq {0} from {1} ({2})'.format(seq, self._owner, self._baseName))
|
||||
dbUniqueId.objects.lock() # @UndefinedVariable
|
||||
UniqueId.objects.lock() # @UndefinedVariable
|
||||
flt = self.__filter(0).filter(owner=self._owner, seq=seq).update(owner='', assigned=False, stamp=getSqlDatetime(True))
|
||||
if flt > 0:
|
||||
self.__purge()
|
||||
finally:
|
||||
dbUniqueId.objects.unlock() # @UndefinedVariable
|
||||
UniqueId.objects.unlock() # @UndefinedVariable
|
||||
|
||||
def __purge(self):
|
||||
try:
|
||||
@ -121,17 +123,17 @@ class UniqueIDGenerator(object):
|
||||
|
||||
def release(self):
|
||||
try:
|
||||
dbUniqueId.objects.lock() # @UndefinedVariable
|
||||
dbUniqueId.objects.filter(owner=self._owner).update(assigned=False, owner='', stamp=getSqlDatetime(True)) # @UndefinedVariable
|
||||
UniqueId.objects.lock() # @UndefinedVariable
|
||||
UniqueId.objects.filter(owner=self._owner).update(assigned=False, owner='', stamp=getSqlDatetime(True)) # @UndefinedVariable
|
||||
self.__purge()
|
||||
finally:
|
||||
dbUniqueId.objects.unlock() # @UndefinedVariable
|
||||
UniqueId.objects.unlock() # @UndefinedVariable
|
||||
|
||||
def releaseOlderThan(self, stamp):
|
||||
stamp = getSqlDatetime(True)
|
||||
try:
|
||||
dbUniqueId.objects.lock() # @UndefinedVariable
|
||||
dbUniqueId.objects.filter(owner=self._owner, stamp__lt=stamp).update(assigned=False, owner='', stamp=stamp) # @UndefinedVariable
|
||||
UniqueId.objects.lock() # @UndefinedVariable
|
||||
UniqueId.objects.filter(owner=self._owner, stamp__lt=stamp).update(assigned=False, owner='', stamp=stamp) # @UndefinedVariable
|
||||
self.__purge()
|
||||
finally:
|
||||
dbUniqueId.objects.unlock() # @UndefinedVariable
|
||||
UniqueId.objects.unlock() # @UndefinedVariable
|
||||
|
@ -4,7 +4,7 @@ from __future__ import unicode_literals
|
||||
from django.db import models, migrations
|
||||
from uds.core.ui.UserInterface import gui
|
||||
from uds.transports.RDP.RDPTransport import RDPTransport
|
||||
from uds.transports.RDP.TSRDPTransport import TSRDPTransport
|
||||
from uds.transports.RDP.TRDPTransport import TRDPTransport
|
||||
try:
|
||||
from uds.transports.RGS import RGSTransport # @UnresolvedImport, pylint: disable=import-error, no-name-in-module
|
||||
from uds.transports.RGS import TRGSTransport # @UnresolvedImport, pylint: disable=import-error, no-name-in-module
|
||||
@ -55,7 +55,7 @@ def unmarshalRDP(str_):
|
||||
}
|
||||
|
||||
|
||||
def unmarshalTSRDP(str_):
|
||||
def unmarshalTRDP(str_):
|
||||
data = str_.split('\t')
|
||||
if data[0] in ('v1', 'v2', 'v3'):
|
||||
useEmptyCreds = gui.strToBool(data[1])
|
||||
@ -178,9 +178,9 @@ def transformTransports(apps, schema_editor):
|
||||
t.data = rdp.serialize()
|
||||
t.save()
|
||||
|
||||
if t.data_type == TSRDPTransport.typeType:
|
||||
values = unmarshalTSRDP(t.data.decode(TSRDPTransport.CODEC))
|
||||
rdp = TSRDPTransport(Environment.getTempEnv(), values)
|
||||
if t.data_type == TRDPTransport.typeType:
|
||||
values = unmarshalTRDP(t.data.decode(TRDPTransport.CODEC))
|
||||
rdp = TRDPTransport(Environment.getTempEnv(), values)
|
||||
t.data = rdp.serialize()
|
||||
t.save()
|
||||
|
||||
|
@ -33,13 +33,15 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
__updated__ = '2014-04-24'
|
||||
|
||||
from django.db import models
|
||||
from uds.core.db.LockingManager import LockingManager
|
||||
|
||||
import logging
|
||||
|
||||
|
||||
__updated__ = '2015-05-14'
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -66,4 +68,3 @@ class UniqueId(models.Model):
|
||||
|
||||
def __unicode__(self):
|
||||
return u"{0} {1}.{2}, assigned is {3}".format(self.owner, self.basename, self.seq, self.assigned)
|
||||
|
||||
|
@ -35,14 +35,13 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
__updated__ = '2015-02-10'
|
||||
|
||||
from django.db import models
|
||||
from django.db.models import signals
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
|
||||
from uds.core.Environment import Environment
|
||||
from uds.core.util import log
|
||||
from uds.core.util import unique
|
||||
from uds.core.util.State import State
|
||||
from uds.models.UUIDModel import UUIDModel
|
||||
|
||||
@ -56,6 +55,9 @@ from uds.models.Util import getSqlDatetime
|
||||
|
||||
import logging
|
||||
|
||||
__updated__ = '2015-05-14'
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -116,9 +118,15 @@ class UserService(UUIDModel):
|
||||
|
||||
(see related classes uds.core.util.UniqueNameGenerator and uds.core.util.UniqueMacGenerator)
|
||||
'''
|
||||
from uds.core.util.UniqueMacGenerator import UniqueMacGenerator
|
||||
from uds.core.util.UniqueNameGenerator import UniqueNameGenerator
|
||||
return Environment.getEnvForTableElement(self._meta.verbose_name, self.id, {'mac': UniqueMacGenerator, 'name': UniqueNameGenerator})
|
||||
return Environment.getEnvForTableElement(
|
||||
self._meta.verbose_name,
|
||||
self.id,
|
||||
{
|
||||
'mac': unique.UniqueMacGenerator,
|
||||
'name': unique.UniqueNameGenerator,
|
||||
'id': unique.UniqueGIDGenerator,
|
||||
}
|
||||
)
|
||||
|
||||
def getInstance(self):
|
||||
'''
|
||||
|
@ -32,14 +32,8 @@
|
||||
'''
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
__updated__ = '2015-03-23'
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# Permissions
|
||||
from .Permissions import Permissions
|
||||
|
||||
@ -98,3 +92,10 @@ from .DelayedTask import DelayedTask
|
||||
from .Image import Image
|
||||
|
||||
from .TicketStore import TicketStore
|
||||
|
||||
|
||||
__updated__ = '2015-05-14'
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -8,6 +8,9 @@ from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
__updated__ = '2015-05-14'
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -37,6 +37,10 @@ from uds.core.util.State import State
|
||||
from datetime import datetime
|
||||
import logging
|
||||
|
||||
|
||||
__updated__ = '2015-05-14'
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -6,7 +6,8 @@ uds.safari = false
|
||||
uds.ie = false
|
||||
uds.firefox = false
|
||||
|
||||
uds.reloadCounter = 12
|
||||
uds.reloadCounterBase = 60
|
||||
uds.counterGranurality = 2 # Every this seconds, reload time will be checked
|
||||
|
||||
# First, detect browser
|
||||
(() ->
|
||||
@ -229,10 +230,10 @@ uds.onLink = ->
|
||||
return
|
||||
|
||||
uds.resetReloadCounter = ->
|
||||
uds.reloadCounter = 12
|
||||
uds.reloadCounter = uds.reloadCounterBase
|
||||
|
||||
uds.setReload = ->
|
||||
setTimeout uds.reload, 5000
|
||||
setTimeout uds.reload, uds.counterGranurality * 1000
|
||||
|
||||
uds.reload = ->
|
||||
if uds.reloadCounter == 0
|
||||
|
@ -1,6 +1,5 @@
|
||||
{% extends "uds/html5/templates/base.html" %}
|
||||
{% load i18n html5 static %}
|
||||
|
||||
{% block title %}{% trans 'Available services list' %}{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
@ -195,6 +194,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
{% pageReloadTime as reloadTime %}
|
||||
<script>
|
||||
function launchURL(el) {
|
||||
var $el = $(el);
|
||||
@ -212,6 +212,8 @@
|
||||
|
||||
$(function() {
|
||||
var autorun = {% if autorun %}true{% else %}false{% endif %};
|
||||
uds.reloadCounterBase = {{ reloadTime }} / uds.counterGranurality;
|
||||
uds.resetReloadCounter();
|
||||
|
||||
$('.with-tooltip').popover({container: 'body', trigger: 'hover', delay: { show: 500, hide: 100 }, placement: 'auto bottom'});
|
||||
|
||||
|
@ -152,6 +152,11 @@ def preferences_allowed():
|
||||
return GlobalConfig.PREFERENCES_ALLOWED.getBool(True)
|
||||
|
||||
|
||||
@register.assignment_tag
|
||||
def pageReloadTime():
|
||||
return GlobalConfig.RELOAD_TIME.getInt(True)
|
||||
|
||||
|
||||
@register.assignment_tag
|
||||
def root_id():
|
||||
return ROOT_ID
|
||||
|
@ -31,6 +31,7 @@
|
||||
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from django.utils.translation import ugettext_noop as _
|
||||
from uds.core.managers.UserPrefsManager import CommonPrefs
|
||||
from uds.core.ui.UserInterface import gui
|
||||
@ -41,6 +42,9 @@ from uds.core.util import connection
|
||||
import logging
|
||||
import os
|
||||
|
||||
__updated__ = '2015-05-14'
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
READY_CACHE_TIMEOUT = 30
|
||||
@ -65,6 +69,7 @@ class BaseRDPTransport(Transport):
|
||||
allowSerials = gui.CheckBoxField(label=_('Allow Serials'), order=9, tooltip=_('If checked, this transport will allow the use of user serial ports'))
|
||||
wallpaper = gui.CheckBoxField(label=_('Show wallpaper'), order=10, tooltip=_('If checked, the wallpaper and themes will be shown on machine (better user experience, more bandwidth)'))
|
||||
multimon = gui.CheckBoxField(label=_('Multiple monitors'), order=10, tooltip=_('If checked, all client monitors will be used for displaying (only works on windows clients)'))
|
||||
aero = gui.CheckBoxField(label=_('Allow Aero'), order=11, tooltip=_('If checked, desktop composition will be allowed'))
|
||||
|
||||
def isAvailableFor(self, userService, ip):
|
||||
'''
|
||||
|
@ -40,6 +40,8 @@ from uds.core.util import OsDetector
|
||||
import six
|
||||
import os
|
||||
|
||||
__updated__ = '2015-05-14'
|
||||
|
||||
|
||||
class RDPFile(object):
|
||||
fullScreen = False
|
||||
@ -59,6 +61,7 @@ class RDPFile(object):
|
||||
displayConnectionBar = True
|
||||
showWallpaper = False
|
||||
multimon = False
|
||||
desktopComposition = False
|
||||
|
||||
def __init__(self, fullScreen, width, height, bpp, target=OsDetector.Windows):
|
||||
self.width = six.text_type(width)
|
||||
@ -231,6 +234,11 @@ class RDPFile(object):
|
||||
res += 'enablecredsspsupport:i:1' + '\n'
|
||||
res += 'prompt for credentials:i:0' + '\n'
|
||||
res += 'negotiate security layer:i:1' + '\n'
|
||||
if self.desktopComposition is True:
|
||||
res += 'allow desktop composition:i:1\n'
|
||||
|
||||
if self.redirectAudio is True:
|
||||
res += 'audiocapturemode:i:1\n'
|
||||
|
||||
return res
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
'''
|
||||
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from django.utils.translation import ugettext_noop as _
|
||||
from uds.core.managers.UserPrefsManager import CommonPrefs
|
||||
from uds.core.util import OsDetector
|
||||
@ -44,6 +44,8 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
READY_CACHE_TIMEOUT = 30
|
||||
|
||||
__updated__ = '2015-05-14'
|
||||
|
||||
|
||||
class RDPTransport(BaseRDPTransport):
|
||||
'''
|
||||
@ -65,6 +67,7 @@ class RDPTransport(BaseRDPTransport):
|
||||
allowSerials = BaseRDPTransport.allowSerials
|
||||
wallpaper = BaseRDPTransport.wallpaper
|
||||
multimon = BaseRDPTransport.multimon
|
||||
aero = BaseRDPTransport.aero
|
||||
|
||||
def getUDSTransportScript(self, userService, transport, ip, os, user, password, request):
|
||||
# We use helper to keep this clean
|
||||
@ -87,6 +90,7 @@ class RDPTransport(BaseRDPTransport):
|
||||
r.redirectSerials = self.allowSerials.isTrue()
|
||||
r.showWallpaper = self.wallpaper.isTrue()
|
||||
r.multimon = self.multimon.isTrue()
|
||||
r.desktopComposition = self.aero.isTrue()
|
||||
|
||||
# data
|
||||
data = {
|
||||
|
@ -30,7 +30,7 @@
|
||||
'''
|
||||
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from django.utils.translation import ugettext_noop as _
|
||||
from uds.core.managers.UserPrefsManager import CommonPrefs
|
||||
from uds.core.ui.UserInterface import gui
|
||||
@ -47,12 +47,15 @@ import logging
|
||||
import random
|
||||
import string
|
||||
|
||||
__updated__ = '2015-05-14'
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
READY_CACHE_TIMEOUT = 30
|
||||
|
||||
|
||||
class TSRDPTransport(BaseRDPTransport):
|
||||
class TRDPTransport(BaseRDPTransport):
|
||||
'''
|
||||
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
|
||||
@ -78,6 +81,7 @@ class TSRDPTransport(BaseRDPTransport):
|
||||
allowSerials = BaseRDPTransport.allowSerials
|
||||
wallpaper = BaseRDPTransport.wallpaper
|
||||
multimon = BaseRDPTransport.multimon
|
||||
aero = BaseRDPTransport.aero
|
||||
|
||||
def initialize(self, values):
|
||||
if values is not None:
|
||||
@ -112,7 +116,7 @@ class TSRDPTransport(BaseRDPTransport):
|
||||
r.redirectSerials = self.allowSerials.isTrue()
|
||||
r.showWallpaper = self.wallpaper.isTrue()
|
||||
r.multimon = self.multimon.isTrue()
|
||||
|
||||
r.desktopComposition = self.aero.isTrue()
|
||||
|
||||
# data
|
||||
data = {
|
||||
@ -159,6 +163,6 @@ class TSRDPTransport(BaseRDPTransport):
|
||||
}.get(m.os)
|
||||
|
||||
if os is None:
|
||||
return super(TSRDPTransport, self).getUDSTransportScript(self, userService, transport, ip, os, user, password, request)
|
||||
return super(TRDPTransport, self).getUDSTransportScript(self, userService, transport, ip, os, user, password, request)
|
||||
|
||||
return self.getScript('scripts/{}/tunnel.py'.format(os)).format(m=m)
|
@ -34,7 +34,7 @@
|
||||
from django.utils.translation import ugettext_noop as _
|
||||
from uds.core.managers.UserPrefsManager import UserPrefsManager, CommonPrefs
|
||||
from .RDPTransport import RDPTransport
|
||||
from .TSRDPTransport import TSRDPTransport
|
||||
from .TRDPTransport import TRDPTransport
|
||||
|
||||
UserPrefsManager.manager().registerPrefs('rdp',
|
||||
_('Remote Desktop Protocol'),
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 793 B After Width: | Height: | Size: 818 B |
Loading…
Reference in New Issue
Block a user