dns util: don't resolve ip addresses

This just times out. Not needed.
This commit is contained in:
Moritz Zwerger 2025-02-09 19:47:07 +01:00
parent ff68fcaac0
commit 434cc7bacb
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2020-2024 Moritz Zwerger
* Copyright (C) 2020-2025 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
@ -12,6 +12,7 @@
*/
package de.bixilon.minosoft.util
import com.google.common.net.InetAddresses
import de.bixilon.kutil.exception.ExceptionUtil.catchAll
import de.bixilon.minosoft.protocol.address.ServerAddress
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
@ -23,11 +24,13 @@ object DNSUtil {
fun resolveServerAddress(hostname: String): List<ServerAddress> {
val original = getServerAddress(hostname)
// TODO: Don't resolve if address is ip address
if (":" in hostname) {
// port provided, skip srv check
return listOf(original)
}
if (InetAddresses.isInetAddress(hostname)) {
return listOf(original)
}
val query = "_minecraft._tcp.$hostname"
val records = catchAll { Lookup(query, Type.SRV).run() } ?: return listOf(original)