diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt index fb47841fc..c6e736ac6 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt @@ -163,12 +163,11 @@ internal class GroupImpl( Highway.RequestDataTrans( uin = bot.uin, command = "PicUp.DataUp", - buildVer = bot.client.buildVer, + sequenceId = bot.client.nextHighwayDataTransSequenceId(), uKey = response.uKey, data = image.input, dataSize = image.inputSize.toInt(), - md5 = image.md5, - sequenceId = bot.client.nextHighwayDataTransSequenceId() + md5 = image.md5 ) ) // } @@ -182,6 +181,7 @@ internal class GroupImpl( println(proto.contentToString()) println(readBytes(bodyLength).toUHexString()) } + socket.close() val resourceId = image.calculateImageResourceId() return NotOnlineImageFromFile( resourceId = resourceId, diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/highway/Codec.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/highway/Codec.kt index c7092324b..edc89d58e 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/highway/Codec.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/highway/Codec.kt @@ -67,13 +67,12 @@ object Highway { uin: Long, command: String, sequenceId: Int, - buildVer: String, appId: Int = 537062845, dataFlag: Int = 4096, commandId: Int = 2, localId: Int = 2052, - uKey: ByteArray, + data: Input, dataSize: Int, md5: ByteArray @@ -87,7 +86,6 @@ object Highway { appid = appId, dataflag = dataFlag, commandId = commandId, - buildVer = buildVer, localeId = localId ) val segHead = CSDataHighwayHead.SegHead( @@ -97,6 +95,7 @@ object Highway { md5 = md5, fileMd5 = md5 ) + //println(data.readBytes().toUHexString()) return Codec.buildC2SData(dataHighwayHead, segHead, EMPTY_BYTE_ARRAY, null, data, dataSize) } @@ -121,9 +120,9 @@ object Highway { writeInt(head.size) writeInt(bodySize) writeFully(head) - body.copyTo(this) + check(body.copyTo(this).toInt() == bodySize) { "bad body size" } writeByte(41) - } + }.also { println(it.remaining) } } } } \ No newline at end of file diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/PacketFactory.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/PacketFactory.kt index bc5c59c2d..301c060b5 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/PacketFactory.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/PacketFactory.kt @@ -5,6 +5,7 @@ import kotlinx.io.pool.useInstance import net.mamoe.mirai.data.Packet import net.mamoe.mirai.event.Subscribable import net.mamoe.mirai.qqandroid.QQAndroidBot +import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.TroopManagement import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.image.ImageUpPacket import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.image.ImgStore import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.image.LongConn diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/type.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/type.kt new file mode 100644 index 000000000..20c29237c --- /dev/null +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/type.kt @@ -0,0 +1,16 @@ +package net.mamoe.mirai.qqandroid.utils + + +fun Int.toIpV4AddressString(): String { + @Suppress("NAME_SHADOWING") + var var0 = this.toLong() and 0xFFFFFFFF + return buildString { + for (var2 in 3 downTo 0) { + append(255L and var0 % 256L) + var0 /= 256L + if (var2 != 0) { + append('.') + } + } + } +} \ No newline at end of file diff --git a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/ExternalImageAndroid.kt b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/ExternalImageAndroid.kt index 1c0d32fd2..7a33ca976 100644 --- a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/ExternalImageAndroid.kt +++ b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/ExternalImageAndroid.kt @@ -34,7 +34,8 @@ fun File.toExternalImage(): ExternalImage { md5 = this.inputStream().use { it.md5() }, imageFormat = this.nameWithoutExtension, input = this.inputStream().asInput(IoBuffer.Pool), - inputSize = this.length() + inputSize = this.length(), + filename = this.name ) }