def getUDSTransportScript( # pylint: disable=too-many-locals self, userService: 'models.UserService', transport: 'models.Transport', ip: str, os: typing.Dict[str, str], user: '******', password: str, request: 'HttpRequest' ) -> typing.Tuple[str, str, typing.Dict[str, typing.Any]]: username = user.getUsernameForAuth() proc = username.split('@') username = proc[0] if self._fixedName: username = self._fixedName if self._fixedPassword: password = self._fixedPassword if self._useEmptyCreds: username, password = '', '' # We have the credentials right now, let os manager width, height = CommonPrefs.getWidthHeight(self._screenSize) # Fix username/password acording to os manager username, password = userService.processUserPassword( username, password) r = NXFile(username=username, password=password, width=width, height=height) r.host = ip r.port = self._listenPort r.linkSpeed = self._connection r.desktop = self._session r.cachedisk = self._cacheDisk r.cachemem = self._cacheMem osName = { OsDetector.Windows: 'windows', OsDetector.Linux: 'linux', OsDetector.Macintosh: 'macosx' }.get(os['OS']) if osName is None: return super().getUDSTransportScript(userService, transport, ip, os, user, password, request) sp = { 'as_file': r.as_file, } return self.getScript('scripts/{}/direct.py', osName, sp)
def getUDSTransportScript( # pylint: disable=too-many-locals self, userService: 'models.UserService', transport: 'models.Transport', ip: str, os: typing.Dict[str, str], user: '******', password: str, request: 'HttpRequest' ) -> typing.Tuple[str, str, typing.Dict[str, typing.Any]]: prefs = self.screenSize.value username = user.getUsernameForAuth() proc = username.split('@') username = proc[0] if self._fixedName is not '': username = self._fixedName if self._fixedPassword is not '': password = self._fixedPassword if self._useEmptyCreds is True: usernamsizerd = '', '' tunpass = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits) for _i in range(12)) tunuser = TicketStore.create(tunpass) sshServer = self._tunnelServer if ':' not in sshServer: sshServer += ':443' sshHost, sshPort = sshServer.split(':') logger.debug('Username generated: %s, password: %s', tunuser, tunpass) width, height = CommonPrefs.getWidthHeight(prefs) # Fix username/password acording to os manager username, password = userService.processUserPassword( username, password) r = NXFile(username=username, password=password, width=width, height=height) r.host = '{address}' r.port = '{port}' r.linkSpeed = self._connection r.desktop = self._session r.cachedisk = self._cacheDisk r.cachemem = self._cacheMem osName = { OsDetector.Windows: 'windows', OsDetector.Linux: 'linux', OsDetector.Macintosh: 'macosx' }.get(os['OS']) if osName is None: return super().getUDSTransportScript(userService, transport, ip, os, user, password, request) sp = { 'ip': ip, 'tunUser': tunuser, 'tunPass': tunpass, 'tunHost': sshHost, 'tunPort': sshPort, 'port': self._listenPort, 'as_file_for_format': r.as_file_for_format } return self.getScript('scripts/{}/direct.py', osName, sp)
def getScreenSize(self) -> typing.Tuple[int, int]: return CommonPrefs.getWidthHeight(self.screenSize.value)
def getUDSTransportScript( # pylint: disable=too-many-locals self, userService: 'models.UserService', transport: 'models.Transport', ip: str, os: typing.Dict[str, str], user: '******', password: str, request: 'HttpRequest', ) -> typing.Tuple[str, str, typing.Mapping[str, typing.Any]]: prefs = self.screenSize.value username = user.getUsernameForAuth() proc = username.split('@') username = proc[0] if self._fixedName is not '': username = self._fixedName if self._fixedPassword is not '': password = self._fixedPassword if self._useEmptyCreds is True: usernamsizerd = '', '' ticket = TicketStore.create_for_tunnel( userService=userService, port=int(self._listenPort), validity=self._tunnelWait + 60, # Ticket overtime ) tunHost, tunPort = self.tunnelServer.value.split(':') width, height = CommonPrefs.getWidthHeight(prefs) # Fix username/password acording to os manager username, password = userService.processUserPassword( username, password) r = NXFile(username=username, password=password, width=width, height=height) r.host = '{address}' r.port = '{port}' r.linkSpeed = self._connection r.desktop = self._session r.cachedisk = self._cacheDisk r.cachemem = self._cacheMem osName = { OsDetector.Windows: 'windows', OsDetector.Linux: 'linux', OsDetector.Macintosh: 'macosx', }.get(os['OS']) if osName is None: return super().getUDSTransportScript(userService, transport, ip, os, user, password, request) sp = { 'ip': ip, 'tunHost': tunHost, 'tunPort': tunPort, 'tunWait': self._tunnelWait, 'tunChk': self._verifyCertificate, 'ticket': ticket, 'as_file_for_format': r.as_file_for_format, } return self.getScript('scripts/{}/tunnel.py', osName, sp)