Use ByteArray to store ipAddress

This commit is contained in:
Him188 2020-01-20 20:57:03 +08:00
parent 2052159dc9
commit 0345bfa4b3
3 changed files with 5 additions and 4 deletions

View File

@ -76,7 +76,7 @@ actual class SystemDeviceInfo actual constructor(context: Context) : DeviceInfo(
(context.applicationContext.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager).deviceId
}
}.getOrElse { "" }
override val ipAddress: String get() = localIpAddress()
override val ipAddress: ByteArray get() = localIpAddress().split(".").map { it.toByte() }.takeIf { it.size == 4 }?.toByteArray() ?: byteArrayOf()
override val androidId: ByteArray get() = Build.ID.toByteArray()
override val apn: ByteArray get() = "wifi".toByteArray()

View File

@ -16,14 +16,15 @@ import kotlin.random.Random
*/
inline class Tlv(val value: ByteArray)
fun BytePacketBuilder.t1(uin: Long, ip: String) {
fun BytePacketBuilder.t1(uin: Long, ip: ByteArray) {
require(ip.size == 4) { "ip.size must == 4" }
writeShort(0x1)
writeShortLVPacket {
writeShort(1) // _ip_ver
writeInt(Random.nextInt())
writeInt(uin.toInt())
writeTime()
writeFully(ByteArray(4))
writeFully(ip)
writeShort(0)
} shouldEqualsTo 20
}

View File

@ -27,7 +27,7 @@ actual class SystemDeviceInfo actual constructor(context: Context) : DeviceInfo(
override val imsiMd5: ByteArray
get() = ubyteArrayOf(0xD4u, 0x1Du, 0x8Cu, 0xD9u, 0x8Fu, 0x00u, 0xB2u, 0x04u, 0xE9u, 0x80u, 0x09u, 0x98u, 0xECu, 0xF8u, 0x42u, 0x7Eu).toByteArray()
override val imei: String get() = "858414369211993"
override val ipAddress: String get() = localIpAddress()
override val ipAddress: ByteArray get() = localIpAddress().split(".").map { it.toByte() }.takeIf { it.size == 4 }?.toByteArray() ?: byteArrayOf()
override val androidId: ByteArray get() = "QSR1.190920.001".toByteArray()
override val apn: ByteArray get() = "wifi".toByteArray()