Performing DNS SRV lookups for hosts that are already direct IP
addresses or special-case hostnames like 'localhost' is
unnecessary.
In addition, several related test suite improvements
have been included:
- A bug in the Bedrock mock packet creation was fixed where the magic
GUID was being written to an incorrect buffer offset.
- The DNS mocking strategy in the Java tests has been refactored for
better accuracy by mocking the `dns.promises.Resolver` class.
- An error test for the Bedrock pinger was corrected to properly
handle a promise rejection instead of a synchronous throw.
Add support for DNS SRV record lookups (`_minecraft._tcp`) to
automatically resolve the correct server host and port, falling back
to the provided address if no record is found. This makes server
discovery compliant with standard Minecraft client behavior.
The Java ping implementation has been refactored:
- The `varint` module is rewritten to throw specific error codes and
its `decodeVarInt` function now returns bytes read, which simplifies
parsing logic.
- The core ping logic is now promise-based and modular, breaking out
packet creation and response processing into helper functions.
- The TCP stream handler now robustly processes chunked data by
catching recoverable decoder errors and waiting for more data,
preventing crashes on incomplete packets.
- Error handling is improved.
The previous implementation of the RakNet ping was monolithic, mixing
socket management, raw packet validation, and data transformation into
a single, complex flow.
This refactor introduces a clear, multi-stage
processing pipeline that separates these concerns. The logic is now
broken down into multi-stage pipeline: extracting the MOTD string
from the raw pong packet -> parsing that string into a raw
object -> transforming the raw data into a
user-friendly response object.
Additionally, the socket handling logic is improved
with idempotent cleanup function to prevent resource
leaks or race conditions.
As part of this overhaul, external TypeScript definition (`.d.ts`)
files have been removed in favor of rich JSDoc annotations.
BREAKING CHANGE: The structure of the resolved `BedrockPingResponse`
object has been significantly changed to improve clarity and
consistency.