diff options
author | Devaev Maxim <[email protected]> | 2020-07-23 11:38:27 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-07-23 11:38:27 +0300 |
commit | ca3641c85b4231106acb259c9cdae6fca40e2fef (patch) | |
tree | 880df9fd8f42edfc309aa717f4f18c3042d255e0 /kvmd/apps/vnc/rfb | |
parent | 1d7f949b9e33195ec584382cf9bdb73829341c45 (diff) |
client port
Diffstat (limited to 'kvmd/apps/vnc/rfb')
-rw-r--r-- | kvmd/apps/vnc/rfb/__init__.py | 22 | ||||
-rw-r--r-- | kvmd/apps/vnc/rfb/stream.py | 2 |
2 files changed, 12 insertions, 12 deletions
diff --git a/kvmd/apps/vnc/rfb/__init__.py b/kvmd/apps/vnc/rfb/__init__.py index 96e70895..6deddbb1 100644 --- a/kvmd/apps/vnc/rfb/__init__.py +++ b/kvmd/apps/vnc/rfb/__init__.py @@ -83,7 +83,7 @@ class RfbClient(RfbClientStream): # pylint: disable=too-many-instance-attribute async def _run(self, **coros: Coroutine) -> None: logger = get_logger(0) - logger.info("[entry] [%s]: Starting client tasks ...", self._remote) + logger.info("[entry] %s: Starting client tasks ...", self._remote) tasks = list(map(asyncio.create_task, [ # type: ignore # Я хз, почему github action фейлится здесь self.__wrapper(name, coro) for (name, coro) in {"main": self.__main_task_loop(), **coros}.items() @@ -95,7 +95,7 @@ class RfbClient(RfbClientStream): # pylint: disable=too-many-instance-attribute task.cancel() await asyncio.gather(*tasks, return_exceptions=True) await self._close() - logger.info("[entry] [%s]: Connection closed", self._remote) + logger.info("[entry] %s: Connection closed", self._remote) async def __wrapper(self, name: str, coro: Coroutine) -> None: logger = get_logger(0) @@ -103,14 +103,14 @@ class RfbClient(RfbClientStream): # pylint: disable=too-many-instance-attribute await coro raise RuntimeError("Subtask just finished without any exception") except asyncio.CancelledError: - logger.info("[%s] [%s]: Cancelling subtask ...", name, self._remote) + logger.info("[%s] %s: Cancelling subtask ...", name, self._remote) raise except RfbConnectionError as err: - logger.info("[%s] [%s]: Gone: %s", name, self._remote, err) + logger.info("[%s] %s: Gone: %s", name, self._remote, err) except (RfbError, ssl.SSLError) as err: - logger.error("[%s] [%s]: Error: %s", name, self._remote, err) + logger.error("[%s] %s: Error: %s", name, self._remote, err) except Exception: - logger.exception("[%s] [%s]: Unhandled exception", name, self._remote) + logger.exception("[%s] %s: Unhandled exception", name, self._remote) async def __main_task_loop(self) -> None: await self.__handshake_version() @@ -200,7 +200,7 @@ class RfbClient(RfbClientStream): # pylint: disable=too-many-instance-attribute except ValueError: raise RfbError(f"Invalid version response: {response!r}") self.__rfb_version = (3 if version == 5 else version) - get_logger(0).info("[main] [%s]: Using RFB version 3.%d", self._remote, self.__rfb_version) + get_logger(0).info("[main] %s: Using RFB version 3.%d", self._remote, self.__rfb_version) # ===== @@ -225,7 +225,7 @@ class RfbClient(RfbClientStream): # pylint: disable=too-many-instance-attribute raise RfbError(f"Invalid security type: {sec_type}") (sec_name, handler) = sec_types[sec_type] - get_logger(0).info("[main] [%s]: Using %s security type", self._remote, sec_name) + get_logger(0).info("[main] %s: Using %s security type", self._remote, sec_name) await handler() async def __handshake_security_vencrypt(self) -> None: @@ -265,7 +265,7 @@ class RfbClient(RfbClientStream): # pylint: disable=too-many-instance-attribute raise RfbError(f"Invalid VeNCrypt auth type: {auth_type}") (auth_name, tls, handler) = auth_types[auth_type] - get_logger(0).info("[main] [%s]: Using %s auth type", self._remote, auth_name) + get_logger(0).info("[main] %s: Using %s auth type", self._remote, auth_name) if tls: await self._write_struct("B", 1) # Ack @@ -322,7 +322,7 @@ class RfbClient(RfbClientStream): # pylint: disable=too-many-instance-attribute async def __handshake_security_send_result(self, allow: bool, allow_msg: str, deny_msg: str, deny_reason: str) -> None: if allow: - get_logger(0).info("[main] [%s]: %s", self._remote, allow_msg) + get_logger(0).info("[main] %s: %s", self._remote, allow_msg) await self._write_struct("L", 0) else: await self._write_struct("L", 1, drain=(self.__rfb_version < 8)) @@ -381,7 +381,7 @@ class RfbClient(RfbClientStream): # pylint: disable=too-many-instance-attribute if encodings_count > 1024: raise RfbError(f"Too many encodings: {encodings_count}") self._encodings = RfbClientEncodings(frozenset(await self._read_struct("l" * encodings_count))) - get_logger(0).info("[main] [%s]: Features: resize=%d; rename=%d; leds=%d", + get_logger(0).info("[main] %s: Features: resize=%d; rename=%d; leds=%d", self._remote, self._encodings.has_resize, self._encodings.has_rename, self._encodings.has_leds_state) self.__check_tight_jpeg() await self._on_set_encodings() diff --git a/kvmd/apps/vnc/rfb/stream.py b/kvmd/apps/vnc/rfb/stream.py index f08da178..3f2d38b8 100644 --- a/kvmd/apps/vnc/rfb/stream.py +++ b/kvmd/apps/vnc/rfb/stream.py @@ -32,7 +32,7 @@ from .errors import RfbConnectionError # ===== def rfb_format_remote(writer: asyncio.StreamWriter) -> str: - return str(writer.transport.get_extra_info("peername")[0]) + return "[%s]:%d" % (writer.transport.get_extra_info("peername")[:2]) async def rfb_close_writer(writer: asyncio.StreamWriter) -> bool: |