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 <[email protected]>
This commit is contained in:
Debian
2026-09-16 22:04:47 +02:00
co-authored by Sisyphus
parent e834b44ba6
commit 8eccfefc75
2 changed files with 11 additions and 8 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ def check_monitor(monitor):
return None return None
logger.debug(f'Monitor: {event_name} {event_value} endpoint {event_endpoint}') 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: class RconConnection:
+10 -7
View File
@@ -103,9 +103,9 @@ def parse_cvar_response(message, game_state, ui):
return False return False
def is_own_command_echo(message, identity): def is_command_echo(message):
"""True for echo lines of commands this client sent (the server echoes them to every RCON client)""" """True for the server's echo lines announcing that an RCON client sent a command"""
return message.startswith(f'zmq RCON command from {identity}:') return message.startswith('zmq RCON command')
def is_command_output(message): def is_command_output(message):
@@ -422,7 +422,8 @@ def main_loop(screen, args):
monitor_event = rcon.check_monitor() monitor_event = rcon.check_monitor()
if monitor_event and monitor_event[0] == zmq.EVENT_CONNECTED: if monitor_event and monitor_event[0] == zmq.EVENT_CONNECTED:
timestamp = time.strftime('%H:%M:%S') 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') rcon.send_command(b'register')
logger.info('Registration message sent') logger.info('Registration message sent')
@@ -434,7 +435,8 @@ def main_loop(screen, args):
name_capture.request(rcon) name_capture.request(rcon)
elif monitor_event and monitor_event[0] == zmq.EVENT_DISCONNECTED: elif monitor_event and monitor_event[0] == zmq.EVENT_DISCONNECTED:
timestamp = time.strftime('%H:%M:%S') 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: if stats_conn is not None:
poller.unregister(stats_conn.socket) poller.unregister(stats_conn.socket)
stats_conn.close() stats_conn.close()
@@ -475,8 +477,9 @@ def main_loop(screen, args):
if parse_player_events(message, game_state, ui): if parse_player_events(message, game_state, ui):
continue continue
# Hide echoes of our own commands; other clients' echoes stay visible # Command echoes only show at -v or higher verbosity
if is_own_command_echo(message, rcon.identity): if is_command_echo(message) and args.verbose == 0:
logger.debug('Suppressed RCON command echo')
continue continue
if 'Game Initialization' in message: if 'Game Initialization' in message: