mirror of
https://github.com/mamoe/mirai.git
synced 2025-04-25 04:50:26 +08:00
Fix resolveIpFromHost
This commit is contained in:
parent
7a3576fe3e
commit
aabcff628a
@ -116,19 +116,13 @@ internal actual class PlatformSocket(
|
||||
}
|
||||
|
||||
private fun resolveIpFromHost(serverIp: String): UInt {
|
||||
val host = gethostbyname(serverIp)
|
||||
val host = gethostbyname(serverIp) // points to static data, don't free
|
||||
?: throw IllegalStateException("Failed to resolve IP from host. host=$serverIp")
|
||||
|
||||
val str = try {
|
||||
val hAddrList = host.pointed.h_addr_list
|
||||
?: throw IllegalStateException("Empty IP list resolved from host. host=$serverIp")
|
||||
val hAddrList = host.pointed.h_addr_list
|
||||
?: throw IllegalStateException("Empty IP list resolved from host. host=$serverIp")
|
||||
|
||||
hAddrList[0]!!.toKString()
|
||||
} finally {
|
||||
free(host)
|
||||
}
|
||||
|
||||
// TODO: 2022/5/30 check memory
|
||||
val str = hAddrList[0]!!.toKString()
|
||||
|
||||
return str.toIpV4Long().toUInt()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user