mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-10 10:30:13 +08:00
Merge pull request #131 from Cyenoch/master
Addressed an exception that was thrown because InetAddress.getLocalHost().hostAddress might get an ipv6 address
This commit is contained in:
commit
badc792af4
@ -18,7 +18,7 @@ import kotlinx.io.pool.useInstance
|
|||||||
import net.mamoe.mirai.utils.io.ByteArrayPool
|
import net.mamoe.mirai.utils.io.ByteArrayPool
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import java.net.InetAddress
|
import java.net.Inet4Address
|
||||||
import java.security.MessageDigest
|
import java.security.MessageDigest
|
||||||
import java.util.zip.Deflater
|
import java.util.zip.Deflater
|
||||||
import java.util.zip.Inflater
|
import java.util.zip.Inflater
|
||||||
@ -81,7 +81,7 @@ actual object MiraiPlatformUtils {
|
|||||||
* Localhost 解析
|
* Localhost 解析
|
||||||
*/
|
*/
|
||||||
actual fun localIpAddress(): String = runCatching {
|
actual fun localIpAddress(): String = runCatching {
|
||||||
InetAddress.getLocalHost().hostAddress
|
Inet4Address.getLocalHost().hostAddress
|
||||||
}.getOrElse { "192.168.1.123" }
|
}.getOrElse { "192.168.1.123" }
|
||||||
|
|
||||||
fun md5(stream: InputStream): ByteArray {
|
fun md5(stream: InputStream): ByteArray {
|
||||||
|
@ -19,7 +19,7 @@ import net.mamoe.mirai.utils.io.ByteArrayPool
|
|||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import java.io.OutputStream
|
import java.io.OutputStream
|
||||||
import java.net.InetAddress
|
import java.net.Inet4Address
|
||||||
import java.security.MessageDigest
|
import java.security.MessageDigest
|
||||||
import java.util.zip.Deflater
|
import java.util.zip.Deflater
|
||||||
import java.util.zip.Inflater
|
import java.util.zip.Inflater
|
||||||
@ -82,7 +82,7 @@ actual object MiraiPlatformUtils {
|
|||||||
* Localhost 解析
|
* Localhost 解析
|
||||||
*/
|
*/
|
||||||
actual fun localIpAddress(): String = runCatching {
|
actual fun localIpAddress(): String = runCatching {
|
||||||
InetAddress.getLocalHost().hostAddress
|
Inet4Address.getLocalHost().hostAddress
|
||||||
}.getOrElse { "192.168.1.123" }
|
}.getOrElse { "192.168.1.123" }
|
||||||
|
|
||||||
fun md5(stream: InputStream): ByteArray {
|
fun md5(stream: InputStream): ByteArray {
|
||||||
|
Loading…
Reference in New Issue
Block a user