From a8ee12310daf0c008e7844fffe943d4c986f6bf1 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Sun, 5 Jul 2020 09:45:43 +0000 Subject: [PATCH] #2744 hook control commands git-svn-id: https://xpra.org/svn/Xpra/trunk@26890 3bb7dfac-3a0b-4e04-842a-767bc560f471 --- src/xpra/client/mixins/network_listener.py | 30 +++++++++++++++------- src/xpra/client/ui_client_base.py | 2 +- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/xpra/client/mixins/network_listener.py b/src/xpra/client/mixins/network_listener.py index cdb50645cd..a61e640f22 100644 --- a/src/xpra/client/mixins/network_listener.py +++ b/src/xpra/client/mixins/network_listener.py @@ -5,7 +5,8 @@ #pylint: disable-msg=E1101 from xpra import __version__ as VERSION -from xpra.util import envint, envfloat, typedict, DETACH_REQUEST, PROTOCOL_ERROR +from xpra.util import envint, envfloat, typedict, DETACH_REQUEST, PROTOCOL_ERROR, DONE +from xpra.os_util import bytestostr from xpra.net.bytestreams import log_new_connection from xpra.net.socket_util import create_sockets, add_listen_socket, accept_connection from xpra.net.net_util import get_network_caps @@ -133,7 +134,15 @@ def handle_new_connection(self, socktype, listener, _handle): def process_network_packet(self, proto, packet): log("process_network_packet: %s", packet) - if packet[0]==b"hello": + packet_type = bytestostr(packet[0]) + def close(): + try: + self._close_timers.pop(proto) + except KeyError: + pass + else: + proto.close() + if packet_type=="hello": caps = typedict(packet[1]) proto.parse_remote_caps(caps) proto.enable_compressor_from_caps(caps) @@ -153,17 +162,20 @@ def protocol_closed(): return elif request=="version": proto.send_now(["hello", {"version" : VERSION}]) + elif request=="command": + command = caps.strtupleget("command_request") + log("command request: %s", command) + self.idle_add(self._process_control, ["control"]+list(command)) + proto.send_disconnect([DONE]) else: + log.info("request '%s' is not handled by this client", request) proto.send_disconnect([PROTOCOL_ERROR]) + elif packet_type=="connection-lost": + close() + return else: + log.info("packet '%s' is not handled by this client", packet_type) proto.send_disconnect([PROTOCOL_ERROR]) #make sure the connection is closed: - def close(): - try: - self._close_timers.pop(proto) - except KeyError: - pass - else: - proto.close() tid = self.timeout_add(REQUEST_TIMEOUT*1000, close) self._close_timers[proto] = tid diff --git a/src/xpra/client/ui_client_base.py b/src/xpra/client/ui_client_base.py index a2131402a0..ade73980e1 100644 --- a/src/xpra/client/ui_client_base.py +++ b/src/xpra/client/ui_client_base.py @@ -568,7 +568,7 @@ def _process_control(self, packet): command = bytestostr(packet[1]) if command=="show_session_info": args = packet[2:] - log("calling show_session_info%s on server request", args) + log("calling %s%s on server request", self.show_session_info, args) self.show_session_info(*args) elif command=="show_bug_report": self.show_bug_report()