diff options
author | Youfu Zhang <[email protected]> | 2024-07-25 22:15:35 +0800 |
---|---|---|
committer | GitHub <[email protected]> | 2024-07-25 17:15:35 +0300 |
commit | 5cc815cfa0d564d65fef63c2e1e21744ae5ad329 (patch) | |
tree | cc670a52c687fe74600017a8eeb7777d7de92a21 /kvmd | |
parent | 73f929b260c11e44d6ed322f81ec7efb63aa787f (diff) |
fix vnc security type handshake for rfb version 3 (#172)
Diffstat (limited to 'kvmd')
-rw-r--r-- | kvmd/apps/vnc/rfb/__init__.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/kvmd/apps/vnc/rfb/__init__.py b/kvmd/apps/vnc/rfb/__init__.py index d6cdf6d8..847325a5 100644 --- a/kvmd/apps/vnc/rfb/__init__.py +++ b/kvmd/apps/vnc/rfb/__init__.py @@ -261,11 +261,15 @@ class RfbClient(RfbClientStream): # pylint: disable=too-many-instance-attribute await self._write_reason("refusing security type reason", msg) raise RfbError(msg) - await self._write_struct("security types", "B" + "B" * len(sec_types), len(sec_types), *sec_types) # Keep dict priority + if self.__rfb_version > 3: + await self._write_struct("security types", "B" + "B" * len(sec_types), len(sec_types), *sec_types) # Keep dict priority - sec_type = await self._read_number("selected security type", "B") - if sec_type not in sec_types: - raise RfbError(f"Invalid security type: {sec_type}") + sec_type = await self._read_number("selected security type", "B") + if sec_type not in sec_types: + raise RfbError(f"Invalid security type: {sec_type}") + else: + sec_type = min(sec_types.keys()) + await self._write_struct("selected security type", "L", sec_type) (sec_name, handler) = sec_types[sec_type] get_logger(0).info("%s [main]: Using %s security type", self._remote, sec_name) |