mirai/mirai-core
StageGuard 60d360baad
[core] Update login protocol, deprecate DeviceInfo constructor and serializer (#2613)
* [core] update protocol

* [core] fix t106 decryption key

* [core] handle t543

* [core] revert t106

* [core] revert native test pow data

* [core] split build version and apk version name

* [core] pass time to t1 instead of time diff

* [core] remove unused t106 writer & rename param ip to ipv4 of t1 and t106

* [core] implement qimei for t545
TODO: aes and rsa crypto for nativeMain

* [core] fix base64 decode for android in rsa

* [core] fix unix timestamp parsing on native and add more tests

* [api] DeviceInfo move `androidId` to main constructor and adjust test.

* [api] do not request qimei when protocol is neither  ANDROID_PHONE nor ANDROID_PAD

* [api] implement aes crypto for native target

* [api] rsa crypto for multi-platform

* [api] crypto test

* [api] move freePointer util

* [api] openssl api compatibility

* [core] add explicit `androidId` param

* [core] remove unused `tlvCount`

* [core] optimize crypto

* [core] move Qimei to network package

* [core] move appId to protocol

* [core] lazily initialize qimeiLogger

* [core] write byte array to BIO mem

* [core] move qimei to client, add direct serializer for DeviceInfo

* [core] optimize DeviceInfoDelegateSerializer

* [core] real user-agent when requesting qimei

* [core] use `DeviceInfo.version.release`

* [core] remove unused wtlogin packet

* [core] do what constructor serializer should do

* [core] fix endless cache validation caused by not upgrading device info file.

* [core] request qimei before fast-login

* [core] tlv order

* [core] remove wrong tests and print more detail when deserialize failed.

* [core] device info upgrade for native

* [core] request qimei after validating cache

* [core] DeviceInfo compatibility

* [core] DeviceInfo test name

* [core] compatibility serializer

* [core] disable rsa crypto test on android unit test

* [core] move rsa impl to jvmBase

* action

* import

* api dump

* api dump

* revert wrong api dumps

* [core] Deprecate DeviceInfo constructor and serializer, provide `serializeToString` and `deserializeFromString` for replacement

* rerun ci

* optimize

* use serializer directly

* optimize test

* revert

* [core] CacheValidator use `DeviceInfo.serializeToString()` instead of direct serializer

* Remove `println` in `DeviceInfoManager`

* Add legacy deserialize overload for ABI compatibility

* Remove uncompleted docs for DeviceInfo

* Suppress DeviceInfo deprecation warnings for internal usages

---------

Co-authored-by: Him188 <Him188@mamoe.net>
2023-05-21 13:45:46 +01:00
..
compatibility-validation Fix project structure for Dokka 2022-01-06 20:26:52 +00:00
src [core] Update login protocol, deprecate DeviceInfo constructor and serializer (#2613) 2023-05-21 13:45:46 +01:00
.gitignore Implement mirai-core for native 2022-07-20 00:30:16 +08:00
build.gradle.kts [build] Fix checkAndroidApiLevel tasks when building without ADK 2023-05-06 11:20:49 +01:00
README.md Update docs and improve source code readability 2021-05-09 15:31:50 +08:00

mirai-core

mirai 核心实现模块。首先阅读 mirai-core-api/README.md

本文仅介绍重要部分。

架构

包名 描述
net.mamoe.mirai.internal mirai 核心 API 的实现
.contact 联系人实现
.message 消息系统的实现
.network 网络层实现
.utils 工具类

net.mamoe.mirai.internal.contact

AbstractContact

AbstractContact.kt

所有 Contact 实现的基类. 实现生命周期等.

SendMessageHandler

SendMessageHandler.kt

处理 mirai 消息系统 Message 到协议数据结构的转换, 并处理长消息上传, 音乐转发上传等.

net.mamoe.mirai.internal.message

ReceiveMessageTransformer

ReceiveMessageHandler.kt

处理协议数据结构到 Message 的转换. 设有 RefinableMessage 处理长消息下载, 合并转发下载并展开等.

RefinableMessage

RefinableMessage.kt

支持处理长消息下载, 合并转发下载并展开等.

Image 实现

imagesImpl.kt

图片的实现的基类为 AbstractImage.

在底层协议, 群图片与私聊图片很不同. 因此图片实现可以是 GroupImageFriendImage.

图片又细分了 OnlineImageOfflineImage. 故有 OnlineGroupImage 等四个类型, 及他们分别的 Impl.

OnlineImage 为通过 Contact.uploadImage 上传得到的, 或刚刚从服务器接收的图片对象. OfflineImage 则为反序列化得到的对象.

MessageSource 实现

MessageSourceInternal.kt

MessageSource 在协议底层十分复杂,