Skip to content

Commit

Permalink
dns util: don't resolve ip addresses
Browse files Browse the repository at this point in the history
This just times out. Not needed.
  • Loading branch information
Bixilon committed Feb 9, 2025
1 parent ff68fca commit 434cc7b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/java/de/bixilon/minosoft/util/DNSUtil.kt
Original file line number Diff line number Diff line change
@@ -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.
*
Expand All @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 434cc7b

Please sign in to comment.