Files
strom/client/dns.go
T
2026-01-13 00:22:11 +01:00

23 lines
422 B
Go

package client
import (
"net"
"strings"
)
func LookupMinecraftSRV(host string, port uint16) (hostRet string, portRet uint16) {
hostRet = host // in case of error
portRet = port
if port != 25565 {
return
}
_, srvs, err := net.LookupSRV("minecraft", "tcp", host)
if err != nil || len(srvs) == 0 {
return
}
target := strings.TrimSuffix(srvs[0].Target, ".")
hostRet = target
portRet = srvs[0].Port
return
}