forked from shaba/openuds
Merge remote-tracking branch 'origin/v3.5' into v3.6
This commit is contained in:
commit
8a150439ae
@ -185,7 +185,8 @@ class UDSActorClient(threading.Thread): # pylint: disable=too-many-instance-att
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# Notify loging and mark it
|
# Notify loging and mark it
|
||||||
self._loginInfo = self.api.login(platform.operations.getCurrentUser(), platform.operations.getSessionType())
|
user, sessionType = platform.operations.getCurrentUser(), platform.operations.getSessionType()
|
||||||
|
self._loginInfo = self.api.login(user, sessionType)
|
||||||
|
|
||||||
if self._loginInfo.max_idle:
|
if self._loginInfo.max_idle:
|
||||||
platform.operations.initIdleDuration(self._loginInfo.max_idle)
|
platform.operations.initIdleDuration(self._loginInfo.max_idle)
|
||||||
@ -197,8 +198,15 @@ class UDSActorClient(threading.Thread): # pylint: disable=too-many-instance-att
|
|||||||
|
|
||||||
time.sleep(1.3) # Sleeps between loop iterations
|
time.sleep(1.3) # Sleeps between loop iterations
|
||||||
|
|
||||||
|
# If login was recognized...
|
||||||
|
if self._loginInfo.logged_in:
|
||||||
|
self.api.logout(user + self._extraLogoff, sessionType)
|
||||||
|
logger.info('Notified logout for %s (%s)', user, sessionType) # Log logout
|
||||||
|
else:
|
||||||
|
logger.info('Logout not notified for %s (%s)', user, sessionType) # Log logout
|
||||||
|
|
||||||
|
# Clean up login info
|
||||||
self._loginInfo = None
|
self._loginInfo = None
|
||||||
self.api.logout(platform.operations.getCurrentUser() + self._extraLogoff, platform.operations.getSessionType())
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error('Error on client loop: %s', e)
|
logger.error('Error on client loop: %s', e)
|
||||||
|
|
||||||
|
@ -58,6 +58,10 @@ class LoginResultInfoType(typing.NamedTuple):
|
|||||||
dead_line: typing.Optional[int]
|
dead_line: typing.Optional[int]
|
||||||
max_idle: typing.Optional[int] # Not provided by broker
|
max_idle: typing.Optional[int] # Not provided by broker
|
||||||
|
|
||||||
|
@property
|
||||||
|
def logged_in(self) -> bool:
|
||||||
|
return self.hostname != '' or self.ip != ''
|
||||||
|
|
||||||
class CertificateInfoType(typing.NamedTuple):
|
class CertificateInfoType(typing.NamedTuple):
|
||||||
private_key: str
|
private_key: str
|
||||||
server_certificate: str
|
server_certificate: str
|
||||||
|
@ -71,10 +71,10 @@ class UserService(UUIDModel): # pylint: disable=too-many-public-methods
|
|||||||
|
|
||||||
# The reference to deployed service is used to accelerate the queries for different methods, in fact its redundant cause we can access to the deployed service
|
# The reference to deployed service is used to accelerate the queries for different methods, in fact its redundant cause we can access to the deployed service
|
||||||
# through publication, but queries are much more simple
|
# through publication, but queries are much more simple
|
||||||
deployed_service: 'models.ForeignKey[UserService, ServicePool]' = models.ForeignKey(
|
deployed_service: 'models.ForeignKey["UserService", ServicePool]' = models.ForeignKey(
|
||||||
ServicePool, on_delete=models.CASCADE, related_name='userServices'
|
ServicePool, on_delete=models.CASCADE, related_name='userServices'
|
||||||
)
|
)
|
||||||
publication: 'models.ForeignKey[UserService, ServicePoolPublication]' = (
|
publication: 'models.ForeignKey["UserService", ServicePoolPublication]' = (
|
||||||
models.ForeignKey(
|
models.ForeignKey(
|
||||||
ServicePoolPublication,
|
ServicePoolPublication,
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
@ -120,7 +120,7 @@ class UserService(UUIDModel): # pylint: disable=too-many-public-methods
|
|||||||
)
|
)
|
||||||
|
|
||||||
# "fake" declarations for type checking
|
# "fake" declarations for type checking
|
||||||
objects: 'models.BaseManager[UserService]'
|
objects: 'models.BaseManager["UserService"]'
|
||||||
properties: 'models.QuerySet[UserServiceProperty]'
|
properties: 'models.QuerySet[UserServiceProperty]'
|
||||||
accounting: 'AccountUsage'
|
accounting: 'AccountUsage'
|
||||||
|
|
||||||
@ -311,7 +311,7 @@ class UserService(UUIDModel): # pylint: disable=too-many-public-methods
|
|||||||
|
|
||||||
:note: If the transport did not notified this data, this may be "empty"
|
:note: If the transport did not notified this data, this may be "empty"
|
||||||
"""
|
"""
|
||||||
return (self.src_ip, self.src_hostname)
|
return (self.src_ip or '0.0.0.0', self.src_hostname or 'unknown')
|
||||||
|
|
||||||
def getOsManager(self) -> typing.Optional['OSManager']:
|
def getOsManager(self) -> typing.Optional['OSManager']:
|
||||||
return self.deployed_service.osmanager
|
return self.deployed_service.osmanager
|
||||||
|
Loading…
Reference in New Issue
Block a user