Commit f0fd0b51 authored by Him188's avatar Him188

Change ipAddress from ByteArray to String

parent 4fd579a7
...@@ -35,11 +35,11 @@ internal open class QQAndroidClient( ...@@ -35,11 +35,11 @@ internal open class QQAndroidClient(
var ssoSequenceId: Int = 0 var ssoSequenceId: Int = 0
var openAppId: Long = 715019303L var openAppId: Long = 715019303L
var ipv6NetType: Int = TODO()
val apkVersionName: ByteArray = "8.2.0".toByteArray() val apkVersionName: ByteArray = "8.2.0".toByteArray()
val appClientVersion: Int = TODO() val appClientVersion: Int = 0
var networkType: NetworkType = NetworkType.WIFI
val apkSignatureMd5: ByteArray = TODO() val apkSignatureMd5: ByteArray = TODO()
......
...@@ -4,6 +4,7 @@ import kotlinx.io.core.BytePacketBuilder ...@@ -4,6 +4,7 @@ import kotlinx.io.core.BytePacketBuilder
import kotlinx.io.core.ByteReadPacket import kotlinx.io.core.ByteReadPacket
import kotlinx.io.core.toByteArray import kotlinx.io.core.toByteArray
import kotlinx.io.core.writeFully import kotlinx.io.core.writeFully
import net.mamoe.mirai.qqandroid.utils.NetworkType
import net.mamoe.mirai.utils.currentTime import net.mamoe.mirai.utils.currentTime
import net.mamoe.mirai.utils.io.* import net.mamoe.mirai.utils.io.*
import net.mamoe.mirai.utils.md5 import net.mamoe.mirai.utils.md5
...@@ -29,15 +30,14 @@ inline class LoginType( ...@@ -29,15 +30,14 @@ inline class LoginType(
} }
@Suppress("MemberVisibilityCanBePrivate") @Suppress("MemberVisibilityCanBePrivate")
fun BytePacketBuilder.t1(uin: Long, ip: ByteArray) { fun BytePacketBuilder.t1(uin: Long, ip: String) {
require(ip.size == 4)
writeShort(0x1) writeShort(0x1)
writeShortLVPacket { writeShortLVPacket {
writeShort(1) // _ip_ver writeShort(1) // _ip_ver
writeInt(Random.nextInt()) writeInt(Random.nextInt())
writeInt(uin.toInt()) writeInt(uin.toInt())
writeTime() writeTime()
writeFully(ip) writeIP(ip)
writeShort(0) writeShort(0)
} shouldEqualsTo 20 } shouldEqualsTo 20
} }
...@@ -83,9 +83,9 @@ fun BytePacketBuilder.t18( ...@@ -83,9 +83,9 @@ fun BytePacketBuilder.t18(
fun BytePacketBuilder.t106( fun BytePacketBuilder.t106(
appId: Long, appId: Long,
subAppId: Long, subAppId: Long,
appClientVersion: Int, appClientVersion: Int = 0,
uin: Long, uin: Long,
ipAddress: ByteArray, ipAddress: String,
n5_always_1: Int = 1, n5_always_1: Int = 1,
passwordMd5: ByteArray, passwordMd5: ByteArray,
salt: Long, salt: Long,
...@@ -112,7 +112,7 @@ fun BytePacketBuilder.t106( ...@@ -112,7 +112,7 @@ fun BytePacketBuilder.t106(
} }
writeTime() writeTime()
writeFully(ipAddress) writeIP(ipAddress)
writeByte(n5_always_1.toByte()) writeByte(n5_always_1.toByte())
writeFully(passwordMd5) writeFully(passwordMd5)
writeFully(tgtgtKey) writeFully(tgtgtKey)
...@@ -130,7 +130,7 @@ fun BytePacketBuilder.t106( ...@@ -130,7 +130,7 @@ fun BytePacketBuilder.t106(
} }
writeInt(subAppId.toInt()) writeInt(subAppId.toInt())
writeInt(loginType.value) writeInt(loginType.value)
writeShortLVByteArray(uinAccount) writeShortLVByteArray(uinAccount) // TODO check if should be empty byte[]
} }
} shouldEqualsTo 98 } shouldEqualsTo 98
} }
...@@ -234,7 +234,7 @@ fun BytePacketBuilder.t144( ...@@ -234,7 +234,7 @@ fun BytePacketBuilder.t144(
// t124 // t124
osType: ByteArray = "android".toByteArray(), osType: ByteArray = "android".toByteArray(),
osVersion: ByteArray, osVersion: ByteArray,
ipv6NetType: Int, networkType: NetworkType,
simInfo: ByteArray, simInfo: ByteArray,
unknown: ByteArray, unknown: ByteArray,
apn: ByteArray = "wifi".toByteArray(), apn: ByteArray = "wifi".toByteArray(),
...@@ -256,7 +256,7 @@ fun BytePacketBuilder.t144( ...@@ -256,7 +256,7 @@ fun BytePacketBuilder.t144(
encryptAndWrite(tgtgtKey) { encryptAndWrite(tgtgtKey) {
t109(androidId) t109(androidId)
t52d(androidDevInfo) t52d(androidDevInfo)
t124(osType, osVersion, ipv6NetType, simInfo, unknown, apn) t124(osType, osVersion, networkType, simInfo, unknown, apn)
t128(isGuidFromFileNull, isGuidAvailable, isGuidChanged, guidFlag, buildModel, guid, buildBrand) t128(isGuidFromFileNull, isGuidAvailable, isGuidChanged, guidFlag, buildModel, guid, buildBrand)
t16e(buildModel) t16e(buildModel)
} }
...@@ -284,7 +284,7 @@ fun BytePacketBuilder.t52d( ...@@ -284,7 +284,7 @@ fun BytePacketBuilder.t52d(
fun BytePacketBuilder.t124( fun BytePacketBuilder.t124(
osType: ByteArray = "android".toByteArray(), osType: ByteArray = "android".toByteArray(),
osVersion: ByteArray, // Build.VERSION.RELEASE.toByteArray() osVersion: ByteArray, // Build.VERSION.RELEASE.toByteArray()
ipv6NetType: Int, //oicq.wlogin_sdk.tools.util#get_network_type networkType: NetworkType, //oicq.wlogin_sdk.tools.util#get_network_type
simInfo: ByteArray, // oicq.wlogin_sdk.tools.util#get_sim_operator_name simInfo: ByteArray, // oicq.wlogin_sdk.tools.util#get_sim_operator_name
unknown: ByteArray, unknown: ByteArray,
apn: ByteArray = "wifi".toByteArray() // oicq.wlogin_sdk.tools.util#get_apn_string apn: ByteArray = "wifi".toByteArray() // oicq.wlogin_sdk.tools.util#get_apn_string
...@@ -293,7 +293,7 @@ fun BytePacketBuilder.t124( ...@@ -293,7 +293,7 @@ fun BytePacketBuilder.t124(
writeShortLVPacket { writeShortLVPacket {
writeShortLVByteArrayLimitedLength(osType, 16) writeShortLVByteArrayLimitedLength(osType, 16)
writeShortLVByteArrayLimitedLength(osVersion, 16) writeShortLVByteArrayLimitedLength(osVersion, 16)
writeShort(ipv6NetType.toShort()) writeShort(networkType.value.toShort())
writeShortLVByteArrayLimitedLength(simInfo, 16) writeShortLVByteArrayLimitedLength(simInfo, 16)
writeShortLVByteArrayLimitedLength(unknown, 32) writeShortLVByteArrayLimitedLength(unknown, 32)
writeShortLVByteArrayLimitedLength(apn, 16) writeShortLVByteArrayLimitedLength(apn, 16)
...@@ -414,14 +414,14 @@ fun BytePacketBuilder.t154( ...@@ -414,14 +414,14 @@ fun BytePacketBuilder.t154(
fun BytePacketBuilder.t141( fun BytePacketBuilder.t141(
simInfo: ByteArray, simInfo: ByteArray,
ipv6NetType: Int, networkType: NetworkType,
apn: ByteArray apn: ByteArray
) { ) {
writeShort(0x141) writeShort(0x141)
writeShortLVPacket { writeShortLVPacket {
writeShort(1) // version writeShort(1) // version
writeShortLVByteArray(simInfo) writeShortLVByteArray(simInfo)
writeShort(ipv6NetType.toShort()) writeShort(networkType.value.toShort())
writeShortLVByteArray(apn) writeShortLVByteArray(apn)
} }
} }
......
...@@ -74,7 +74,7 @@ internal object LoginPacket : PacketFactory<LoginPacket.LoginPacketResponse, Log ...@@ -74,7 +74,7 @@ internal object LoginPacket : PacketFactory<LoginPacket.LoginPacketResponse, Log
androidDevInfo = client.device.generateDeviceInfoData(), androidDevInfo = client.device.generateDeviceInfoData(),
osType = client.device.osType, osType = client.device.osType,
osVersion = client.device.version.release, osVersion = client.device.version.release,
ipv6NetType = client.ipv6NetType, networkType = client.networkType,
simInfo = client.device.simInfo, simInfo = client.device.simInfo,
unknown = byteArrayOf(), apn = client.device.apn, unknown = byteArrayOf(), apn = client.device.apn,
isGuidFromFileNull = false, isGuidFromFileNull = false,
...@@ -97,7 +97,7 @@ internal object LoginPacket : PacketFactory<LoginPacket.LoginPacketResponse, Log ...@@ -97,7 +97,7 @@ internal object LoginPacket : PacketFactory<LoginPacket.LoginPacketResponse, Log
// ignored t16a because array5 is null // ignored t16a because array5 is null
t154(client.ssoSequenceId) t154(client.ssoSequenceId)
t141(client.device.simInfo, client.ipv6NetType, client.device.apn) t141(client.device.simInfo, client.networkType, client.device.apn)
t8(2052) t8(2052)
// ignored t511 because domain is null // ignored t511 because domain is null
......
...@@ -34,7 +34,7 @@ abstract class DeviceInfo( ...@@ -34,7 +34,7 @@ abstract class DeviceInfo(
abstract val imsiMd5: ByteArray abstract val imsiMd5: ByteArray
abstract val ipAddress: ByteArray abstract val ipAddress: String
abstract val androidId: ByteArray abstract val androidId: ByteArray
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment