Skip to content

Commit

Permalink
we only need one real packet encoder
Browse files Browse the repository at this point in the history
the others checks are superfluous and may cause spurious warnings
  • Loading branch information
totaam committed Aug 8, 2021
1 parent 0cd0d63 commit a6151c1
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 33 deletions.
3 changes: 1 addition & 2 deletions xpra/client/client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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:
Expand Down
12 changes: 0 additions & 12 deletions xpra/net/compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 0 additions & 7 deletions xpra/net/packet_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 2 additions & 8 deletions xpra/net/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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!
Expand Down
8 changes: 6 additions & 2 deletions xpra/scripts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
3 changes: 1 addition & 2 deletions xpra/server/server_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -211,7 +211,6 @@ def __init__(self):
self.menu_provider = None

self.init_uuid()
sanity_checks()

def get_server_mode(self):
return "core"
Expand Down

0 comments on commit a6151c1

Please sign in to comment.