version compat system

This commit is contained in:
adman
2026-03-11 09:18:58 +01:00
parent c516cc5283
commit 047c4d02ff
18 changed files with 258 additions and 101 deletions
+18
View File
@@ -2,6 +2,7 @@ package client
import (
"net"
"strconv"
"strings"
)
@@ -20,3 +21,20 @@ func LookupMinecraftSRV(host string, port uint16) (hostRet string, portRet uint1
portRet = srvs[0].Port
return
}
func DoDNS(in string) (out string, err error) { // Bad code should match minecraft
// https://mcsrc.dev/1/26.1-pre-1/net/minecraft/client/multiplayer/resolver/ServerAddress#L34
host, port, _ := net.SplitHostPort(in)
var portN uint16 = 25565
if port != "" {
var porti int
porti, err = strconv.Atoi(port)
if err != nil {
return
}
portN = uint16(porti)
}
host, portN = LookupMinecraftSRV(host, portN)
out = net.JoinHostPort(host, strconv.Itoa(int(portN)))
return
}