From ec89a2cfa8e094284529a000f3370e4113db523f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Sat, 6 Aug 2022 19:23:51 +0200 Subject: [PATCH] adding session id to uds actor --- actor/src/actor_client.py | 2 +- actor/src/udsactor/rest.py | 14 +++++++++++--- actor/src/udsactor/types.py | 3 ++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/actor/src/actor_client.py b/actor/src/actor_client.py index 6a4d44b0..9edbe857 100755 --- a/actor/src/actor_client.py +++ b/actor/src/actor_client.py @@ -54,7 +54,7 @@ if __name__ == "__main__": qApp = UDSClientQApp(sys.argv) - if 'linux' not in sys.platform: + if 'win' in sys.platform: # The "hidden window" is only needed to process events on Windows # Not needed on Linux mw = QMainWindow() diff --git a/actor/src/udsactor/rest.py b/actor/src/udsactor/rest.py index 37e50076..86dfe48a 100644 --- a/actor/src/udsactor/rest.py +++ b/actor/src/udsactor/rest.py @@ -131,7 +131,7 @@ class UDSApi: # pylint: disable=too-few-public-methods headers=headers, verify=self._validateCert, timeout=TIMEOUT, - proxies=NO_PROXY # type: ignore + proxies=NO_PROXY # type: ignore if disableProxy else None, # if not proxies wanted, enforce it ) @@ -329,7 +329,11 @@ class UDSServerApi(UDSApi): ) -> types.LoginResultInfoType: if not token: return types.LoginResultInfoType( - ip='0.0.0.0', hostname=UNKNOWN, dead_line=None, max_idle=None # nosec: this is not a binding + ip='0.0.0.0', # nosec: this is not a binding + hostname=UNKNOWN, + dead_line=None, + max_idle=None, + session_id=None, ) payload = { 'type': actor_type or types.MANAGED, @@ -340,11 +344,12 @@ class UDSServerApi(UDSApi): 'secret': secret or '', } result = self._doPost('login', payload) - return types.LoginResultInfoType( + return types.LoginResultInfoType( # nosec: this is not a binding ip=result['ip'], hostname=result['hostname'], dead_line=result['dead_line'], max_idle=result['max_idle'], + session_id=result['session_id'], ) def logout( @@ -352,6 +357,7 @@ class UDSServerApi(UDSApi): actor_type: typing.Optional[str], token: str, username: str, + session_id: typing.Optional[str], interfaces: typing.Iterable[types.InterfaceInfoType], secret: typing.Optional[str], ) -> None: @@ -362,6 +368,7 @@ class UDSServerApi(UDSApi): 'id': [{'mac': i.mac, 'ip': i.ip} for i in interfaces], 'token': token, 'username': username, + 'session_id': session_id or '', 'secret': secret or '', } self._doPost('logout', payload) @@ -417,6 +424,7 @@ class UDSClientApi(UDSApi): hostname=result['hostname'], dead_line=result['dead_line'], max_idle=result['max_idle'], + session_id=result['session_id'], ) def logout(self, username: str) -> None: diff --git a/actor/src/udsactor/types.py b/actor/src/udsactor/types.py index bed835c8..f1592304 100644 --- a/actor/src/udsactor/types.py +++ b/actor/src/udsactor/types.py @@ -57,7 +57,8 @@ class LoginResultInfoType(typing.NamedTuple): ip: str hostname: str dead_line: typing.Optional[int] - max_idle: typing.Optional[int] # Not provided by broker + max_idle: typing.Optional[int] + session_id: typing.Optional[str] class CertificateInfoType(typing.NamedTuple): private_key: str