Skip to content

Add context to unexpected-message logs; log port2 reassignments#13

Merged
softins merged 2 commits into
softins:masterfrom
mcfnord:enrich-unexpected-logs
May 21, 2026
Merged

Add context to unexpected-message logs; log port2 reassignments#13
softins merged 2 commits into
softins:masterfrom
mcfnord:enrich-unexpected-logs

Conversation

@mcfnord
Copy link
Copy Markdown

@mcfnord mcfnord commented May 21, 2026

Summary

  • Introduce log_unexpected() to replace bare error_log("Unexpected X from ip:port") calls. The helper appends the queried directory (host:port) and, when the source IP is in the server list, the server's registered port and name. This turns opaque log entries into actionable ones:
    Unexpected CLM_PING from 1.2.3.4:5678 (directory: anygenre1.jamulus.io:22124, registered as 1.2.3.4:22124 name="My Server")
    
  • Log port2 reassignments: when CLM_EMPTY_MESSAGE arrives from a known IP but an unexpected port, record the registered port, responding port, server name, and directory. Previously this was silently absorbed.

Motivation

Both changes address the same underlying problem: unexpected messages and port shifts currently produce log entries that give no clue about which directory query triggered them or which registered server is involved. With ~900+ unexpected-message drops per day in a busy deployment, the added context makes it practical to distinguish transient noise from specific misconfigured or misbehaving servers.

Test plan

  • Run php servers.php directory=<host>:<port> against a directory that contains servers known to generate unexpected messages; confirm log lines include directory and name context
  • Confirm no regression in normal directory polling output
  • Confirm Port2 reassign log appears when a server responds on a port different from its registered one

jrd and others added 2 commits May 21, 2026 17:31
Introduce log_unexpected() to replace the bare error_log("Unexpected X
from ip:port") calls. The helper appends the queried directory (host:port)
and, when the source IP is recognised in the server list, the server's
registered port and name. This turns opaque "Unexpected CLM_PING from
1.2.3.4:5678" entries into actionable lines like:
  Unexpected CLM_PING from 1.2.3.4:5678 (directory: anygenre1.jamulus.io:22124, registered as 1.2.3.4:22124 name="My Server")

Also log port2 reassignments: when a CLM_EMPTY_MESSAGE arrives from an IP
that is registered but on a different port than expected, record the
registered port, responding port, server name, and directory so the event
is visible in logs rather than silently absorbed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Owner

@softins softins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I pushed a small change to avoid shadowing global $port

@softins softins merged commit 6930980 into softins:master May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants