Add context to unexpected-message logs; log port2 reassignments#13
Merged
Conversation
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>
softins
approved these changes
May 21, 2026
Owner
softins
left a comment
There was a problem hiding this comment.
Thanks! I pushed a small change to avoid shadowing global $port
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
log_unexpected()to replace bareerror_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:CLM_EMPTY_MESSAGEarrives 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
php servers.php directory=<host>:<port>against a directory that contains servers known to generate unexpected messages; confirm log lines include directory and name contextPort2 reassignlog appears when a server responds on a port different from its registered one