client: add StatusRawWithVersion for version-aware status pings

This commit is contained in:
adman
2026-07-31 19:34:16 +02:00
parent 33754d7c71
commit f579645b88
+6 -1
View File
@@ -40,12 +40,17 @@ func (s *StatusClient) OnPong(p *v1_21_8.StatusToClientPacketPing) (err error) {
// So ignore the resource leak warning. And maybe attach a warn ignore comment. // So ignore the resource leak warning. And maybe attach a warn ignore comment.
// It does not resolve SRV records. // It does not resolve SRV records.
func StatusRaw(ctx context.Context, addr string) (s *StatusClient, err error) { func StatusRaw(ctx context.Context, addr string) (s *StatusClient, err error) {
return StatusRawWithVersion(ctx, addr, "1.21.8")
}
// StatusRawWithVersion is like StatusRaw but uses the given Minecraft version for the handshake.
func StatusRawWithVersion(ctx context.Context, addr, version string) (s *StatusClient, err error) {
c, err := ConnectVersionLess(ctx, addr) c, err := ConnectVersionLess(ctx, addr)
if err != nil { if err != nil {
return return
} }
defer c.Close() defer c.Close()
err = c.SetVersion("1.21.8") err = c.SetVersion(version)
if err != nil { if err != nil {
return return
} }