fix: Certain single-label domain names can only be resolved by InetAddress.getAllByName() but not Network.getAllByName() (#1050)

This commit is contained in:
xymopen_Official 2025-10-21 20:31:41 +08:00 committed by GitHub
parent 2d32653f5b
commit 596b9ebfbb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -128,11 +128,11 @@ object LocalResolverImpl : LocalDNSTransport {
// 老版本系统,继续用阻塞的 InetAddress
try {
val u = SagerNet.underlyingNetwork
val answer = if (u != null) {
u.getAllByName(domain)
} else {
InetAddress.getAllByName(domain)
}
val answer = try {
u?.getAllByName(domain)
} catch (e: UnknownHostException) {
null
} ?: InetAddress.getAllByName(domain)
if (answer != null) {
ctx.success(answer.mapNotNull { it.hostAddress }.joinToString("\n"))
} else {