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

This commit is contained in:
Xu Yiming 2025-10-20 01:06:16 +08:00
parent 2d32653f5b
commit a4a3b18551

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 {