Skip to content

Commit

Permalink
#3574 add 'control' to socket options
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Dec 25, 2023
1 parent e0ea5d4 commit 972cc90
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
18 changes: 15 additions & 3 deletions xpra/server/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,13 +827,25 @@ def init_control_commands(self) -> None:
def handle_command_request(self, proto, *args) -> None:
""" client sent a command request as part of the hello packet """
assert args, "no arguments supplied"
code, response = self.process_control_command(*args)
code, response = self.process_control_command(proto, *args)
hello = {"command_response" : (code, response)}
proto.send_now(("hello", hello))

def process_control_command(self, *args):
def process_control_command(self, protocol, *args):
try:
options = protocol._conn.options
control = options.get("control", "yes")
except AttributeError:
control = "no"
if not parse_bool("control", control):
err = "control commands are not enabled on this connection"
log.warn(f"Warning: {err}")
return 6, err
from xpra.server.control_command import ControlError
assert args, "control command must have arguments"
if not args:
err = "control command must have arguments"
log.warn(f"Warning: {err}")
return 6, err
name = args[0]
try:
command = self.control_commands.get(name) or self.control_commands.get("*")
Expand Down
4 changes: 2 additions & 2 deletions xpra/server/mixins/controlcommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,12 +794,12 @@ def control_command_moveresize(self, wid:int, x:int, y:int, w:int, h:int) -> str
return f"window {wid} moved to {x},{y} and resized to {w}x{h} for {count} clients"


def _process_command_request(self, _proto, packet : PacketType) -> None:
def _process_command_request(self, protocol, packet : PacketType) -> None:
""" client sent a command request through its normal channel """
assert len(packet)>=2, "invalid command request packet (too small!)"
#packet[0] = "control"
#this may end up calling do_handle_command_request via the adapter
code, msg = self.process_control_command(*packet[1:])
code, msg = self.process_control_command(protocol, *packet[1:])
log("command request returned: %s (%s)", code, msg)

def init_packet_handlers(self) -> None:
Expand Down

0 comments on commit 972cc90

Please sign in to comment.