Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/master'

jiahua.liu 6 rokov pred
rodič
commit
3bf219d7d3

+ 3 - 3
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,

+ 4 - 5
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) }
         }
     }
 }

+ 16 - 0
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('.')
+            }
+        }
+    }
+}

+ 2 - 1
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
     )
 }