mirror of
https://github.com/dkmstr/openuds.git
synced 2024-12-22 13:34:04 +03:00
moving constants (os constants) to uds.core.consts module
This commit is contained in:
parent
eab6703f2f
commit
639273fd35
1
server/src/tests/fixtures/servers.py
vendored
1
server/src/tests/fixtures/servers.py
vendored
@ -32,7 +32,6 @@ import typing
|
||||
|
||||
from uds import models
|
||||
from uds.core import types
|
||||
from uds.core.util import os_detector
|
||||
import datetime
|
||||
|
||||
from ..utils import generators
|
||||
|
@ -37,8 +37,8 @@ import typing
|
||||
from unittest import mock
|
||||
|
||||
from uds import models
|
||||
from uds.core import types, consts
|
||||
from uds.web.util import services
|
||||
import uds.core.util.os_detector as osd
|
||||
|
||||
from ...utils.test import UDSTransactionTestCase
|
||||
from ...fixtures import authenticators as fixtures_authenticators
|
||||
@ -66,8 +66,8 @@ class TestGetServicesData(UDSTransactionTestCase):
|
||||
self.request.ip = '127.0.0.1'
|
||||
self.request.ip_version = 4
|
||||
self.request.ip_proxy = '127.0.0.1'
|
||||
self.request.os = osd.DetectedOsInfo(
|
||||
osd.KnownOS.LINUX, osd.KnownBrowser.FIREFOX, 'Windows 10'
|
||||
self.request.os = types.os.DetectedOsInfo(
|
||||
types.os.KnownOS.LINUX, types.os.KnownBrowser.FIREFOX, 'Windows 10'
|
||||
)
|
||||
|
||||
return super().setUp()
|
||||
|
@ -42,7 +42,6 @@ from uds.core.util import log, security
|
||||
from uds.core.util.cache import Cache
|
||||
from uds.core.util.config import GlobalConfig
|
||||
from uds.core.util.model import getSqlDatetime
|
||||
from uds.core.util.os_detector import KnownOS
|
||||
from uds.core.util.state import State
|
||||
from uds.models import Server, Service, TicketStore, UserService
|
||||
from uds.models.service import ServiceTokenAlias
|
||||
@ -307,7 +306,7 @@ class Register(ActorV3Action):
|
||||
'type': types.servers.ServerType.ACTOR,
|
||||
'subtype': self._params.get('version', ''),
|
||||
'version': '',
|
||||
'os_type': self._params.get('os', KnownOS.UNKNOWN.os_name()),
|
||||
'os_type': self._params.get('os', types.os.KnownOS.UNKNOWN.os_name()),
|
||||
'mac': self._params['mac'],
|
||||
'stamp': getSqlDatetime(),
|
||||
}
|
||||
@ -584,7 +583,7 @@ class Login(ActorV3Action):
|
||||
|
||||
def action(self) -> typing.Dict[str, typing.Any]:
|
||||
isManaged = self._params.get('type') != UNMANAGED
|
||||
src = types.connections.ConnectionSourceType('', '')
|
||||
src = types.connections.ConnectionSource('', '')
|
||||
deadLine = maxIdle = None
|
||||
session_id = ''
|
||||
|
||||
|
@ -153,7 +153,7 @@ class Connection(Handler):
|
||||
password = CryptoManager().symDecrpyt(self.getValue('password'), scrambler)
|
||||
|
||||
userService.setConnectionSource(
|
||||
types.connections.ConnectionSourceType(self._request.ip, hostname)
|
||||
types.connections.ConnectionSource(self._request.ip, hostname)
|
||||
) # Store where we are accessing from so we can notify Service
|
||||
|
||||
if not ip or not transportInstance:
|
||||
|
@ -37,7 +37,6 @@ from django.utils.translation import gettext_lazy as _
|
||||
from uds import models
|
||||
from uds.core import consts, exceptions, types
|
||||
from uds.core.util import decorators, validators, log, model
|
||||
from uds.core.util.os_detector import KnownOS
|
||||
from uds.REST import Handler, exceptions as rest_exceptions
|
||||
from uds.REST.utils import rest_result
|
||||
|
||||
@ -58,7 +57,7 @@ class ServerRegisterBase(Handler):
|
||||
mac = self._params.get('mac', consts.MAC_UNKNOWN)
|
||||
data = self._params.get('data', None)
|
||||
subtype = self._params.get('subtype', '')
|
||||
os = self._params.get('os', KnownOS.UNKNOWN.os_name()).lower()
|
||||
os = self._params.get('os', types.os.KnownOS.UNKNOWN.os_name()).lower()
|
||||
|
||||
type = self._params['type'] # MUST be present
|
||||
hostname = self._params['hostname'] # MUST be present
|
||||
@ -108,7 +107,7 @@ class ServerRegisterBase(Handler):
|
||||
stamp=now,
|
||||
type=self._params['type'],
|
||||
subtype=self._params.get('subtype', ''), # Optional
|
||||
os_type=typing.cast(str, self._params.get('os', KnownOS.UNKNOWN.os_name())).lower(),
|
||||
os_type=typing.cast(str, self._params.get('os', types.os.KnownOS.UNKNOWN.os_name())).lower(),
|
||||
mac=mac,
|
||||
data=data,
|
||||
)
|
||||
|
@ -37,10 +37,9 @@ import typing
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
from uds.core.environment import Environment
|
||||
from uds.models import Transport, Network, ServicePool
|
||||
from uds.core import transports, types
|
||||
from uds.core import transports, types, consts
|
||||
from uds.core.ui import gui
|
||||
from uds.core.util import permissions
|
||||
from uds.core.util import os_detector as OsDetector
|
||||
|
||||
from uds.REST.model import ModelHandler
|
||||
|
||||
@ -101,7 +100,7 @@ class Transports(ModelHandler):
|
||||
'choices': sorted(
|
||||
[
|
||||
{'id': x.name, 'text': x.name}
|
||||
for x in OsDetector.knownOss
|
||||
for x in consts.os.KNOWN_OS_LIST
|
||||
],
|
||||
key=lambda x: x['text'].lower(),
|
||||
),
|
||||
|
@ -35,7 +35,6 @@ import typing
|
||||
from uds import models
|
||||
from uds.core import consts, types
|
||||
from uds.core.util.model import getSqlStampInSeconds, getSqlDatetime
|
||||
from uds.core.util.os_detector import KnownOS
|
||||
from uds.REST import Handler
|
||||
from uds.REST import AccessDenied
|
||||
from uds.core.auths.auth import isTrustedSource
|
||||
@ -163,7 +162,7 @@ class TunnelRegister(ServerRegisterBase):
|
||||
# Just a compatibility method for old tunnel servers
|
||||
def post(self) -> typing.MutableMapping[str, typing.Any]:
|
||||
self._params['type'] = types.servers.ServerType.TUNNEL
|
||||
self._params['os'] = self._params.get('os', KnownOS.LINUX.os_name()) # Legacy tunnels are always linux
|
||||
self._params['os'] = self._params.get('os', types.os.KnownOS.LINUX.os_name()) # Legacy tunnels are always linux
|
||||
self._params['version'] = '' # No version for legacy tunnels, does not respond to API requests from UDS
|
||||
self._params['certificate'] = '' # No certificate for legacy tunnels, does not respond to API requests from UDS
|
||||
return super().post()
|
||||
|
@ -30,35 +30,33 @@
|
||||
"""
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import re
|
||||
from urllib.parse import urlparse
|
||||
import xml.sax # nosec: used to parse trusted xml provided only by administrators
|
||||
import datetime
|
||||
import logging
|
||||
import re
|
||||
import typing
|
||||
import xml.sax # nosec: used to parse trusted xml provided only by administrators
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import requests
|
||||
|
||||
from django.utils.translation import gettext
|
||||
from django.utils.translation import gettext_noop as _
|
||||
from onelogin.saml2.auth import OneLogin_Saml2_Auth
|
||||
from onelogin.saml2.idp_metadata_parser import OneLogin_Saml2_IdPMetadataParser
|
||||
from onelogin.saml2.settings import OneLogin_Saml2_Settings
|
||||
|
||||
from django.utils.translation import gettext_noop as _, gettext
|
||||
from uds.core.types.request import ExtendedHttpRequest
|
||||
|
||||
from uds.core.util.model import getSqlDatetime
|
||||
from uds.core.ui import gui
|
||||
from uds.core import auths, exceptions
|
||||
from uds.core import auths, exceptions, types
|
||||
from uds.core.managers.crypto import CryptoManager
|
||||
from uds.core.util.decorators import cached
|
||||
from uds.core.util import security
|
||||
from uds.core import types
|
||||
from uds.core.types.request import ExtendedHttpRequest
|
||||
from uds.core.ui import gui
|
||||
from uds.core.util import security, decorators, ensure
|
||||
from uds.core.util.model import getSqlDatetime
|
||||
|
||||
from . import config
|
||||
|
||||
# Not imported at runtime, just for type checking
|
||||
if typing.TYPE_CHECKING:
|
||||
from django.http import HttpRequest
|
||||
|
||||
from uds.core.types.request import ExtendedHttpRequestWithUser
|
||||
|
||||
|
||||
@ -310,7 +308,7 @@ class SAMLAuthenticator(auths.Authenticator):
|
||||
label=_('Metadata cache duration'),
|
||||
default=0,
|
||||
order=22,
|
||||
tooltip=_('Duration of metadata cache in seconds'),
|
||||
tooltip=_('Duration of metadata cache in days. 0 means default (ten years)'),
|
||||
tab=_('Metadata'),
|
||||
)
|
||||
|
||||
@ -318,7 +316,7 @@ class SAMLAuthenticator(auths.Authenticator):
|
||||
label=_('Metadata validity duration'),
|
||||
default=0,
|
||||
order=22,
|
||||
tooltip=_('Duration of metadata validity in seconds'),
|
||||
tooltip=_('Duration of metadata validity in days. 0 means default (ten years)'),
|
||||
tab=_('Metadata'),
|
||||
)
|
||||
|
||||
@ -455,7 +453,7 @@ class SAMLAuthenticator(auths.Authenticator):
|
||||
'query_string': request.META['QUERY_STRING'],
|
||||
}
|
||||
|
||||
@cached(
|
||||
@decorators.cached(
|
||||
cachePrefix='idpm',
|
||||
cachingKeyFnc=CACHING_KEY_FNC,
|
||||
cacheTimeout=3600 * 24 * 365, # 1 year
|
||||
@ -499,11 +497,11 @@ class SAMLAuthenticator(auths.Authenticator):
|
||||
'security': {
|
||||
'metadataCacheDuration': self.metadataCacheDuration.int_value
|
||||
if self.metadataCacheDuration.int_value > 0
|
||||
else None,
|
||||
else 86400 * 365 * 10,
|
||||
'metadataValidUntil': getSqlDatetime()
|
||||
+ datetime.timedelta(seconds=self.metadataValidityDuration.int_value)
|
||||
if self.metadataCacheDuration.int_value > 0
|
||||
else None,
|
||||
else getSqlDatetime() + datetime.timedelta(days=365 * 10),
|
||||
'nameIdEncrypted': self.nameIdEncrypted.isTrue(),
|
||||
'authnRequestsSigned': self.authnRequestsSigned.isTrue(),
|
||||
'logoutRequestSigned': self.logoutRequestSigned.isTrue(),
|
||||
@ -527,7 +525,7 @@ class SAMLAuthenticator(auths.Authenticator):
|
||||
},
|
||||
}
|
||||
|
||||
@cached(
|
||||
@decorators.cached(
|
||||
cachePrefix='spm',
|
||||
cachingKeyFnc=CACHING_KEY_FNC,
|
||||
cacheTimeout=3600, # 1 hour
|
||||
@ -567,17 +565,18 @@ class SAMLAuthenticator(auths.Authenticator):
|
||||
if '+' in attrName:
|
||||
attrList = attrName.split('+')
|
||||
# Check all attributes are present, and has only one value
|
||||
if not all([len(attributes.get(a, [])) <= 1 for a in attrList]):
|
||||
attrValues = [ensure.is_list(attributes.get(a, [''])) for a in attrList]
|
||||
if not all([len(v) <= 1 for v in attrValues]):
|
||||
logger.warning('Attribute %s do not has exactly one value, skipping %s', attrName, line)
|
||||
return val
|
||||
|
||||
val = [''.join([attributes.get(a, [''])[0] for a in attrList])]
|
||||
val = [''.join(v) for v in attrValues] # flatten
|
||||
elif ':' in attrName:
|
||||
# Prepend the value after : to value before :
|
||||
# Prepend the value after : to attribute value before :
|
||||
attr, prependable = attrName.split(':')
|
||||
val = [prependable + a for a in attributes.get(attr, [])]
|
||||
val = [prependable + a for a in ensure.is_list(attributes.get(attr, []))]
|
||||
else:
|
||||
val = attributes.get(attrName, [])
|
||||
val = ensure.is_list(attributes.get(attrName, []))
|
||||
return val
|
||||
|
||||
for line in field.splitlines():
|
||||
|
@ -34,7 +34,7 @@ import typing
|
||||
from datetime import datetime
|
||||
import time
|
||||
|
||||
from . import images
|
||||
from . import images, os
|
||||
|
||||
# UDS Version related
|
||||
VERSION = '4.x.x-DEVEL'
|
||||
@ -66,7 +66,7 @@ ALLOWED_FAILS: typing.Final[int] = 5
|
||||
USER_AGENT: typing.Final[str] = f'UDS/{VERSION}'
|
||||
COMMS_TIMEOUT: typing.Final[int] = 5 # Timeout for communications with servers
|
||||
MIN_SERVER_VERSION: typing.Final[str] = '4.0.0'
|
||||
FAILURE_TIMEOUT: typing.Final[int] = 60 # In case of failure, wait this time before retrying (where applicable)
|
||||
FAILURE_TIMEOUT: typing.Final[int] = 60 # In case of failure, wait this time before retrying (where applicable)
|
||||
|
||||
# For conversion to boolean
|
||||
BOOL_TRUE_VALUES: typing.Final[typing.Set[typing.Union[bool, str, bytes, int]]] = {
|
||||
|
91
server/src/uds/core/consts/os.py
Normal file
91
server/src/uds/core/consts/os.py
Normal file
@ -0,0 +1,91 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#
|
||||
# Copyright (c) 2012-2023 Virtual Cable S.L.U.
|
||||
# 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.U. 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
|
||||
"""
|
||||
import enum
|
||||
import re
|
||||
import logging
|
||||
import typing
|
||||
|
||||
from uds.core import types
|
||||
|
||||
|
||||
KNOWN_OS_LIST: typing.Final[typing.Tuple[types.os.KnownOS, ...]] = tuple(
|
||||
os for os in types.os.KnownOS if os != types.os.KnownOS.UNKNOWN
|
||||
)
|
||||
|
||||
ALL_OS_LIST: typing.Final[typing.Tuple[types.os.KnownOS, ...]] = KNOWN_OS_LIST + (types.os.KnownOS.UNKNOWN,)
|
||||
desktopOss: typing.Final[typing.Tuple[types.os.KnownOS, ...]] = (
|
||||
types.os.KnownOS.LINUX,
|
||||
types.os.KnownOS.WINDOWS,
|
||||
types.os.KnownOS.MAC_OS,
|
||||
)
|
||||
MOBILE_OS_LIST: typing.Final[typing.Tuple[types.os.KnownOS, ...]] = tuple(set(ALL_OS_LIST) - set(desktopOss))
|
||||
|
||||
|
||||
DEFAULT_OS: typing.Final[types.os.KnownOS] = types.os.KnownOS.WINDOWS
|
||||
|
||||
|
||||
knownBrowsers = tuple(types.os.KnownBrowser)
|
||||
|
||||
browsersREs: typing.Dict[types.os.KnownBrowser, typing.Tuple] = {
|
||||
types.os.KnownBrowser.FIREFOX: (re.compile(r'Firefox/([0-9.]+)'),),
|
||||
types.os.KnownBrowser.SEAMONKEY: (re.compile(r'Seamonkey/([0-9.]+)'),),
|
||||
types.os.KnownBrowser.CHROME: (re.compile(r'Chrome/([0-9.]+)'),),
|
||||
types.os.KnownBrowser.CHROMIUM: (re.compile(r'Chromium/([0-9.]+)'),),
|
||||
types.os.KnownBrowser.SAFARI: (re.compile(r'Safari/([0-9.]+)'),),
|
||||
types.os.KnownBrowser.OPERA: (
|
||||
re.compile(r'OPR/([0-9.]+)'),
|
||||
re.compile(r'Opera/([0-9.]+)'),
|
||||
),
|
||||
types.os.KnownBrowser.IEXPLORER: (
|
||||
re.compile(r';MSIE ([0-9.]+);'),
|
||||
re.compile(r'Trident/.*rv:([0-9.]+)'),
|
||||
),
|
||||
types.os.KnownBrowser.EDGE: (re.compile(r'Edg/([0-9.]+)'),),
|
||||
}
|
||||
|
||||
browserRules: typing.Dict[types.os.KnownBrowser, typing.Tuple] = {
|
||||
types.os.KnownBrowser.EDGE: (types.os.KnownBrowser.EDGE, ()),
|
||||
types.os.KnownBrowser.CHROME: (
|
||||
types.os.KnownBrowser.CHROME,
|
||||
(types.os.KnownBrowser.CHROMIUM, types.os.KnownBrowser.OPERA),
|
||||
),
|
||||
types.os.KnownBrowser.FIREFOX: (types.os.KnownBrowser.FIREFOX, (types.os.KnownBrowser.SEAMONKEY,)),
|
||||
types.os.KnownBrowser.IEXPLORER: (types.os.KnownBrowser.IEXPLORER, ()),
|
||||
types.os.KnownBrowser.CHROMIUM: (types.os.KnownBrowser.CHROMIUM, (types.os.KnownBrowser.CHROME,)),
|
||||
types.os.KnownBrowser.SAFARI: (
|
||||
types.os.KnownBrowser.SAFARI,
|
||||
(types.os.KnownBrowser.CHROME, types.os.KnownBrowser.CHROMIUM, types.os.KnownBrowser.OPERA),
|
||||
),
|
||||
types.os.KnownBrowser.SEAMONKEY: (types.os.KnownBrowser.SEAMONKEY, (types.os.KnownBrowser.FIREFOX,)),
|
||||
types.os.KnownBrowser.OPERA: (types.os.KnownBrowser.OPERA, ()),
|
||||
}
|
@ -377,7 +377,7 @@ class ServerManager(metaclass=singleton.Singleton):
|
||||
self,
|
||||
server: 'models.Server',
|
||||
userService: 'models.UserService',
|
||||
info: types.connections.ConnectionDataType,
|
||||
info: types.connections.ConnectionData,
|
||||
) -> None:
|
||||
"""
|
||||
Notifies preconnect to server
|
||||
|
@ -47,6 +47,7 @@ if typing.TYPE_CHECKING:
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
AUTH_TOKEN = 'X-TOKEN-AUTH'
|
||||
|
||||
# Restrainer decorator
|
||||
# If server is restrained, it will return False
|
||||
@ -103,7 +104,7 @@ class ServerApiRequester:
|
||||
'Accept': 'application/json',
|
||||
'User-Agent': consts.USER_AGENT,
|
||||
'X-UDS-VERSION': consts.VERSION,
|
||||
'X-AUTH-HASH': self.hash,
|
||||
AUTH_TOKEN: self.hash,
|
||||
}
|
||||
)
|
||||
except Exception as e:
|
||||
@ -179,7 +180,7 @@ class ServerApiRequester:
|
||||
logger.debug('Notifying assign of service %s to server %s', userService.uuid, self.server.host)
|
||||
self.post(
|
||||
'assign',
|
||||
types.connections.AssignRequestType(
|
||||
types.connections.AssignRequest(
|
||||
udsuser=userService.user.name + '@' + userService.user.manager.name if userService.user else '',
|
||||
udsuser_uuid=userService.user.uuid if userService.user else '',
|
||||
userservice_uuid=userService.uuid,
|
||||
@ -191,7 +192,7 @@ class ServerApiRequester:
|
||||
|
||||
@restrainServer
|
||||
def notifyPreconnect(
|
||||
self, userService: 'models.UserService', info: 'types.connections.ConnectionDataType'
|
||||
self, userService: 'models.UserService', info: 'types.connections.ConnectionData'
|
||||
) -> bool:
|
||||
"""
|
||||
Notifies preconnect to server, if this allows it
|
||||
@ -209,8 +210,8 @@ class ServerApiRequester:
|
||||
'Notifying preconnect of service %s to server %s: %s', userService.uuid, self.server.host, info
|
||||
)
|
||||
self.post(
|
||||
'preConnect',
|
||||
types.connections.PreconnectRequestType(
|
||||
'preconnect',
|
||||
types.connections.PreconnectRequest(
|
||||
user=info.username,
|
||||
protocol=info.protocol,
|
||||
service_type=info.service_type,
|
||||
@ -230,7 +231,7 @@ class ServerApiRequester:
|
||||
Notifies removal of user service to server
|
||||
"""
|
||||
logger.debug('Notifying release of service %s to server %s', userService.uuid, self.server.host)
|
||||
self.post('removeService', {'userservice': userService.uuid})
|
||||
self.post('release', {'userservice': userService.uuid})
|
||||
|
||||
return True
|
||||
|
||||
|
@ -31,38 +31,28 @@
|
||||
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import random
|
||||
import operator
|
||||
import random
|
||||
import typing
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
from django.db.models import Q
|
||||
from django.db import transaction
|
||||
from django.db.models import Q
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from uds.core import types
|
||||
from uds.core.services.exceptions import OperationException
|
||||
from uds.core.util.state import State
|
||||
from uds.core.util import log
|
||||
from uds.core import consts, services, transports, types
|
||||
from uds.core.services.exceptions import (
|
||||
MaxServicesReachedError,
|
||||
ServiceInMaintenanceMode,
|
||||
InvalidServiceException,
|
||||
ServiceNotReadyError,
|
||||
MaxServicesReachedError,
|
||||
OperationException,
|
||||
ServiceAccessDeniedByCalendar,
|
||||
ServiceInMaintenanceMode,
|
||||
ServiceNotReadyError,
|
||||
)
|
||||
from uds.models import (
|
||||
MetaPool,
|
||||
ServicePool,
|
||||
UserService,
|
||||
Transport,
|
||||
User,
|
||||
ServicePoolPublication,
|
||||
)
|
||||
from uds.core.util import log, singleton
|
||||
from uds.core.util.model import getSqlDatetime
|
||||
from uds.core import services, transports
|
||||
from uds.core.util import singleton
|
||||
from uds.core.util.state import State
|
||||
from uds.core.util.stats import events
|
||||
from uds.core.util.os_detector import DetectedOsInfo
|
||||
from uds.models import MetaPool, ServicePool, ServicePoolPublication, Transport, User, UserService
|
||||
|
||||
from .userservice import comms
|
||||
from .userservice.opchecker import UserServiceOpChecker
|
||||
@ -611,7 +601,7 @@ class UserServiceManager(metaclass=singleton.Singleton):
|
||||
except Exception:
|
||||
logger.exception('Reseting service')
|
||||
|
||||
def notifyPreconnect(self, userService: UserService, info: types.connections.ConnectionDataType) -> None:
|
||||
def notifyPreconnect(self, userService: UserService, info: types.connections.ConnectionData) -> None:
|
||||
comms.notifyPreconnect(userService, info)
|
||||
|
||||
def checkUuid(self, userService: UserService) -> bool:
|
||||
@ -716,7 +706,7 @@ class UserServiceManager(metaclass=singleton.Singleton):
|
||||
def getService( # pylint: disable=too-many-locals, too-many-branches, too-many-statements
|
||||
self,
|
||||
user: User,
|
||||
os: DetectedOsInfo,
|
||||
os: 'types.os.DetectedOsInfo',
|
||||
srcIp: str,
|
||||
idService: str,
|
||||
idTransport: typing.Optional[str],
|
||||
@ -743,7 +733,7 @@ class UserServiceManager(metaclass=singleton.Singleton):
|
||||
)
|
||||
|
||||
# Early log of "access try" so we can imagine what is going on
|
||||
userService.setConnectionSource(types.connections.ConnectionSourceType(srcIp, clientHostname or srcIp))
|
||||
userService.setConnectionSource(types.connections.ConnectionSource(srcIp, clientHostname or srcIp))
|
||||
|
||||
if userService.isInMaintenance():
|
||||
raise ServiceInMaintenanceMode()
|
||||
@ -897,7 +887,7 @@ class UserServiceManager(metaclass=singleton.Singleton):
|
||||
self,
|
||||
user: User,
|
||||
srcIp: str,
|
||||
os: DetectedOsInfo,
|
||||
os: 'types.os.DetectedOsInfo',
|
||||
idMetaPool: str,
|
||||
idTransport: str,
|
||||
clientHostName: typing.Optional[str] = None,
|
||||
|
@ -129,7 +129,7 @@ def _requestActor(
|
||||
return js
|
||||
|
||||
|
||||
def notifyPreconnect(userService: 'UserService', info: types.connections.ConnectionDataType) -> None:
|
||||
def notifyPreconnect(userService: 'UserService', info: types.connections.ConnectionData) -> None:
|
||||
"""
|
||||
Notifies a preconnect to an user service
|
||||
"""
|
||||
@ -139,7 +139,7 @@ def notifyPreconnect(userService: 'UserService', info: types.connections.Connect
|
||||
_requestActor(
|
||||
userService,
|
||||
'preConnect',
|
||||
types.connections.PreconnectRequestType(
|
||||
types.connections.PreconnectRequest(
|
||||
user=info.username,
|
||||
protocol=info.protocol,
|
||||
service_type=info.service_type,
|
||||
|
@ -38,8 +38,7 @@ import typing
|
||||
|
||||
from django.utils.translation import gettext_noop as _
|
||||
|
||||
from uds.core import types
|
||||
from uds.core.util import os_detector as OsDetector
|
||||
from uds.core import types, consts
|
||||
from uds.core.module import Module
|
||||
from uds.core.transports import protocols
|
||||
from uds.core.util import net
|
||||
@ -47,7 +46,6 @@ from uds.core.util import net
|
||||
# Not imported at runtime, just for type checking
|
||||
if typing.TYPE_CHECKING:
|
||||
from uds.core.types.request import ExtendedHttpRequestWithUser
|
||||
from uds.core.util.os_detector import DetectedOsInfo
|
||||
from uds.core.environment import Environment
|
||||
from uds import models
|
||||
|
||||
@ -91,7 +89,7 @@ class Transport(Module):
|
||||
# Windows
|
||||
# Macintosh
|
||||
# Linux
|
||||
supportedOss: typing.Tuple = OsDetector.desktopOss # Supported operating systems
|
||||
supportedOss: typing.Tuple = consts.os.desktopOss # Supported operating systems
|
||||
|
||||
# If this transport is visible via Web, via Thin Client or both
|
||||
webTransport: bool = False
|
||||
@ -165,7 +163,7 @@ class Transport(Module):
|
||||
return False
|
||||
|
||||
@classmethod
|
||||
def supportsOs(cls, osType: OsDetector.KnownOS) -> bool:
|
||||
def supportsOs(cls, osType: types.os.KnownOS) -> bool:
|
||||
"""
|
||||
Helper method to check if transport supports requested operating system.
|
||||
Class method
|
||||
@ -184,7 +182,7 @@ class Transport(Module):
|
||||
userService: typing.Union['models.UserService', 'models.ServicePool'],
|
||||
user: 'models.User',
|
||||
password: str,
|
||||
) -> types.connections.ConnectionDataType:
|
||||
) -> types.connections.ConnectionData:
|
||||
"""
|
||||
This method must provide information about connection.
|
||||
We don't have to implement it, but if we wont to allow some types of connections
|
||||
@ -208,7 +206,7 @@ class Transport(Module):
|
||||
username, password = userService.processUserPassword(user.name, password)
|
||||
else:
|
||||
username = self.processedUser(userService, user)
|
||||
return types.connections.ConnectionDataType(
|
||||
return types.connections.ConnectionData(
|
||||
protocol=self.protocol,
|
||||
username=username,
|
||||
service_type=types.services.ServiceType.VDI,
|
||||
@ -229,7 +227,7 @@ class Transport(Module):
|
||||
userService: 'models.UserService',
|
||||
transport: 'models.Transport',
|
||||
ip: str,
|
||||
os: 'DetectedOsInfo', # pylint: disable=redefined-outer-name
|
||||
os: 'types.os.DetectedOsInfo', # pylint: disable=redefined-outer-name
|
||||
user: 'models.User',
|
||||
password: str,
|
||||
request: 'ExtendedHttpRequestWithUser',
|
||||
@ -263,7 +261,7 @@ class Transport(Module):
|
||||
userService: 'models.UserService',
|
||||
transport: 'models.Transport',
|
||||
ip: str,
|
||||
os: 'DetectedOsInfo', # pylint: disable=redefined-outer-name
|
||||
os: 'types.os.DetectedOsInfo', # pylint: disable=redefined-outer-name
|
||||
user: 'models.User',
|
||||
password: str,
|
||||
request: 'ExtendedHttpRequestWithUser',
|
||||
@ -324,7 +322,7 @@ class Transport(Module):
|
||||
userService: 'models.UserService',
|
||||
transport: 'models.Transport',
|
||||
ip: str,
|
||||
os: 'DetectedOsInfo', # pylint: disable=redefined-outer-name
|
||||
os: 'types.os.DetectedOsInfo', # pylint: disable=redefined-outer-name
|
||||
user: 'models.User',
|
||||
password: str,
|
||||
request: 'ExtendedHttpRequestWithUser',
|
||||
|
@ -35,7 +35,7 @@ from .services import ServiceType
|
||||
|
||||
|
||||
# For requests to actors/servers
|
||||
class PreconnectRequestType(typing.NamedTuple):
|
||||
class PreconnectRequest(typing.NamedTuple):
|
||||
"""
|
||||
Information sent on a preconnect request
|
||||
"""
|
||||
@ -55,7 +55,7 @@ class PreconnectRequestType(typing.NamedTuple):
|
||||
|
||||
|
||||
# For requests to actors/servers
|
||||
class AssignRequestType(typing.NamedTuple):
|
||||
class AssignRequest(typing.NamedTuple):
|
||||
udsuser: str
|
||||
udsuser_uuid: str
|
||||
userservice_uuid: str # UUID of userservice
|
||||
@ -66,7 +66,7 @@ class AssignRequestType(typing.NamedTuple):
|
||||
return self._asdict()
|
||||
|
||||
|
||||
class ConnectionDataType(typing.NamedTuple):
|
||||
class ConnectionData(typing.NamedTuple):
|
||||
"""
|
||||
Connection data provided by transports, and contains all the "transformable" information needed to connect to a service
|
||||
(such as username, password, domain, etc..)
|
||||
@ -87,7 +87,7 @@ class ConnectionDataType(typing.NamedTuple):
|
||||
return self._asdict()
|
||||
|
||||
|
||||
class ConnectionSourceType(typing.NamedTuple):
|
||||
class ConnectionSource(typing.NamedTuple):
|
||||
"""
|
||||
Connection source from where the connection is being done
|
||||
"""
|
||||
|
@ -35,9 +35,6 @@ import re
|
||||
import logging
|
||||
import typing
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DetectedOsInfo(typing.NamedTuple):
|
||||
os: 'KnownOS'
|
||||
browser: 'KnownBrowser'
|
||||
@ -62,17 +59,6 @@ class KnownOS(enum.Enum):
|
||||
def __str__(self):
|
||||
return self.os_name()
|
||||
|
||||
|
||||
knownOss = tuple(os for os in KnownOS if os != KnownOS.UNKNOWN)
|
||||
|
||||
allOss = knownOss + (KnownOS.UNKNOWN,)
|
||||
desktopOss = (KnownOS.LINUX, KnownOS.WINDOWS, KnownOS.MAC_OS)
|
||||
mobileOss = list(set(allOss) - set(desktopOss))
|
||||
|
||||
|
||||
DEFAULT_OS = KnownOS.WINDOWS
|
||||
|
||||
|
||||
class KnownBrowser(enum.StrEnum):
|
||||
# Known browsers
|
||||
FIREFOX = 'Firefox'
|
||||
@ -85,37 +71,3 @@ class KnownBrowser(enum.StrEnum):
|
||||
EDGE = 'Edge'
|
||||
OTHER = 'Other'
|
||||
|
||||
|
||||
knownBrowsers = tuple(KnownBrowser)
|
||||
|
||||
browsersREs: typing.Dict[KnownBrowser, typing.Tuple] = {
|
||||
KnownBrowser.FIREFOX: (re.compile(r'Firefox/([0-9.]+)'),),
|
||||
KnownBrowser.SEAMONKEY: (re.compile(r'Seamonkey/([0-9.]+)'),),
|
||||
KnownBrowser.CHROME: (re.compile(r'Chrome/([0-9.]+)'),),
|
||||
KnownBrowser.CHROMIUM: (re.compile(r'Chromium/([0-9.]+)'),),
|
||||
KnownBrowser.SAFARI: (re.compile(r'Safari/([0-9.]+)'),),
|
||||
KnownBrowser.OPERA: (
|
||||
re.compile(r'OPR/([0-9.]+)'),
|
||||
re.compile(r'Opera/([0-9.]+)'),
|
||||
),
|
||||
KnownBrowser.IEXPLORER: (
|
||||
re.compile(r';MSIE ([0-9.]+);'),
|
||||
re.compile(r'Trident/.*rv:([0-9.]+)'),
|
||||
),
|
||||
KnownBrowser.EDGE: (re.compile(r'Edg/([0-9.]+)'),),
|
||||
}
|
||||
|
||||
browserRules: typing.Dict[KnownBrowser, typing.Tuple] = {
|
||||
KnownBrowser.EDGE: (KnownBrowser.EDGE, ()),
|
||||
KnownBrowser.CHROME: (KnownBrowser.CHROME, (KnownBrowser.CHROMIUM, KnownBrowser.OPERA)),
|
||||
KnownBrowser.FIREFOX: (KnownBrowser.FIREFOX, (KnownBrowser.SEAMONKEY,)),
|
||||
KnownBrowser.IEXPLORER: (KnownBrowser.IEXPLORER, ()),
|
||||
KnownBrowser.CHROMIUM: (KnownBrowser.CHROMIUM, (KnownBrowser.CHROME,)),
|
||||
KnownBrowser.SAFARI: (
|
||||
KnownBrowser.SAFARI,
|
||||
(KnownBrowser.CHROME, KnownBrowser.CHROMIUM, KnownBrowser.OPERA),
|
||||
),
|
||||
KnownBrowser.SEAMONKEY: (KnownBrowser.SEAMONKEY, (KnownBrowser.FIREFOX,)),
|
||||
KnownBrowser.OPERA: (KnownBrowser.OPERA, ()),
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ import typing
|
||||
from django.http import HttpRequest
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from uds.core.util.os_detector import DetectedOsInfo
|
||||
from uds.core import types
|
||||
from uds.models import User
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@ class ExtendedHttpRequest(HttpRequest):
|
||||
ip: str
|
||||
ip_version: int
|
||||
ip_proxy: str
|
||||
os: 'DetectedOsInfo'
|
||||
os: 'types.os.DetectedOsInfo'
|
||||
user: typing.Optional['User']
|
||||
authorized: bool
|
||||
|
||||
|
@ -34,7 +34,7 @@ import enum
|
||||
|
||||
class ServiceType(enum.StrEnum):
|
||||
VDI = 'VDI'
|
||||
VAPP = 'VApp'
|
||||
VAPP = 'VAPP'
|
||||
|
||||
def asStr(self) -> str:
|
||||
"""Returns the service type as a string"""
|
||||
|
@ -255,6 +255,7 @@ def cached(
|
||||
# compute cache key
|
||||
cacheKey = f'{cachePrefix}-{keyHash.hexdigest()}'
|
||||
|
||||
# Get cache from object, or create a new one (generic, common to all objects)
|
||||
cache = getattr(args[0], 'cache', None) or Cache('functionCache')
|
||||
|
||||
# if cacheTimeout is a function, call it
|
||||
|
@ -35,93 +35,23 @@ import re
|
||||
import logging
|
||||
import typing
|
||||
|
||||
from uds.core import types, consts
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DetectedOsInfo(typing.NamedTuple):
|
||||
os: 'KnownOS'
|
||||
browser: 'KnownBrowser'
|
||||
version: str
|
||||
|
||||
|
||||
class KnownOS(enum.Enum):
|
||||
LINUX = ('Linux', 'armv7l')
|
||||
CHROME_OS = ('CrOS',)
|
||||
WINDOWS_PHONE = ('Windows Phone',)
|
||||
WINDOWS = ('Windows',)
|
||||
MAC_OS = ('MacOsX',)
|
||||
ANDROID = ('Android',)
|
||||
IPAD = ('iPad',) #
|
||||
IPHONE = ('iPhone',) # In fact, these are IOS both, but we can diferentiate them
|
||||
WYSE = ('WYSE',)
|
||||
UNKNOWN = ('Unknown',)
|
||||
|
||||
def os_name(self):
|
||||
return self.value[0].lower()
|
||||
|
||||
knownOss = tuple(os for os in KnownOS if os != KnownOS.UNKNOWN)
|
||||
|
||||
allOss = knownOss + (KnownOS.UNKNOWN,)
|
||||
desktopOss = (KnownOS.LINUX, KnownOS.WINDOWS, KnownOS.MAC_OS)
|
||||
mobileOss = list(set(allOss) - set(desktopOss))
|
||||
|
||||
|
||||
DEFAULT_OS = KnownOS.WINDOWS
|
||||
|
||||
class KnownBrowser(enum.Enum):
|
||||
# Known browsers
|
||||
FIREFOX = 'Firefox'
|
||||
SEAMONKEY = 'Seamonkey'
|
||||
CHROME = 'Chrome'
|
||||
CHROMIUM = 'Chromium'
|
||||
SAFARI = 'Safari'
|
||||
OPERA = 'Opera'
|
||||
IEXPLORER = 'Explorer'
|
||||
EDGE = 'Edge'
|
||||
OTHER = 'Other'
|
||||
|
||||
knownBrowsers = tuple(KnownBrowser)
|
||||
|
||||
browsersREs: typing.Dict[KnownBrowser, typing.Tuple] = {
|
||||
KnownBrowser.FIREFOX: (re.compile(r'Firefox/([0-9.]+)'),),
|
||||
KnownBrowser.SEAMONKEY: (re.compile(r'Seamonkey/([0-9.]+)'),),
|
||||
KnownBrowser.CHROME: (re.compile(r'Chrome/([0-9.]+)'),),
|
||||
KnownBrowser.CHROMIUM: (re.compile(r'Chromium/([0-9.]+)'),),
|
||||
KnownBrowser.SAFARI: (re.compile(r'Safari/([0-9.]+)'),),
|
||||
KnownBrowser.OPERA: (
|
||||
re.compile(r'OPR/([0-9.]+)'),
|
||||
re.compile(r'Opera/([0-9.]+)'),
|
||||
),
|
||||
KnownBrowser.IEXPLORER: (
|
||||
re.compile(r';MSIE ([0-9.]+);'),
|
||||
re.compile(r'Trident/.*rv:([0-9.]+)'),
|
||||
),
|
||||
KnownBrowser.EDGE: (re.compile(r'Edg/([0-9.]+)'),),
|
||||
}
|
||||
|
||||
browserRules: typing.Dict[KnownBrowser, typing.Tuple] = {
|
||||
KnownBrowser.EDGE: (KnownBrowser.EDGE, ()),
|
||||
KnownBrowser.CHROME: (KnownBrowser.CHROME, (KnownBrowser.CHROMIUM, KnownBrowser.OPERA)),
|
||||
KnownBrowser.FIREFOX: (KnownBrowser.FIREFOX, (KnownBrowser.SEAMONKEY,)),
|
||||
KnownBrowser.IEXPLORER: (KnownBrowser.IEXPLORER, ()),
|
||||
KnownBrowser.CHROMIUM: (KnownBrowser.CHROMIUM, (KnownBrowser.CHROME,)),
|
||||
KnownBrowser.SAFARI: (KnownBrowser.SAFARI, (KnownBrowser.CHROME, KnownBrowser.CHROMIUM, KnownBrowser.OPERA)),
|
||||
KnownBrowser.SEAMONKEY: (KnownBrowser.SEAMONKEY, (KnownBrowser.FIREFOX,)),
|
||||
KnownBrowser.OPERA: (KnownBrowser.OPERA, ()),
|
||||
}
|
||||
|
||||
|
||||
def getOsFromUA(
|
||||
ua: typing.Optional[str],
|
||||
) -> DetectedOsInfo:
|
||||
) -> types.os.DetectedOsInfo:
|
||||
"""
|
||||
Basic OS Client detector (very basic indeed :-))
|
||||
"""
|
||||
ua = ua or KnownOS.UNKNOWN.value[0]
|
||||
ua = ua or types.os.KnownOS.UNKNOWN.value[0]
|
||||
|
||||
res = DetectedOsInfo(os=KnownOS.UNKNOWN, browser=KnownBrowser.OTHER, version='0.0')
|
||||
res = types.os.DetectedOsInfo(os=types.os.KnownOS.UNKNOWN, browser=types.os.KnownBrowser.OTHER, version='0.0')
|
||||
found: bool = False
|
||||
for os in knownOss:
|
||||
for os in consts.os.KNOWN_OS_LIST:
|
||||
if found:
|
||||
break
|
||||
for osName in os.value:
|
||||
@ -133,16 +63,16 @@ def getOsFromUA(
|
||||
match = None
|
||||
|
||||
ruleKey, ruleValue = None, None
|
||||
for ruleKey, ruleValue in browserRules.items():
|
||||
for ruleKey, ruleValue in consts.os.browserRules.items():
|
||||
must, mustNot = ruleValue
|
||||
|
||||
for mustRe in browsersREs[must]:
|
||||
for mustRe in consts.os.browsersREs[must]:
|
||||
match = mustRe.search(ua)
|
||||
if match is None:
|
||||
continue
|
||||
# Check against no maching rules
|
||||
for mustNotREs in mustNot:
|
||||
for cre in browsersREs[mustNotREs]:
|
||||
for cre in consts.os.browsersREs[mustNotREs]:
|
||||
if cre.search(ua) is not None:
|
||||
match = None
|
||||
break
|
||||
|
@ -65,8 +65,9 @@ class LogMaintenance(Job):
|
||||
continue
|
||||
|
||||
max_elements = ownerType.get_max_elements()
|
||||
if 0 < max_elements < count: # Negative max elements means "unlimited"
|
||||
if 0 < max_elements < count: # Negative max elements means "unlimited"
|
||||
# We will delete the oldest ones
|
||||
for record in models.Log.objects.filter(owner_id=owner_id, owner_type=owner_type).order_by('created', 'id')[: count - max_elements + 1]:
|
||||
for record in models.Log.objects.filter(owner_id=owner_id, owner_type=owner_type).order_by(
|
||||
'created', 'id'
|
||||
)[: count - max_elements + 1]:
|
||||
record.delete()
|
||||
|
||||
|
@ -4,8 +4,8 @@ import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
import uds.core.types.servers
|
||||
import uds.core.types.os
|
||||
import uds.core.util.model
|
||||
from uds.core.util.os_detector import KnownOS
|
||||
|
||||
from .fixers import properties_v4, transports_v4, providers_v4
|
||||
|
||||
@ -27,7 +27,7 @@ def migrate_old_data(apps, schema_editor) -> None:
|
||||
server.save(update_fields=['uuid'])
|
||||
|
||||
# Current Registered servers are tunnel servers, and all tunnel servers are linux os, so update ip
|
||||
Server.objects.all().update(os_type=KnownOS.LINUX.os_name())
|
||||
Server.objects.all().update(os_type=uds.core.types.os.KnownOS.LINUX.os_name())
|
||||
|
||||
# Now append actors to registered servers, with "unknown" os type (legacy)
|
||||
for token in ActorToken.objects.all():
|
||||
@ -39,7 +39,7 @@ def migrate_old_data(apps, schema_editor) -> None:
|
||||
token=token.token,
|
||||
stamp=token.stamp,
|
||||
type=ACTOR_TYPE,
|
||||
os_type=KnownOS.UNKNOWN.os_name(),
|
||||
os_type=uds.core.types.os.KnownOS.UNKNOWN.os_name(),
|
||||
data={
|
||||
'mac': token.mac,
|
||||
'pre_command': token.pre_command,
|
||||
|
@ -38,7 +38,7 @@ import dns.reversename
|
||||
|
||||
from uds.core import types, consts
|
||||
from uds.core.environment import Environment
|
||||
from uds.core.util import os_detector, validators
|
||||
from uds.core.util import validators
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -106,7 +106,7 @@ def migrate(
|
||||
username='migration',
|
||||
ip_from=svr[0],
|
||||
ip=svr[0],
|
||||
os_type=os_detector.KnownOS.WINDOWS.os_name(),
|
||||
os_type=types.os.KnownOS.WINDOWS.os_name(),
|
||||
hostname=svr[1],
|
||||
listen_port=0,
|
||||
type=types.servers.ServerType.UNMANAGED,
|
||||
|
@ -39,7 +39,6 @@ from uds.core.consts import MAC_UNKNOWN, MAX_DNS_NAME_LENGTH, MAX_IPV6_LENGTH, S
|
||||
from uds.core.types.request import ExtendedHttpRequest
|
||||
from uds.core.util import log, net, properties, resolver
|
||||
from uds.core.util.model import getSqlStamp, getSqlDatetime
|
||||
from uds.core.util.os_detector import KnownOS
|
||||
|
||||
from .tag import TaggingMixin
|
||||
from .uuid_model import UUIDModel
|
||||
@ -174,7 +173,7 @@ class Server(UUIDModel, TaggingMixin, properties.PropertiesMixin):
|
||||
locked_until = models.DateTimeField(null=True, blank=True, default=None, db_index=True)
|
||||
|
||||
# os type of server (linux, windows, etc..)
|
||||
os_type = models.CharField(max_length=32, default=KnownOS.UNKNOWN.os_name())
|
||||
os_type = models.CharField(max_length=32, default=types.os.KnownOS.UNKNOWN.os_name())
|
||||
# mac address of registered server, if any. Important for VDI actor servers mainly, informative for others
|
||||
mac = models.CharField(max_length=32, default=MAC_UNKNOWN, db_index=True)
|
||||
# certificate of server, if any. VDI Actors will have it's certificate on a property of the userService
|
||||
@ -372,14 +371,10 @@ class Server(UUIDModel, TaggingMixin, properties.PropertiesMixin):
|
||||
"""
|
||||
path = path or ''
|
||||
|
||||
if not path.startswith('/'):
|
||||
path = '/' + path
|
||||
path = path.lstrip('/') # Remove leading slashes
|
||||
pre, post = ('[', ']') if self.ip_version == 6 else ('', '')
|
||||
|
||||
path = f'/{self.server_type.path()}{path}'
|
||||
|
||||
if self.ip_version == 4:
|
||||
return f'https://{self.ip}:{self.listen_port}{path}'
|
||||
return f'https://[{self.ip}]:{self.listen_port}{path}'
|
||||
return f'https://{pre}{self.ip}{post}:{self.listen_port}/{self.server_type.path()}/v1/{path}'
|
||||
|
||||
def __str__(self):
|
||||
return f'<RegisterdServer {self.token} of type {self.server_type.name} created on {self.stamp} by {self.username} from {self.ip}/{self.hostname}>'
|
||||
|
@ -35,7 +35,7 @@ import typing
|
||||
|
||||
from django.db import models
|
||||
|
||||
from uds.core import transports
|
||||
from uds.core import transports, types
|
||||
|
||||
from uds.core.util import net
|
||||
|
||||
@ -45,7 +45,6 @@ from .tag import TaggingMixin
|
||||
# Not imported at runtime, just for type checking
|
||||
if typing.TYPE_CHECKING:
|
||||
from uds.models import Network, ServicePool
|
||||
from uds.core.util.os_detector import KnownOS
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -138,7 +137,7 @@ class Transport(ManagedObjectModel, TaggingMixin):
|
||||
# Deny, must not be in any network
|
||||
return not exists
|
||||
|
||||
def isValidForOs(self, os: 'KnownOS') -> bool:
|
||||
def isValidForOs(self, os: 'types.os.KnownOS') -> bool:
|
||||
"""If this transport is configured to be valid for the specified OS.
|
||||
|
||||
Args:
|
||||
|
@ -302,7 +302,7 @@ class UserService(UUIDModel, properties.PropertiesMixin):
|
||||
val = typing.cast(str, self.getEnvironment().storage.get(name))
|
||||
return val
|
||||
|
||||
def setConnectionSource(self, src: types.connections.ConnectionSourceType) -> None:
|
||||
def setConnectionSource(self, src: types.connections.ConnectionSource) -> None:
|
||||
"""
|
||||
Notifies that the last access to this service was initiated from provided params
|
||||
|
||||
@ -325,7 +325,7 @@ class UserService(UUIDModel, properties.PropertiesMixin):
|
||||
|
||||
self.save(update_fields=['src_ip', 'src_hostname'])
|
||||
|
||||
def getConnectionSource(self) -> types.connections.ConnectionSourceType:
|
||||
def getConnectionSource(self) -> types.connections.ConnectionSource:
|
||||
"""
|
||||
Returns stored connection source data (ip & hostname)
|
||||
|
||||
@ -334,7 +334,7 @@ class UserService(UUIDModel, properties.PropertiesMixin):
|
||||
|
||||
:note: If the transport did not notified this data, this may be "empty"
|
||||
"""
|
||||
return types.connections.ConnectionSourceType(
|
||||
return types.connections.ConnectionSource(
|
||||
self.src_ip or '0.0.0.0', # nosec: not a binding address
|
||||
self.src_hostname or 'unknown',
|
||||
)
|
||||
|
@ -39,13 +39,12 @@ from django.utils.translation import gettext_noop as _
|
||||
from uds import models
|
||||
from uds.core import transports, types, ui, consts
|
||||
from uds.core.managers.crypto import CryptoManager
|
||||
from uds.core.util import fields, os_detector
|
||||
from uds.core.util import fields
|
||||
from uds.core.util.model import getSqlDatetime
|
||||
|
||||
# Not imported at runtime, just for type checking
|
||||
if typing.TYPE_CHECKING:
|
||||
from uds.core.module import Module
|
||||
from uds.core.util.os_detector import DetectedOsInfo
|
||||
from uds.core.types.request import ExtendedHttpRequestWithUser
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -64,7 +63,7 @@ class HTML5RDPTransport(transports.Transport):
|
||||
iconFile = 'html5.png'
|
||||
|
||||
ownLink = True
|
||||
supportedOss = os_detector.allOss
|
||||
supportedOss = consts.os.ALL_OS_LIST
|
||||
protocol = transports.protocols.RDP
|
||||
group = transports.TUNNELED_GROUP
|
||||
|
||||
@ -318,7 +317,7 @@ class HTML5RDPTransport(transports.Transport):
|
||||
userService: typing.Union['models.UserService', 'models.ServicePool'],
|
||||
user: 'models.User',
|
||||
password: str,
|
||||
) -> types.connections.ConnectionDataType:
|
||||
) -> types.connections.ConnectionData:
|
||||
username = user.getUsernameForAuth()
|
||||
|
||||
# Maybe this is called from another provider, as for example WYSE, that need all connections BEFORE
|
||||
@ -365,7 +364,7 @@ class HTML5RDPTransport(transports.Transport):
|
||||
# Fix username/password acording to os manager
|
||||
username, password = userService.processUserPassword(username, password)
|
||||
|
||||
return types.connections.ConnectionDataType(
|
||||
return types.connections.ConnectionData(
|
||||
protocol=self.protocol,
|
||||
username=username,
|
||||
service_type=types.services.ServiceType.VDI,
|
||||
@ -378,7 +377,7 @@ class HTML5RDPTransport(transports.Transport):
|
||||
userService: 'models.UserService',
|
||||
transport: 'models.Transport',
|
||||
ip: str,
|
||||
os: 'DetectedOsInfo', # pylint: disable=unused-argument
|
||||
os: 'types.os.DetectedOsInfo', # pylint: disable=unused-argument
|
||||
user: 'models.User',
|
||||
password: str,
|
||||
request: 'ExtendedHttpRequestWithUser', # pylint: disable=unused-argument
|
||||
|
@ -36,17 +36,16 @@ import typing
|
||||
from django.utils.translation import gettext_noop as _
|
||||
|
||||
from uds import models
|
||||
from uds.core import transports, types
|
||||
from uds.core import consts, transports, types
|
||||
from uds.core.managers.crypto import CryptoManager
|
||||
from uds.core.ui import gui
|
||||
from uds.core.util import fields, os_detector
|
||||
from uds.core.util import fields
|
||||
|
||||
from ..HTML5RDP.html5rdp import HTML5RDPTransport
|
||||
|
||||
# Not imported at runtime, just for type checking
|
||||
if typing.TYPE_CHECKING:
|
||||
from uds.core.module import Module
|
||||
from uds.core.util.os_detector import DetectedOsInfo
|
||||
from uds.core.types.request import ExtendedHttpRequestWithUser
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -65,7 +64,7 @@ class HTML5SSHTransport(transports.Transport):
|
||||
iconFile = 'html5ssh.png'
|
||||
|
||||
ownLink = True
|
||||
supportedOss = os_detector.allOss
|
||||
supportedOss = consts.os.ALL_OS_LIST
|
||||
# pylint: disable=no-member # ??? SSH is there, but pylint does not see it ???
|
||||
protocol = transports.protocols.SSH
|
||||
group = transports.TUNNELED_GROUP
|
||||
@ -177,7 +176,7 @@ class HTML5SSHTransport(transports.Transport):
|
||||
userService: 'models.UserService', # pylint: disable=unused-argument
|
||||
transport: 'models.Transport',
|
||||
ip: str,
|
||||
os: 'DetectedOsInfo', # pylint: disable=unused-argument
|
||||
os: 'types.os.DetectedOsInfo', # pylint: disable=unused-argument
|
||||
user: 'models.User', # pylint: disable=unused-argument
|
||||
password: str, # pylint: disable=unused-argument
|
||||
request: 'ExtendedHttpRequestWithUser', # pylint: disable=unused-argument
|
||||
|
@ -36,17 +36,16 @@ import typing
|
||||
from django.utils.translation import gettext_noop as _
|
||||
|
||||
from uds import models
|
||||
from uds.core import transports, types
|
||||
from uds.core import consts, transports, types
|
||||
from uds.core.managers.crypto import CryptoManager
|
||||
from uds.core.ui import gui
|
||||
from uds.core.util import fields, os_detector
|
||||
from uds.core.util import fields
|
||||
|
||||
from ..HTML5RDP.html5rdp import HTML5RDPTransport
|
||||
|
||||
# Not imported at runtime, just for type checking
|
||||
if typing.TYPE_CHECKING:
|
||||
from uds.core.module import Module
|
||||
from uds.core.util.os_detector import DetectedOsInfo
|
||||
from uds.core.types.request import ExtendedHttpRequestWithUser
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -66,7 +65,7 @@ class HTML5VNCTransport(transports.Transport):
|
||||
iconFile = 'html5vnc.png'
|
||||
|
||||
ownLink = True
|
||||
supportedOss = os_detector.allOss
|
||||
supportedOss = consts.os.ALL_OS_LIST
|
||||
protocol = transports.protocols.VNC
|
||||
group = transports.TUNNELED_GROUP
|
||||
experimental = True
|
||||
@ -161,7 +160,7 @@ class HTML5VNCTransport(transports.Transport):
|
||||
userService: 'models.UserService',
|
||||
transport: 'models.Transport',
|
||||
ip: str,
|
||||
os: 'DetectedOsInfo',
|
||||
os: 'types.os.DetectedOsInfo',
|
||||
user: 'models.User',
|
||||
password: str,
|
||||
request: 'ExtendedHttpRequestWithUser',
|
||||
|
@ -34,7 +34,9 @@ import logging
|
||||
import typing
|
||||
|
||||
from django.utils.translation import gettext_noop as _
|
||||
from uds.core.util import os_detector
|
||||
|
||||
from uds.core import types, consts
|
||||
|
||||
from .rdp_base import BaseRDPTransport
|
||||
from .rdp_file import RDPFile
|
||||
|
||||
@ -102,7 +104,7 @@ class RDPTransport(BaseRDPTransport):
|
||||
userService: 'models.UserService',
|
||||
transport: 'models.Transport',
|
||||
ip: str,
|
||||
os: 'os_detector.DetectedOsInfo',
|
||||
os: 'types.os.DetectedOsInfo',
|
||||
user: 'models.User',
|
||||
password: str,
|
||||
request: 'ExtendedHttpRequestWithUser',
|
||||
@ -155,7 +157,7 @@ class RDPTransport(BaseRDPTransport):
|
||||
'address': r.address,
|
||||
}
|
||||
|
||||
if os.os == os_detector.KnownOS.WINDOWS:
|
||||
if os.os == types.os.KnownOS.WINDOWS:
|
||||
r.customParameters = self.customParametersWindows.value
|
||||
if password:
|
||||
r.password = '{password}' # nosec: password is not hardcoded
|
||||
@ -165,7 +167,7 @@ class RDPTransport(BaseRDPTransport):
|
||||
'optimize_teams': self.optimizeTeams.isTrue(),
|
||||
}
|
||||
)
|
||||
elif os.os == os_detector.KnownOS.LINUX:
|
||||
elif os.os == types.os.KnownOS.LINUX:
|
||||
r.customParameters = self.customParameters.value
|
||||
sp.update(
|
||||
{
|
||||
@ -173,7 +175,7 @@ class RDPTransport(BaseRDPTransport):
|
||||
'address': r.address,
|
||||
}
|
||||
)
|
||||
elif os.os == os_detector.KnownOS.MAC_OS:
|
||||
elif os.os == types.os.KnownOS.MAC_OS:
|
||||
r.customParameters = self.customParametersMAC.value
|
||||
sp.update(
|
||||
{
|
||||
|
@ -356,7 +356,7 @@ class BaseRDPTransport(transports.Transport):
|
||||
password: str,
|
||||
*,
|
||||
altUsername: typing.Optional[str]
|
||||
) -> types.connections.ConnectionDataType:
|
||||
) -> types.connections.ConnectionData:
|
||||
username: str = altUsername or user.getUsernameForAuth()
|
||||
|
||||
if self.fixedName.value:
|
||||
@ -405,7 +405,7 @@ class BaseRDPTransport(transports.Transport):
|
||||
if self.optimizeTeams.isTrue():
|
||||
password = '' # nosec
|
||||
|
||||
return types.connections.ConnectionDataType(
|
||||
return types.connections.ConnectionData(
|
||||
protocol=self.protocol,
|
||||
username=username,
|
||||
service_type=types.services.ServiceType.VDI,
|
||||
@ -418,7 +418,7 @@ class BaseRDPTransport(transports.Transport):
|
||||
userService: typing.Union['models.UserService', 'models.ServicePool'],
|
||||
user: 'models.User',
|
||||
password: str,
|
||||
) -> types.connections.ConnectionDataType:
|
||||
) -> types.connections.ConnectionData:
|
||||
username = None
|
||||
if isinstance(userService, UserService):
|
||||
cdata = userService.getInstance().getConnectionData()
|
||||
|
@ -37,8 +37,7 @@ import urllib.parse
|
||||
import shlex
|
||||
import typing
|
||||
|
||||
from uds.core.util import os_detector as OsDetector
|
||||
|
||||
from uds.core import types
|
||||
|
||||
class RDPFile:
|
||||
fullScreen = False
|
||||
@ -79,7 +78,7 @@ class RDPFile:
|
||||
width: typing.Union[str, int],
|
||||
height: typing.Union[str, int],
|
||||
bpp: str,
|
||||
target: OsDetector.KnownOS = OsDetector.KnownOS.WINDOWS,
|
||||
target: types.os.KnownOS = types.os.KnownOS.WINDOWS,
|
||||
):
|
||||
self.width = str(width)
|
||||
self.height = str(height)
|
||||
@ -89,9 +88,9 @@ class RDPFile:
|
||||
|
||||
def get(self):
|
||||
if self.target in (
|
||||
OsDetector.KnownOS.WINDOWS,
|
||||
OsDetector.KnownOS.LINUX,
|
||||
OsDetector.KnownOS.MAC_OS,
|
||||
types.os.KnownOS.WINDOWS,
|
||||
types.os.KnownOS.LINUX,
|
||||
types.os.KnownOS.MAC_OS,
|
||||
):
|
||||
return self.getGeneric()
|
||||
# Unknown target
|
||||
@ -121,7 +120,7 @@ class RDPFile:
|
||||
params.append('/smartcard')
|
||||
|
||||
if self.redirectAudio:
|
||||
if self.alsa and self.target != OsDetector.KnownOS.MAC_OS:
|
||||
if self.alsa and self.target != types.os.KnownOS.MAC_OS:
|
||||
params.append('/sound:sys:alsa,format:1,quality:high')
|
||||
params.append('/microphone:sys:alsa')
|
||||
else:
|
||||
@ -133,7 +132,7 @@ class RDPFile:
|
||||
params.append('/video')
|
||||
|
||||
if self.redirectDrives != 'false':
|
||||
if self.target in (OsDetector.KnownOS.LINUX, OsDetector.KnownOS.MAC_OS):
|
||||
if self.target in (types.os.KnownOS.LINUX, types.os.KnownOS.MAC_OS):
|
||||
params.append('/drive:home,$HOME')
|
||||
else:
|
||||
params.append('/drive:Users,/Users')
|
||||
@ -159,7 +158,7 @@ class RDPFile:
|
||||
params.append('/multimon')
|
||||
|
||||
if self.fullScreen:
|
||||
if self.target != OsDetector.KnownOS.MAC_OS:
|
||||
if self.target != types.os.KnownOS.MAC_OS:
|
||||
params.append('/f')
|
||||
else: # On mac, will fix this later...
|
||||
params.append('/w:#WIDTH#')
|
||||
@ -194,7 +193,7 @@ class RDPFile:
|
||||
params += shlex.split(self.customParameters.strip())
|
||||
|
||||
# On MacOSX, /rfx /gfx:rfx are almost inprescindible, as it seems the only way to get a decent performance
|
||||
if self.target == OsDetector.KnownOS.MAC_OS:
|
||||
if self.target == types.os.KnownOS.MAC_OS:
|
||||
for i in ('/rfx', '/gfx:rfx'):
|
||||
if i not in params:
|
||||
params.append(i)
|
||||
@ -234,7 +233,7 @@ class RDPFile:
|
||||
if self.username:
|
||||
res += 'username:s:' + self.username + '\n'
|
||||
res += 'domain:s:' + self.domain + '\n'
|
||||
if self.target == OsDetector.KnownOS.WINDOWS and not self.optimizeTeams:
|
||||
if self.target == types.os.KnownOS.WINDOWS and not self.optimizeTeams:
|
||||
res += 'password 51:b:' + password + '\n'
|
||||
|
||||
res += 'alternate shell:s:' + '\n'
|
||||
@ -300,7 +299,7 @@ class RDPFile:
|
||||
# res += 'camerastoredirect:s:*\n'
|
||||
|
||||
# If target is windows, add customParameters
|
||||
if self.target == OsDetector.KnownOS.WINDOWS:
|
||||
if self.target == types.os.KnownOS.WINDOWS:
|
||||
if self.customParameters and self.customParameters.strip() != '':
|
||||
res += self.customParameters.strip() + '\n'
|
||||
|
||||
|
@ -36,7 +36,7 @@ from django.utils.translation import gettext_noop as _
|
||||
|
||||
from uds.core import transports, types, consts
|
||||
from uds.core.ui import gui
|
||||
from uds.core.util import fields, os_detector, validators
|
||||
from uds.core.util import fields, validators
|
||||
from uds.models import TicketStore
|
||||
|
||||
from .rdp_base import BaseRDPTransport
|
||||
@ -124,7 +124,7 @@ class TRDPTransport(BaseRDPTransport):
|
||||
userService: 'models.UserService',
|
||||
transport: 'models.Transport',
|
||||
ip: str,
|
||||
os: 'os_detector.DetectedOsInfo',
|
||||
os: 'types.os.DetectedOsInfo',
|
||||
user: 'models.User',
|
||||
password: str,
|
||||
request: 'ExtendedHttpRequestWithUser',
|
||||
@ -189,7 +189,7 @@ class TRDPTransport(BaseRDPTransport):
|
||||
'this_server': request.build_absolute_uri('/'),
|
||||
}
|
||||
|
||||
if os.os == os_detector.KnownOS.WINDOWS:
|
||||
if os.os == types.os.KnownOS.WINDOWS:
|
||||
r.customParameters = self.customParametersWindows.value
|
||||
if password:
|
||||
r.password = '{password}' # nosec: password is not hardcoded
|
||||
@ -199,14 +199,14 @@ class TRDPTransport(BaseRDPTransport):
|
||||
'optimize_teams': self.optimizeTeams.isTrue(),
|
||||
}
|
||||
)
|
||||
elif os.os == os_detector.KnownOS.LINUX:
|
||||
elif os.os == types.os.KnownOS.LINUX:
|
||||
r.customParameters = self.customParameters.value
|
||||
sp.update(
|
||||
{
|
||||
'as_new_xfreerdp_params': r.as_new_xfreerdp_params,
|
||||
}
|
||||
)
|
||||
elif os.os == os_detector.KnownOS.MAC_OS:
|
||||
elif os.os == types.os.KnownOS.MAC_OS:
|
||||
r.customParameters = self.customParametersMAC.value
|
||||
sp.update(
|
||||
{
|
||||
|
@ -35,17 +35,16 @@ import typing
|
||||
|
||||
from django.utils.translation import gettext_noop as _
|
||||
|
||||
from uds.core import exceptions
|
||||
from uds.core import exceptions, types
|
||||
|
||||
from .spice_base import BaseSpiceTransport
|
||||
from .remote_viewer_file import RemoteViewerFile
|
||||
from .spice_base import BaseSpiceTransport
|
||||
|
||||
# Not imported at runtime, just for type checking
|
||||
if typing.TYPE_CHECKING:
|
||||
from uds import models
|
||||
from uds.core import transports
|
||||
from uds.core.types.request import ExtendedHttpRequestWithUser
|
||||
from uds.core.util import os_detector
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -77,7 +76,7 @@ class SPICETransport(BaseSpiceTransport):
|
||||
userService: 'models.UserService',
|
||||
transport: 'models.Transport',
|
||||
ip: str,
|
||||
os: 'os_detector.DetectedOsInfo',
|
||||
os: 'types.os.DetectedOsInfo',
|
||||
user: 'models.User',
|
||||
password: str,
|
||||
request: 'ExtendedHttpRequestWithUser',
|
||||
|
@ -199,7 +199,7 @@ class BaseSpiceTransport(transports.Transport):
|
||||
userService: typing.Union['models.UserService', 'models.ServicePool'],
|
||||
user: 'models.User',
|
||||
password: str,
|
||||
) -> types.connections.ConnectionDataType:
|
||||
) -> types.connections.ConnectionData:
|
||||
username = user.getUsernameForAuth()
|
||||
|
||||
if self.fixedName.value:
|
||||
@ -214,7 +214,7 @@ class BaseSpiceTransport(transports.Transport):
|
||||
# Fix username/password acording to os manager
|
||||
username, password = userService.processUserPassword(username, password)
|
||||
|
||||
return types.connections.ConnectionDataType(
|
||||
return types.connections.ConnectionData(
|
||||
protocol=self.protocol,
|
||||
username=username,
|
||||
service_type=types.services.ServiceType.VDI,
|
||||
@ -226,5 +226,5 @@ class BaseSpiceTransport(transports.Transport):
|
||||
userService: typing.Union['models.UserService', 'models.ServicePool'],
|
||||
user: 'models.User',
|
||||
password: str,
|
||||
) -> types.connections.ConnectionDataType:
|
||||
) -> types.connections.ConnectionData:
|
||||
return self.processUserPassword(userService, user, password)
|
||||
|
@ -46,7 +46,6 @@ from .spice_base import BaseSpiceTransport
|
||||
if typing.TYPE_CHECKING:
|
||||
from uds import models
|
||||
from uds.core.module import Module
|
||||
from uds.core.util import os_detector
|
||||
from uds.core.types.request import ExtendedHttpRequestWithUser
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -94,7 +93,7 @@ class TSPICETransport(BaseSpiceTransport):
|
||||
userService: 'models.UserService',
|
||||
transport: 'models.Transport',
|
||||
ip: str,
|
||||
os: 'os_detector.DetectedOsInfo',
|
||||
os: 'types.os.DetectedOsInfo',
|
||||
user: 'models.User',
|
||||
password: str,
|
||||
request: 'ExtendedHttpRequestWithUser',
|
||||
|
@ -38,13 +38,11 @@ from django.utils.translation import gettext_noop as _
|
||||
from uds import models
|
||||
from uds.core import consts, exceptions, transports, types
|
||||
from uds.core.ui import gui
|
||||
from uds.core.util import os_detector as OsDetector
|
||||
|
||||
# Not imported at runtime, just for type checking
|
||||
if typing.TYPE_CHECKING:
|
||||
from uds.core.module import Module
|
||||
from uds.core.types.request import ExtendedHttpRequestWithUser
|
||||
from uds.core.util.os_detector import DetectedOsInfo
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -60,7 +58,7 @@ class TestTransport(transports.Transport):
|
||||
iconFile = 'transport.png'
|
||||
|
||||
ownLink = True
|
||||
supportedOss = OsDetector.allOss
|
||||
supportedOss = consts.os.ALL_OS_LIST
|
||||
protocol = transports.protocols.OTHER
|
||||
group = transports.DIRECT_GROUP
|
||||
|
||||
@ -105,7 +103,7 @@ class TestTransport(transports.Transport):
|
||||
userService: 'models.UserService',
|
||||
transport: 'models.Transport',
|
||||
ip: str,
|
||||
os: 'DetectedOsInfo',
|
||||
os: 'types.os.DetectedOsInfo',
|
||||
user: 'models.User',
|
||||
password: str,
|
||||
request: 'ExtendedHttpRequestWithUser',
|
||||
|
@ -38,12 +38,10 @@ from django.utils.translation import gettext_noop as _
|
||||
from uds import models
|
||||
from uds.core import exceptions, transports, types, consts
|
||||
from uds.core.ui import gui
|
||||
from uds.core.util import os_detector as OsDetector
|
||||
|
||||
# Not imported at runtime, just for type checking
|
||||
if typing.TYPE_CHECKING:
|
||||
from uds.core.module import Module
|
||||
from uds.core.util.os_detector import DetectedOsInfo
|
||||
from uds.core.types.request import ExtendedHttpRequestWithUser
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -61,7 +59,7 @@ class URLCustomTransport(transports.Transport):
|
||||
iconFile = 'url.png'
|
||||
|
||||
ownLink = True
|
||||
supportedOss = OsDetector.allOss
|
||||
supportedOss = consts.os.ALL_OS_LIST
|
||||
protocol = transports.protocols.OTHER
|
||||
group = transports.DIRECT_GROUP
|
||||
|
||||
@ -106,7 +104,7 @@ class URLCustomTransport(transports.Transport):
|
||||
userService: 'models.UserService',
|
||||
transport: 'models.Transport',
|
||||
ip: str,
|
||||
os: 'DetectedOsInfo',
|
||||
os: 'types.os.DetectedOsInfo',
|
||||
user: 'models.User',
|
||||
password: str,
|
||||
request: 'ExtendedHttpRequestWithUser',
|
||||
|
@ -40,9 +40,8 @@ from . import x2go_file
|
||||
# Not imported at runtime, just for type checking
|
||||
if typing.TYPE_CHECKING:
|
||||
from uds import models
|
||||
from uds.core import transports
|
||||
from uds.core import transports, types
|
||||
from uds.core.types.request import ExtendedHttpRequestWithUser
|
||||
from uds.core.util.os_detector import DetectedOsInfo
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -77,7 +76,7 @@ class X2GOTransport(BaseX2GOTransport):
|
||||
userService: 'models.UserService',
|
||||
transport: 'models.Transport',
|
||||
ip: str,
|
||||
os: 'DetectedOsInfo',
|
||||
os: 'types.os.DetectedOsInfo',
|
||||
user: 'models.User',
|
||||
password: str,
|
||||
request: 'ExtendedHttpRequestWithUser',
|
||||
|
@ -43,7 +43,7 @@ from uds.core import consts, transports, types
|
||||
from uds.core.managers.user_service import UserServiceManager
|
||||
from uds.core.types.preferences import CommonPrefs
|
||||
from uds.core.ui import gui
|
||||
from uds.core.util import connection, os_detector
|
||||
from uds.core.util import connection
|
||||
|
||||
# Not imported at runtime, just for type checking
|
||||
if typing.TYPE_CHECKING:
|
||||
@ -65,7 +65,7 @@ class BaseX2GOTransport(transports.Transport):
|
||||
|
||||
iconFile = 'x2go.png'
|
||||
protocol = transports.protocols.X2GO
|
||||
supportedOss = (os_detector.KnownOS.LINUX, os_detector.KnownOS.WINDOWS)
|
||||
supportedOss = (types.os.KnownOS.LINUX, types.os.KnownOS.WINDOWS)
|
||||
|
||||
fixedName = gui.TextField(
|
||||
order=2,
|
||||
@ -227,7 +227,7 @@ class BaseX2GOTransport(transports.Transport):
|
||||
userService: typing.Union['models.UserService', 'models.ServicePool'],
|
||||
user: 'models.User',
|
||||
password: str,
|
||||
) -> types.connections.ConnectionDataType:
|
||||
) -> types.connections.ConnectionData:
|
||||
username = user.getUsernameForAuth()
|
||||
|
||||
# Get the type of service (VDI, VAPP, ...)
|
||||
@ -244,7 +244,7 @@ class BaseX2GOTransport(transports.Transport):
|
||||
# Fix username/password acording to os manager
|
||||
username, password = userService.processUserPassword(username, password)
|
||||
|
||||
return types.connections.ConnectionDataType(
|
||||
return types.connections.ConnectionData(
|
||||
protocol=self.protocol,
|
||||
username=username,
|
||||
service_type=servicesTypeProvided,
|
||||
@ -256,7 +256,7 @@ class BaseX2GOTransport(transports.Transport):
|
||||
userService: typing.Union['models.UserService', 'models.ServicePool'],
|
||||
user: 'models.User',
|
||||
password: str,
|
||||
) -> types.connections.ConnectionDataType:
|
||||
) -> types.connections.ConnectionData:
|
||||
return self.processUserPassword(userService, user, password)
|
||||
|
||||
def genKeyPairForSsh(self) -> typing.Tuple[str, str]:
|
||||
|
@ -46,7 +46,6 @@ from .x2go_base import BaseX2GOTransport
|
||||
if typing.TYPE_CHECKING:
|
||||
from uds import models
|
||||
from uds.core.module import Module
|
||||
from uds.core.util.os_detector import DetectedOsInfo
|
||||
from uds.core.types.request import ExtendedHttpRequestWithUser
|
||||
|
||||
|
||||
@ -100,7 +99,7 @@ class TX2GOTransport(BaseX2GOTransport):
|
||||
userService: 'models.UserService',
|
||||
transport: 'models.Transport',
|
||||
ip: str,
|
||||
os: 'DetectedOsInfo',
|
||||
os: 'types.os.DetectedOsInfo',
|
||||
user: 'models.User',
|
||||
password: str,
|
||||
request: 'ExtendedHttpRequestWithUser',
|
||||
|
@ -52,7 +52,6 @@ from uds.web.util import errors
|
||||
|
||||
# Not imported at runtime, just for type checking
|
||||
if typing.TYPE_CHECKING:
|
||||
from uds.core.util.os_detector import KnownOS
|
||||
from uds.core.types.request import ExtendedHttpRequestWithUser
|
||||
from uds.models import Image
|
||||
|
||||
@ -133,7 +132,7 @@ def getServicesData(
|
||||
nets = ''
|
||||
validTrans = ''
|
||||
|
||||
osType: 'KnownOS' = request.os.os
|
||||
osType: 'types.os.KnownOS' = request.os.os
|
||||
logger.debug('OS: %s', osType)
|
||||
|
||||
if request.user.isStaff():
|
||||
|
@ -344,7 +344,7 @@ def update_transport_ticket(
|
||||
uuid=data['ticket-info'].get('userService', None)
|
||||
)
|
||||
UserServiceManager().notifyPreconnect(
|
||||
userService, types.connections.ConnectionDataType(
|
||||
userService, types.connections.ConnectionData(
|
||||
username=username,
|
||||
protocol=data.get('protocol', ''),
|
||||
service_type=data['ticket-info'].get('service_type', ''),
|
||||
|
Loading…
Reference in New Issue
Block a user