From a6151c1fa16ff58af6f9e0d20e090dfffec4197c Mon Sep 17 00:00:00 2001 From: totaam Date: Sun, 8 Aug 2021 21:46:38 +0700 Subject: [PATCH] we only need one real packet encoder the others checks are superfluous and may cause spurious warnings --- xpra/client/client_base.py | 3 +-- xpra/net/compression.py | 12 ------------ xpra/net/packet_encoding.py | 7 ------- xpra/net/protocol.py | 10 ++-------- xpra/scripts/main.py | 8 ++++++-- xpra/server/server_core.py | 3 +-- 6 files changed, 10 insertions(+), 33 deletions(-) diff --git a/xpra/client/client_base.py b/xpra/client/client_base.py index 590c905583..230c809f03 100644 --- a/xpra/client/client_base.py +++ b/xpra/client/client_base.py @@ -18,7 +18,7 @@ from xpra.net import compression from xpra.net.common import may_log_packet, PACKET_TYPES from xpra.net.protocol_classes import get_client_protocol_class -from xpra.net.protocol import Protocol, sanity_checks +from xpra.net.protocol import Protocol from xpra.net.net_util import get_network_caps from xpra.net.digest import get_salt, gendigest from xpra.net.crypto import ( @@ -138,7 +138,6 @@ def defaults_init(self): self.session_id = uuid.uuid4().hex self.init_packet_handlers() self.have_more = noop - sanity_checks() def init(self, opts): if self._init_done: diff --git a/xpra/net/compression.py b/xpra/net/compression.py index c9f81376fd..594d6ca71f 100644 --- a/xpra/net/compression.py +++ b/xpra/net/compression.py @@ -148,18 +148,6 @@ def get_compressor(name): return c.compress -def sanity_checks(): - if not use("lzo") and not use("lz4"): - from xpra.log import Logger - logger = Logger("network", "protocol") - if not use("zlib"): - logger.warn("Warning: all the compressors are unavailable or disabled,") - logger.warn(" performance may suffer in some cases") - else: - logger.warn("Warning: zlib is the only compressor enabled") - logger.warn(" install and enable lz4 support for better performance") - - class Compressed: def __init__(self, datatype, data, can_inline=False): assert data is not None, "compressed data cannot be set to None" diff --git a/xpra/net/packet_encoding.py b/xpra/net/packet_encoding.py index dfab20d99c..023dc49b0b 100644 --- a/xpra/net/packet_encoding.py +++ b/xpra/net/packet_encoding.py @@ -119,13 +119,6 @@ def get_packet_encoding_type(protocol_flags) -> str: return "bencode" -def sanity_checks(): - if "rencodeplus" not in ENCODERS: - log = Logger("network", "protocol") - log.warn("Warning: 'rencodeplus' packet encoder was not found") - log.warn(" this build of xpra may be incomplete") - - class InvalidPacketEncodingException(Exception): pass diff --git a/xpra/net/protocol.py b/xpra/net/protocol.py index bb17ebb9ad..a2820317cb 100644 --- a/xpra/net/protocol.py +++ b/xpra/net/protocol.py @@ -23,13 +23,13 @@ from xpra.net.bytestreams import ABORT from xpra.net import compression from xpra.net.compression import ( - decompress, sanity_checks as compression_sanity_checks, + decompress, InvalidCompressionException, Compressed, LevelCompressed, Compressible, LargeStructure, ) from xpra.net import packet_encoding from xpra.net.socket_util import guess_packet_type from xpra.net.packet_encoding import ( - decode, sanity_checks as packet_encoding_sanity_checks, + decode, InvalidPacketEncodingException, ) from xpra.net.header import unpack_header, pack_header, FLAGS_CIPHER, FLAGS_NOHEADER, FLAGS_FLUSH, HEADER_SIZE @@ -54,12 +54,6 @@ SEND_INVALID_PACKET_DATA = strtobytes(os.environ.get("XPRA_SEND_INVALID_PACKET_DATA", b"ZZinvalid-packetZZ")) -def sanity_checks(): - """ warns the user if important modules are missing """ - compression_sanity_checks() - packet_encoding_sanity_checks() - - def exit_queue(): queue = Queue() for _ in range(10): #just 2 should be enough! diff --git a/xpra/scripts/main.py b/xpra/scripts/main.py index 74de144381..51823d9d5f 100755 --- a/xpra/scripts/main.py +++ b/xpra/scripts/main.py @@ -252,8 +252,12 @@ def configure_network(options): #force compression level to zero since we have no compressors available: options.compression_level = 0 packet_encoding.init_encoders(*list(options.packet_encoders)+["none"]) - ees = packet_encoding.get_enabled_encoders() - #verify that at least one encoder is available: + ees = set(packet_encoding.get_enabled_encoders()) + try: + ees.remove("none") + except KeyError: + pass + #verify that at least one real encoder is available: if not ees: raise InitException("at least one valid packet encoder must be enabled") diff --git a/xpra/server/server_core.py b/xpra/server/server_core.py index 35002598a5..22eb78125b 100644 --- a/xpra/server/server_core.py +++ b/xpra/server/server_core.py @@ -39,7 +39,7 @@ get_network_caps, get_info as get_net_info, import_netifaces, get_interfaces_addresses, ) -from xpra.net.protocol import Protocol, sanity_checks +from xpra.net.protocol import Protocol from xpra.net.digest import get_salt, gendigest, choose_digest from xpra.platform import set_name, threaded_server_init from xpra.platform.paths import ( @@ -211,7 +211,6 @@ def __init__(self): self.menu_provider = None self.init_uuid() - sanity_checks() def get_server_mode(self): return "core"