version compat system
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user