From 8eccfefc75a489e685348f0f89ecb274caa51073 Mon Sep 17 00:00:00 2001 From: Debian Date: Wed, 16 Sep 2026 22:04:47 +0200 Subject: [PATCH] Show client id and endpoint on connect/disconnect, gate command echoes behind -v Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- lib/network.py | 2 +- main.py | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/network.py b/lib/network.py index 3644f34..a82263c 100644 --- a/lib/network.py +++ b/lib/network.py @@ -45,7 +45,7 @@ def check_monitor(monitor): return None logger.debug(f'Monitor: {event_name} {event_value} endpoint {event_endpoint}') - return (event_id, event_value) + return (event_id, event_value, event_endpoint.decode('utf-8', 'replace')) class RconConnection: diff --git a/main.py b/main.py index 794075a..09c9193 100644 --- a/main.py +++ b/main.py @@ -103,9 +103,9 @@ def parse_cvar_response(message, game_state, ui): return False -def is_own_command_echo(message, identity): - """True for echo lines of commands this client sent (the server echoes them to every RCON client)""" - return message.startswith(f'zmq RCON command from {identity}:') +def is_command_echo(message): + """True for the server's echo lines announcing that an RCON client sent a command""" + return message.startswith('zmq RCON command') def is_command_output(message): @@ -422,7 +422,8 @@ def main_loop(screen, args): monitor_event = rcon.check_monitor() if monitor_event and monitor_event[0] == zmq.EVENT_CONNECTED: timestamp = time.strftime('%H:%M:%S') - ui.print_message(f"^3[^7{timestamp}^3]^7 Connected to server\n") + ui.print_message(f"^3[^7{timestamp}^3]^7 Connected to server ({monitor_event[2]}) " + f"as rcon client {rcon.identity}\n") rcon.send_command(b'register') logger.info('Registration message sent') @@ -434,7 +435,8 @@ def main_loop(screen, args): name_capture.request(rcon) elif monitor_event and monitor_event[0] == zmq.EVENT_DISCONNECTED: timestamp = time.strftime('%H:%M:%S') - ui.print_message(f"^3[^7{timestamp}^3] ^8^1Disconnected from server - waiting for reconnect...^0^7\n") + ui.print_message(f"^3[^7{timestamp}^3] ^8^1Disconnected from server ({monitor_event[2]}) " + f"as rcon client {rcon.identity} - waiting for reconnect...^0^7\n") if stats_conn is not None: poller.unregister(stats_conn.socket) stats_conn.close() @@ -475,8 +477,9 @@ def main_loop(screen, args): if parse_player_events(message, game_state, ui): continue - # Hide echoes of our own commands; other clients' echoes stay visible - if is_own_command_echo(message, rcon.identity): + # Command echoes only show at -v or higher verbosity + if is_command_echo(message) and args.verbose == 0: + logger.debug('Suppressed RCON command echo') continue if 'Game Initialization' in message: