Moved package

This commit is contained in:
Him188 2019-09-30 03:08:29 +08:00
parent 94e445a1bb
commit 738c76752f
52 changed files with 255 additions and 244 deletions

View File

@ -4,7 +4,7 @@ import lombok.Getter;
import net.mamoe.mirai.event.MiraiEventManager;
import net.mamoe.mirai.event.events.server.ServerDisabledEvent;
import net.mamoe.mirai.event.events.server.ServerEnabledEvent;
import net.mamoe.mirai.network.packet.login.LoginState;
import net.mamoe.mirai.network.protocol.tim.packet.login.LoginState;
import net.mamoe.mirai.task.MiraiTaskManager;
import net.mamoe.mirai.utils.*;
import net.mamoe.mirai.utils.config.MiraiConfig;
@ -172,7 +172,7 @@ public final class MiraiServer {
getLogger().info("Initializing [Bot] " + section.getString("account"));
try {
Bot bot = new Bot(section);
var state = bot.network.tryLogin$mirai_core().get();
var state = bot.network.tryLogin$mirai_core().of();
//bot.network.tryLogin$mirai_core().whenComplete((state, e) -> {
if (state == LoginState.SUCCESS) {
Bot.instances.add(bot);
@ -181,7 +181,7 @@ public final class MiraiServer {
getLogger().error(" Login Failed with error " + state);
bot.close();
}
// }).get();
// }).of();
} catch (Throwable e) {
e.printStackTrace();

View File

@ -3,7 +3,7 @@ package net.mamoe.mirai;
import net.mamoe.mirai.contact.Group;
import net.mamoe.mirai.contact.QQ;
import net.mamoe.mirai.network.BotNetworkHandler;
import net.mamoe.mirai.network.BotNetworkHandlerImpl;
import net.mamoe.mirai.network.protocol.tim.TIMBotNetworkHandler;
import net.mamoe.mirai.utils.BotAccount;
import net.mamoe.mirai.utils.ContactList;
import net.mamoe.mirai.utils.MiraiLogger;
@ -22,7 +22,7 @@ import java.util.concurrent.atomic.AtomicInteger;
* <br>
* {@link Bot} 3 个模块组成.
* {@linkplain ContactSystem 联系人管理}: 可通过 {@link Bot#contacts} 访问
* {@linkplain BotNetworkHandlerImpl 网络处理器}: 可通过 {@link Bot#network} 访问
* {@linkplain TIMBotNetworkHandler 网络处理器}: 可通过 {@link Bot#network} 访问
* {@linkplain BotAccount 机器人账号信息}: 可通过 {@link Bot#account} 访问
* <br>
* 若你需要得到机器人的 QQ 账号, 请访问 {@link Bot#account}
@ -32,11 +32,11 @@ import java.util.concurrent.atomic.AtomicInteger;
* Bot that is the base of the whole program.
* It consists of
* a {@link ContactSystem}, which manage contacts such as {@link QQ} and {@link Group};
* a {@link BotNetworkHandlerImpl}, which manages the connection to the server;
* a {@link TIMBotNetworkHandler}, which manages the connection to the server;
* a {@link BotAccount}, which stores the account information(e.g. qq number the bot)
* <br>
* To get all the QQ contacts, access {@link Bot#account}
* To get all the Robot instance, access {@link Bot#instances}
* To of all the QQ contacts, access {@link Bot#account}
* To of all the Robot instance, access {@link Bot#instances}
* </p>
*
* @author Him188moe
@ -105,7 +105,7 @@ public final class Bot implements Closeable {
this.logger = Objects.requireNonNull(logger);
this.logger.setIdentity("Bot" + this.id + "(" + this.account.getQqNumber() + ")");
this.network = new BotNetworkHandlerImpl(this);
this.network = new TIMBotNetworkHandler(this);
}

View File

@ -2,7 +2,7 @@ package net.mamoe.mirai
import net.mamoe.mirai.contact.Group
import net.mamoe.mirai.contact.QQ
import net.mamoe.mirai.network.packet.ClientPacket
import net.mamoe.mirai.network.protocol.tim.packet.ClientPacket
/**
* The mirror of functions in inner classes of [Bot]

View File

@ -1,7 +1,7 @@
package net.mamoe.mirai.event.events.network
import net.mamoe.mirai.Bot
import net.mamoe.mirai.network.packet.ClientPacket
import net.mamoe.mirai.network.protocol.tim.packet.ClientPacket
abstract class ClientPacketEvent<out P : ClientPacket>(bot: Bot, packet: P) : PacketEvent<P>(bot, packet)

View File

@ -2,7 +2,7 @@ package net.mamoe.mirai.event.events.network
import net.mamoe.mirai.Bot
import net.mamoe.mirai.event.events.bot.BotEvent
import net.mamoe.mirai.network.packet.Packet
import net.mamoe.mirai.network.protocol.tim.packet.Packet
/**
* @author Him188moe

View File

@ -1,7 +1,7 @@
package net.mamoe.mirai.event.events.network
import net.mamoe.mirai.Bot
import net.mamoe.mirai.network.packet.ServerPacket
import net.mamoe.mirai.network.protocol.tim.packet.ServerPacket
abstract class ServerPacketEvent<out P : ServerPacket>(bot: Bot, packet: P) : PacketEvent<P>(bot, packet)

View File

@ -3,9 +3,9 @@ package net.mamoe.mirai.message.defaults
import net.mamoe.mirai.message.FaceID
import net.mamoe.mirai.message.Message
import net.mamoe.mirai.message.MessageKey
import net.mamoe.mirai.network.packet.readLVNumber
import net.mamoe.mirai.network.packet.writeHex
import net.mamoe.mirai.network.packet.writeLVByteArray
import net.mamoe.mirai.network.protocol.tim.packet.readLVNumber
import net.mamoe.mirai.network.protocol.tim.packet.writeHex
import net.mamoe.mirai.network.protocol.tim.packet.writeLVByteArray
import net.mamoe.mirai.utils.lazyDecode
import net.mamoe.mirai.utils.lazyEncode

View File

@ -3,7 +3,7 @@ package net.mamoe.mirai.message.defaults
import net.mamoe.mirai.message.Message
import net.mamoe.mirai.message.MessageId
import net.mamoe.mirai.message.MessageKey
import net.mamoe.mirai.network.packet.*
import net.mamoe.mirai.network.protocol.tim.packet.*
import net.mamoe.mirai.utils.lazyDecode
import net.mamoe.mirai.utils.lazyEncode
import net.mamoe.mirai.utils.skip

View File

@ -2,9 +2,9 @@ package net.mamoe.mirai.message.defaults
import net.mamoe.mirai.message.Message
import net.mamoe.mirai.message.MessageKey
import net.mamoe.mirai.network.packet.readLVString
import net.mamoe.mirai.network.packet.writeLVByteArray
import net.mamoe.mirai.network.packet.writeLVString
import net.mamoe.mirai.network.protocol.tim.packet.readLVString
import net.mamoe.mirai.network.protocol.tim.packet.writeLVByteArray
import net.mamoe.mirai.network.protocol.tim.packet.writeLVString
import net.mamoe.mirai.utils.lazyDecode
import net.mamoe.mirai.utils.lazyEncode

View File

@ -2,11 +2,11 @@ package net.mamoe.mirai.message.defaults
import net.mamoe.mirai.contact.Contact
import net.mamoe.mirai.network.LoginSession
import net.mamoe.mirai.network.packet.image.ClientTryGetImageIDPacket
import net.mamoe.mirai.network.packet.image.ServerTryGetImageIDFailedPacket
import net.mamoe.mirai.network.packet.image.ServerTryGetImageIDResponsePacket
import net.mamoe.mirai.network.packet.image.ServerTryGetImageIDSuccessPacket
import net.mamoe.mirai.network.packet.md5
import net.mamoe.mirai.network.protocol.tim.packet.image.ClientTryGetImageIDPacket
import net.mamoe.mirai.network.protocol.tim.packet.image.ServerTryGetImageIDFailedPacket
import net.mamoe.mirai.network.protocol.tim.packet.image.ServerTryGetImageIDResponsePacket
import net.mamoe.mirai.network.protocol.tim.packet.image.ServerTryGetImageIDSuccessPacket
import net.mamoe.mirai.network.protocol.tim.packet.md5
import net.mamoe.mirai.utils.ImageNetworkUtils
import net.mamoe.mirai.utils.toByteArray
import net.mamoe.mirai.utils.toUHexString

View File

@ -1,13 +1,17 @@
package net.mamoe.mirai.network
import net.mamoe.mirai.network.BotNetworkHandlerImpl.BotSocket
import net.mamoe.mirai.network.BotNetworkHandlerImpl.Login
import net.mamoe.mirai.network.handler.*
import net.mamoe.mirai.network.packet.ClientPacket
import net.mamoe.mirai.network.packet.Packet
import net.mamoe.mirai.network.packet.ServerEventPacket
import net.mamoe.mirai.network.packet.ServerPacket
import net.mamoe.mirai.network.packet.login.LoginState
import net.mamoe.mirai.network.protocol.tim.TIMBotNetworkHandler.BotSocket
import net.mamoe.mirai.network.protocol.tim.TIMBotNetworkHandler.Login
import net.mamoe.mirai.network.protocol.tim.handler.ActionPacketHandler
import net.mamoe.mirai.network.protocol.tim.handler.DataPacketSocket
import net.mamoe.mirai.network.protocol.tim.handler.MessagePacketHandler
import net.mamoe.mirai.network.protocol.tim.handler.TemporaryPacketHandler
import net.mamoe.mirai.network.protocol.tim.internal.handler.*
import net.mamoe.mirai.network.protocol.tim.packet.ClientPacket
import net.mamoe.mirai.network.protocol.tim.packet.Packet
import net.mamoe.mirai.network.protocol.tim.packet.ServerEventPacket
import net.mamoe.mirai.network.protocol.tim.packet.ServerPacket
import net.mamoe.mirai.network.protocol.tim.packet.login.LoginState
import java.io.Closeable
import java.util.concurrent.CompletableFuture

View File

@ -1,10 +1,10 @@
package net.mamoe.mirai.network
import net.mamoe.mirai.Bot
import net.mamoe.mirai.network.handler.DataPacketSocket
import net.mamoe.mirai.network.handler.TemporaryPacketHandler
import net.mamoe.mirai.network.packet.ClientPacket
import net.mamoe.mirai.network.packet.ServerPacket
import net.mamoe.mirai.network.protocol.tim.handler.DataPacketSocket
import net.mamoe.mirai.network.protocol.tim.handler.TemporaryPacketHandler
import net.mamoe.mirai.network.protocol.tim.packet.ClientPacket
import net.mamoe.mirai.network.protocol.tim.packet.ServerPacket
import net.mamoe.mirai.utils.getGTK
import java.util.concurrent.CompletableFuture

View File

@ -1,13 +0,0 @@
package net.mamoe.mirai.network.packet.login
import net.mamoe.mirai.network.packet.PacketId
import net.mamoe.mirai.network.packet.ServerPacket
import java.io.DataInputStream
/**
* Congratulations!
*
* @author Him188moe
*/
@PacketId("00 EC")
class ServerLoginSuccessPacket(input: DataInputStream) : ServerPacket(input)

View File

@ -1,4 +1,4 @@
package net.mamoe.mirai.network
package net.mamoe.mirai.network.protocol.tim
import kotlinx.coroutines.*
import net.mamoe.mirai.Bot
@ -6,9 +6,13 @@ import net.mamoe.mirai.event.events.bot.BotLoginSucceedEvent
import net.mamoe.mirai.event.events.network.BeforePacketSendEvent
import net.mamoe.mirai.event.events.network.PacketSentEvent
import net.mamoe.mirai.event.events.network.ServerPacketReceivedEvent
import net.mamoe.mirai.network.handler.*
import net.mamoe.mirai.network.packet.*
import net.mamoe.mirai.network.packet.login.*
import net.mamoe.mirai.network.BotNetworkHandler
import net.mamoe.mirai.network.LoginSession
import net.mamoe.mirai.network.NetworkScope
import net.mamoe.mirai.network.protocol.tim.handler.*
import net.mamoe.mirai.network.protocol.tim.internal.handler.*
import net.mamoe.mirai.network.protocol.tim.packet.*
import net.mamoe.mirai.network.protocol.tim.packet.login.*
import net.mamoe.mirai.task.MiraiThreadPool
import net.mamoe.mirai.utils.*
import java.io.Closeable
@ -29,7 +33,7 @@ import javax.imageio.ImageIO
* @author Him188moe
*/
@Suppress("EXPERIMENTAL_API_USAGE")//to simplify code
internal class BotNetworkHandlerImpl(private val bot: Bot) : BotNetworkHandler {
internal class TIMBotNetworkHandler(private val bot: Bot) : BotNetworkHandler {
override val socket: BotSocket = BotSocket()
lateinit var login: Login
@ -56,7 +60,7 @@ internal class BotNetworkHandlerImpl(private val bot: Bot) : BotNetworkHandler {
* @param touchingTimeoutMillis 连接每个服务器的 timeout
*/
override fun tryLogin(touchingTimeoutMillis: Long): CompletableFuture<LoginState> {
val ipQueue: LinkedList<String> = LinkedList(Protocol.SERVER_IP)
val ipQueue: LinkedList<String> = LinkedList(TIMProtocol.SERVER_IP)
val future = CompletableFuture<LoginState>()
fun login() {
@ -185,7 +189,7 @@ internal class BotNetworkHandlerImpl(private val bot: Bot) : BotNetworkHandler {
*/
fun touch(serverAddress: String, timeoutMillis: Long): CompletableFuture<LoginState> {
bot.info("Connecting server: $serverAddress")
if (this@BotNetworkHandlerImpl::login.isInitialized) {
if (this@TIMBotNetworkHandler::login.isInitialized) {
login.close()
}
login = Login()
@ -231,7 +235,7 @@ internal class BotNetworkHandlerImpl(private val bot: Bot) : BotNetworkHandler {
}
}
override fun getOwner(): Bot = this@BotNetworkHandlerImpl.bot
override fun getOwner(): Bot = this@TIMBotNetworkHandler.bot
override fun close() {
this.socket?.close()

View File

@ -1,6 +1,6 @@
@file:Suppress("EXPERIMENTAL_API_USAGE")
package net.mamoe.mirai.network
package net.mamoe.mirai.network.protocol.tim
import net.mamoe.mirai.utils.hexToBytes
import net.mamoe.mirai.utils.lazyDecode
@ -9,10 +9,13 @@ import java.net.InetAddress
import java.util.*
import java.util.stream.Collectors
typealias TIM = TIMProtocol
/**
* @author Him188moe
*/
object Protocol {
object TIMProtocol {
val SERVER_IP: List<String> = object : ArrayList<String>() {
init {
//add("183.60.56.29")

View File

@ -1,15 +1,15 @@
package net.mamoe.mirai.network.handler
package net.mamoe.mirai.network.protocol.tim.handler
import kotlinx.coroutines.runBlocking
import net.mamoe.mirai.network.LoginSession
import net.mamoe.mirai.network.packet.*
import net.mamoe.mirai.network.packet.action.AddFriendResult
import net.mamoe.mirai.network.packet.action.ClientAddFriendPacket
import net.mamoe.mirai.network.packet.action.ClientCanAddFriendPacket
import net.mamoe.mirai.network.packet.action.ServerCanAddFriendResponsePacket
import net.mamoe.mirai.network.packet.image.ServerTryGetImageIDFailedPacket
import net.mamoe.mirai.network.packet.image.ServerTryGetImageIDResponsePacket
import net.mamoe.mirai.network.packet.image.ServerTryGetImageIDSuccessPacket
import net.mamoe.mirai.network.protocol.tim.packet.*
import net.mamoe.mirai.network.protocol.tim.packet.action.AddFriendResult
import net.mamoe.mirai.network.protocol.tim.packet.action.ClientAddFriendPacket
import net.mamoe.mirai.network.protocol.tim.packet.action.ClientCanAddFriendPacket
import net.mamoe.mirai.network.protocol.tim.packet.action.ServerCanAddFriendResponsePacket
import net.mamoe.mirai.network.protocol.tim.packet.image.ServerTryGetImageIDFailedPacket
import net.mamoe.mirai.network.protocol.tim.packet.image.ServerTryGetImageIDResponsePacket
import net.mamoe.mirai.network.protocol.tim.packet.image.ServerTryGetImageIDSuccessPacket
import net.mamoe.mirai.task.MiraiThreadPool
import net.mamoe.mirai.utils.getGTK
import java.awt.image.BufferedImage

View File

@ -1,17 +1,17 @@
package net.mamoe.mirai.network.handler
package net.mamoe.mirai.network.protocol.tim.handler
import net.mamoe.mirai.Bot
import net.mamoe.mirai.event.events.network.ServerPacketReceivedEvent
import net.mamoe.mirai.network.BotNetworkHandlerImpl
import net.mamoe.mirai.network.protocol.tim.TIMBotNetworkHandler
import net.mamoe.mirai.network.LoginSession
import net.mamoe.mirai.network.packet.ClientPacket
import net.mamoe.mirai.network.packet.ServerPacket
import net.mamoe.mirai.network.protocol.tim.packet.ClientPacket
import net.mamoe.mirai.network.protocol.tim.packet.ServerPacket
import java.io.Closeable
/**
* 网络接口.
* 发包 / 处理包.
* 仅可通过 [BotNetworkHandlerImpl.socket] 得到实例.
* 仅可通过 [TIMBotNetworkHandler.socket] 得到实例.
*
* @author Him188moe
*/

View File

@ -1,4 +1,4 @@
package net.mamoe.mirai.network.handler
package net.mamoe.mirai.network.protocol.tim.handler
import net.mamoe.mirai.contact.Group
import net.mamoe.mirai.contact.QQ
@ -8,14 +8,14 @@ import net.mamoe.mirai.getGroupByNumber
import net.mamoe.mirai.getQQ
import net.mamoe.mirai.message.defaults.MessageChain
import net.mamoe.mirai.network.LoginSession
import net.mamoe.mirai.network.packet.ServerFriendMessageEventPacket
import net.mamoe.mirai.network.packet.ServerGroupMessageEventPacket
import net.mamoe.mirai.network.packet.ServerGroupUploadFileEventPacket
import net.mamoe.mirai.network.packet.ServerPacket
import net.mamoe.mirai.network.packet.action.ClientSendFriendMessagePacket
import net.mamoe.mirai.network.packet.action.ClientSendGroupMessagePacket
import net.mamoe.mirai.network.packet.action.ServerSendFriendMessageResponsePacket
import net.mamoe.mirai.network.packet.action.ServerSendGroupMessageResponsePacket
import net.mamoe.mirai.network.protocol.tim.packet.ServerFriendMessageEventPacket
import net.mamoe.mirai.network.protocol.tim.packet.ServerGroupMessageEventPacket
import net.mamoe.mirai.network.protocol.tim.packet.ServerGroupUploadFileEventPacket
import net.mamoe.mirai.network.protocol.tim.packet.ServerPacket
import net.mamoe.mirai.network.protocol.tim.packet.action.ClientSendFriendMessagePacket
import net.mamoe.mirai.network.protocol.tim.packet.action.ClientSendGroupMessagePacket
import net.mamoe.mirai.network.protocol.tim.packet.action.ServerSendFriendMessageResponsePacket
import net.mamoe.mirai.network.protocol.tim.packet.action.ServerSendGroupMessageResponsePacket
/**
* 处理消息事件, 承担消息发送任务.

View File

@ -1,7 +1,7 @@
package net.mamoe.mirai.network.handler
package net.mamoe.mirai.network.protocol.tim.handler
import net.mamoe.mirai.network.LoginSession
import net.mamoe.mirai.network.packet.ServerPacket
import net.mamoe.mirai.network.protocol.tim.packet.ServerPacket
import net.mamoe.mirai.utils.MiraiSynchronizedLinkedList
import java.io.Closeable

View File

@ -1,8 +1,8 @@
package net.mamoe.mirai.network.handler
package net.mamoe.mirai.network.protocol.tim.handler
import net.mamoe.mirai.network.LoginSession
import net.mamoe.mirai.network.packet.ClientPacket
import net.mamoe.mirai.network.packet.ServerPacket
import net.mamoe.mirai.network.protocol.tim.packet.ClientPacket
import net.mamoe.mirai.network.protocol.tim.packet.ServerPacket
import java.util.concurrent.CompletableFuture
import kotlin.reflect.KClass

View File

@ -1,10 +1,10 @@
@file:Suppress("EXPERIMENTAL_API_USAGE", "EXPERIMENTAL_UNSIGNED_LITERALS")
package net.mamoe.mirai.network.packet
package net.mamoe.mirai.network.protocol.tim.packet
import lombok.Getter
import net.mamoe.mirai.network.Protocol
import net.mamoe.mirai.network.packet.PacketNameFormatter.adjustName
import net.mamoe.mirai.network.protocol.tim.TIMProtocol
import net.mamoe.mirai.network.protocol.tim.packet.PacketNameFormatter.adjustName
import net.mamoe.mirai.utils.*
import java.io.DataOutputStream
import java.io.IOException
@ -26,8 +26,8 @@ abstract class ClientPacket : ByteArrayDataOutputStream(), Packet {
idHex = annotation.value.trim()
try {
this.writeHex(Protocol.head)
this.writeHex(Protocol.ver)
this.writeHex(TIMProtocol.head)
this.writeHex(TIMProtocol.ver)
this.writePacketId()
} catch (e: IOException) {
throw RuntimeException(e)
@ -43,7 +43,7 @@ abstract class ClientPacket : ByteArrayDataOutputStream(), Packet {
* Encode this packet.
*
*
* Before sending the packet, a [tail][Protocol.tail] will be added.
* Before sending the packet, a [tail][TIMProtocol.tail] will be added.
*/
@Throws(IOException::class)
protected abstract fun encode()
@ -53,7 +53,7 @@ abstract class ClientPacket : ByteArrayDataOutputStream(), Packet {
return
}
encode()
writeHex(Protocol.tail)
writeHex(TIMProtocol.tail)
}
@Throws(IOException::class)
@ -129,7 +129,7 @@ fun DataOutputStream.writeTLV0006(qq: Long, password: String, loginTime: Int, lo
it.writeRandom(4)
it.writeHex("00 02")
it.writeQQ(qq)
it.writeHex(Protocol.constantData2)
it.writeHex(TIMProtocol.constantData2)
it.writeHex("00 00 01")
it.write(firstMD5)

View File

@ -1,6 +1,6 @@
package net.mamoe.mirai.network.packet
package net.mamoe.mirai.network.protocol.tim.packet
import net.mamoe.mirai.network.Protocol
import net.mamoe.mirai.network.protocol.tim.TIMProtocol
import net.mamoe.mirai.utils.TEA
import java.io.DataInputStream
@ -19,7 +19,7 @@ class ClientAccountInfoRequestPacket(
this.writeRandom(2)//part of packet id
this.writeQQ(qq)
this.writeHex(Protocol.fixVer2)
this.writeHex(TIMProtocol.fixVer2)
this.encryptAndWrite(sessionKey) {
it.writeByte(0x88)
it.writeQQ(qq)

View File

@ -1,6 +1,6 @@
package net.mamoe.mirai.network.packet
package net.mamoe.mirai.network.protocol.tim.packet
import net.mamoe.mirai.network.Protocol
import net.mamoe.mirai.network.protocol.tim.TIMProtocol
import java.io.DataInputStream
import java.io.IOException
@ -17,7 +17,7 @@ class ClientHeartbeatPacket(
override fun encode() {
this.writeRandom(2)
this.writeQQ(qq)
this.writeHex(Protocol.fixVer)
this.writeHex(TIMProtocol.fixVer)
this.encryptAndWrite(sessionKey) {
it.writeHex("00 01 00 01")
}

View File

@ -1,4 +1,4 @@
package net.mamoe.mirai.network.packet
package net.mamoe.mirai.network.protocol.tim.packet
/**
* @author Him188moe

View File

@ -1,4 +1,4 @@
package net.mamoe.mirai.network.packet;
package net.mamoe.mirai.network.protocol.tim.packet;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;

View File

@ -1,6 +1,6 @@
package net.mamoe.mirai.network.packet
package net.mamoe.mirai.network.protocol.tim.packet
import net.mamoe.mirai.network.Protocol
import net.mamoe.mirai.network.protocol.tim.TIMProtocol
import net.mamoe.mirai.utils.TEA
import java.io.DataInputStream
@ -20,7 +20,7 @@ class ClientSKeyRequestPacket(
this.writeRandom(2)//part of packet id
this.writeQQ(qq)
this.writeHex(Protocol.fixVer2)
this.writeHex(TIMProtocol.fixVer2)
this.encryptAndWrite(sessionKey) {
it.writeHex("33 00 05 00 08 74 2E 71 71 2E 63 6F 6D 00 0A 71 75 6E 2E 71 71 2E 63 6F 6D 00 0C 71 7A 6F 6E 65 2E 71 71 2E 63 6F 6D 00 0C 6A 75 62 61 6F 2E 71 71 2E 63 6F 6D 00 09 6B 65 2E 71 71 2E 63 6F 6D")
}

View File

@ -1,13 +1,13 @@
@file:Suppress("EXPERIMENTAL_API_USAGE")
package net.mamoe.mirai.network.packet
package net.mamoe.mirai.network.protocol.tim.packet
import net.mamoe.mirai.message.Message
import net.mamoe.mirai.message.defaults.Face
import net.mamoe.mirai.message.defaults.Image
import net.mamoe.mirai.message.defaults.MessageChain
import net.mamoe.mirai.message.defaults.PlainText
import net.mamoe.mirai.network.Protocol
import net.mamoe.mirai.network.protocol.tim.TIMProtocol
import net.mamoe.mirai.utils.hexToBytes
import net.mamoe.mirai.utils.lazyDecode
import net.mamoe.mirai.utils.toUHexString
@ -362,7 +362,7 @@ class ClientEventResponsePacket(
this.write(packetIdFromServer)//packet id 4bytes
this.writeQQ(qq)
this.writeHex(Protocol.fixVer2)
this.writeHex(TIMProtocol.fixVer2)
this.encryptAndWrite(sessionKey) {
it.write(eventIdentity)
}

View File

@ -1,16 +1,16 @@
@file:Suppress("EXPERIMENTAL_API_USAGE")
package net.mamoe.mirai.network.packet
package net.mamoe.mirai.network.protocol.tim.packet
import net.mamoe.mirai.Bot
import net.mamoe.mirai.event.events.network.ServerPacketReceivedEvent
import net.mamoe.mirai.event.hookWhile
import net.mamoe.mirai.network.packet.PacketNameFormatter.adjustName
import net.mamoe.mirai.network.packet.action.ServerCanAddFriendResponsePacket
import net.mamoe.mirai.network.packet.action.ServerSendFriendMessageResponsePacket
import net.mamoe.mirai.network.packet.action.ServerSendGroupMessageResponsePacket
import net.mamoe.mirai.network.packet.image.ServerTryGetImageIDResponsePacket
import net.mamoe.mirai.network.packet.login.*
import net.mamoe.mirai.network.protocol.tim.packet.PacketNameFormatter.adjustName
import net.mamoe.mirai.network.protocol.tim.packet.action.ServerCanAddFriendResponsePacket
import net.mamoe.mirai.network.protocol.tim.packet.action.ServerSendFriendMessageResponsePacket
import net.mamoe.mirai.network.protocol.tim.packet.action.ServerSendGroupMessageResponsePacket
import net.mamoe.mirai.network.protocol.tim.packet.image.ServerTryGetImageIDResponsePacket
import net.mamoe.mirai.network.protocol.tim.packet.login.*
import net.mamoe.mirai.task.MiraiThreadPool
import net.mamoe.mirai.utils.*
import java.io.DataInputStream

View File

@ -1,6 +1,6 @@
package net.mamoe.mirai.network.packet
package net.mamoe.mirai.network.protocol.tim.packet
import net.mamoe.mirai.network.Protocol
import net.mamoe.mirai.network.protocol.tim.TIMProtocol
import net.mamoe.mirai.utils.TEA
import net.mamoe.mirai.utils.lazyEncode
import java.io.DataInputStream
@ -30,10 +30,10 @@ class ClientSessionRequestPacket(
it.writeIP(serverIp)
it.writeHex("1F 40 00 00 00 00 00 15 00 30 00 01")//fix1
it.writeHex("01 92 A5 D2 59 00 10 54 2D CF 9B 60 BF BB EC 0D D4 81 CE 36 87 DE 35 02 AE 6D ED DC 00 10 ")
it.writeHex(Protocol.fix0836)
it.writeHex(TIMProtocol.fix0836)
it.writeHex("00 36 00 12 00 02 00 01 00 00 00 05 00 00 00 00 00 00 00 00 00 00")
it.writeHex(Protocol.constantData1)
it.writeHex(Protocol.constantData2)
it.writeHex(TIMProtocol.constantData1)
it.writeHex(TIMProtocol.constantData2)
it.writeQQ(qq)
it.writeHex("00 00 00 00 00 1F 00 22 00 01")
it.writeHex("1A 68 73 66 E4 BA 79 92 CC C2 D4 EC 14 7C 8B AF 43 B0 62 FB 65 58 A9 EB 37 55 1D 26 13 A8 E5 3D")//device ID

View File

@ -1,7 +1,7 @@
package net.mamoe.mirai.network.packet
package net.mamoe.mirai.network.protocol.tim.packet
import net.mamoe.mirai.network.Protocol
import net.mamoe.mirai.network.packet.login.ClientPasswordSubmissionPacket
import net.mamoe.mirai.network.protocol.tim.TIMProtocol
import net.mamoe.mirai.network.protocol.tim.packet.login.ClientPasswordSubmissionPacket
import net.mamoe.mirai.utils.ByteArrayDataOutputStream
import net.mamoe.mirai.utils.TEA
import net.mamoe.mirai.utils.hexToBytes
@ -56,8 +56,8 @@ class ServerTouchResponsePacket(inputStream: DataInputStream) : ServerPacket(inp
class Encrypted(private val type: Type, inputStream: DataInputStream) : ServerPacket(inputStream) {
fun decrypt(): ServerTouchResponsePacket = ServerTouchResponsePacket(decryptBy(when (type) {
Type.TYPE_08_25_31_02 -> Protocol.redirectionKey.hexToBytes()
Type.TYPE_08_25_31_01 -> Protocol.touchKey.hexToBytes()
Type.TYPE_08_25_31_02 -> TIMProtocol.redirectionKey.hexToBytes()
Type.TYPE_08_25_31_01 -> TIMProtocol.touchKey.hexToBytes()
})).setId(this.idHex)
}
}
@ -74,17 +74,17 @@ class ClientTouchPacket(private val qq: Long, private val serverIp: String) : Cl
@Throws(IOException::class)
override fun encode() {
this.writeQQ(qq)
this.writeHex(Protocol.fixVer)
this.writeHex(Protocol.touchKey)
this.writeHex(TIMProtocol.fixVer)
this.writeHex(TIMProtocol.touchKey)
this.encryptAndWrite(Protocol.touchKey) {
it.writeHex(Protocol.constantData1)
it.writeHex(Protocol.constantData2)
this.encryptAndWrite(TIMProtocol.touchKey) {
it.writeHex(TIMProtocol.constantData1)
it.writeHex(TIMProtocol.constantData2)
it.writeQQ(qq)
it.writeHex("00 00 00 00 03 09 00 08 00 01")
it.writeIP(serverIp)
it.writeHex("00 02 00 36 00 12 00 02 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 14 00 1D 01 02 00 19")
it.writeHex(Protocol.publicKey)
it.writeHex(TIMProtocol.publicKey)
}
}
}
@ -99,22 +99,22 @@ class ClientServerRedirectionPacket(private val serverIP: String, private val qq
override fun encode() {
this.writeQQ(qq)
this.writeHex(Protocol.fixVer)
this.writeHex(Protocol.redirectionKey)
this.writeHex(TIMProtocol.fixVer)
this.writeHex(TIMProtocol.redirectionKey)
this.write(TEA.encrypt(object : ByteArrayDataOutputStream() {
@Throws(IOException::class)
override fun toByteArray(): ByteArray {
this.writeHex(Protocol.constantData1)
this.writeHex(Protocol.constantData2)
this.writeHex(TIMProtocol.constantData1)
this.writeHex(TIMProtocol.constantData2)
this.writeQQ(qq)
this.writeHex("00 01 00 00 03 09 00 0C 00 01")
this.writeIP(serverIP)
this.writeHex("01 6F A1 58 22 01 00 36 00 12 00 02 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 14 00 1D 01 03 00 19")
this.writeHex(Protocol.publicKey)
this.writeHex(TIMProtocol.publicKey)
return super.toByteArray()
}
}.toByteArray(), Protocol.redirectionKey.hexToBytes()))
}.toByteArray(), TIMProtocol.redirectionKey.hexToBytes()))
}
}

View File

@ -1,4 +1,4 @@
package net.mamoe.mirai.network.packet
package net.mamoe.mirai.network.protocol.tim.packet
import net.mamoe.mirai.utils.LoggerTextFormat
import net.mamoe.mirai.utils.toUHexString

View File

@ -1,6 +1,6 @@
package net.mamoe.mirai.network.packet
package net.mamoe.mirai.network.protocol.tim.packet
import net.mamoe.mirai.network.Protocol
import net.mamoe.mirai.network.protocol.tim.TIMProtocol
import net.mamoe.mirai.utils.TEA
import net.mamoe.mirai.utils.Tested
import net.mamoe.mirai.utils.hexToBytes
@ -23,21 +23,21 @@ class ClientVerificationCodeTransmissionRequestPacket(
this.writeByte(packetId)//part of packet id
this.writeQQ(qq)
this.writeHex(Protocol.fixVer)
this.writeHex(Protocol.key00BA)
this.encryptAndWrite(Protocol.key00BA) {
this.writeHex(TIMProtocol.fixVer)
this.writeHex(TIMProtocol.key00BA)
this.encryptAndWrite(TIMProtocol.key00BA) {
it.writeHex("00 02 00 00 08 04 01 E0")
it.writeHex(Protocol.constantData2)
it.writeHex(TIMProtocol.constantData2)
it.writeHex("00 00 38")
it.write(token0825)
it.writeHex("01 03 00 19")
it.writeHex(Protocol.publicKey)
it.writeHex(TIMProtocol.publicKey)
it.writeHex("13 00 05 00 00 00 00")
it.writeByte(verificationSequence)
it.writeHex("00 28")
it.write(token00BA)
it.writeHex("00 10")
it.writeHex(Protocol.key00BAFix)
it.writeHex(TIMProtocol.key00BAFix)
}
}
}
@ -62,17 +62,17 @@ class ClientVerificationCodeSubmitPacket(
this.writeByte(packetIdLast)//part of packet id
this.writeQQ(qq)
this.writeHex(Protocol.fixVer)
this.writeHex(Protocol.key00BA)
this.encryptAndWrite(Protocol.key00BA) {
this.writeHex(TIMProtocol.fixVer)
this.writeHex(TIMProtocol.key00BA)
this.encryptAndWrite(TIMProtocol.key00BA) {
it.writeHex("00 02 00 00 08 04 01 E0")
it.writeHex(Protocol.constantData2)
it.writeHex(TIMProtocol.constantData2)
it.writeHex("01 00 38")
it.write(token0825)
it.writeHex("01 03")
it.writeShort(25)
it.writeHex(Protocol.publicKey)//25
it.writeHex(TIMProtocol.publicKey)//25
it.writeHex("14 00 05 00 00 00 00 00 04")
it.write(verificationCode.toUpperCase().toByteArray())
@ -80,7 +80,7 @@ class ClientVerificationCodeSubmitPacket(
it.write(verificationToken)
it.writeShort(16)
it.writeHex(Protocol.key00BAFix)//16
it.writeHex(TIMProtocol.key00BAFix)//16
}
}
@ -103,17 +103,17 @@ class ClientVerificationCodeRefreshPacket(
this.writeByte(packetIdLast)//part of packet id
this.writeQQ(qq)
this.writeHex(Protocol.fixVer)
this.writeHex(Protocol.key00BA)
this.encryptAndWrite(Protocol.key00BA) {
this.writeHex(TIMProtocol.fixVer)
this.writeHex(TIMProtocol.key00BA)
this.encryptAndWrite(TIMProtocol.key00BA) {
it.writeHex("00 02 00 00 08 04 01 E0")
it.writeHex(Protocol.constantData2)
it.writeHex(TIMProtocol.constantData2)
it.writeHex("00 00 38")
it.write(token0825)
it.writeHex("01 03 00 19")
it.writeHex(Protocol.publicKey)
it.writeHex(TIMProtocol.publicKey)
it.writeHex("13 00 05 00 00 00 00 00 00 00 00 10")
it.writeHex(Protocol.key00BAFix)
it.writeHex(TIMProtocol.key00BAFix)
}
}
@ -194,7 +194,7 @@ abstract class ServerCatchaPacket(input: DataInputStream) : ServerPacket(input)
fun decrypt(): ServerCatchaPacket {
this.input goto 14
val data = TEA.decrypt(this.input.readAllBytes().cutTail(1), Protocol.key00BA.hexToBytes())
val data = TEA.decrypt(this.input.readAllBytes().cutTail(1), TIMProtocol.key00BA.hexToBytes())
if (id.startsWith("00 BA 32")) {
return when (data.size) {
66,

View File

@ -1,9 +1,9 @@
@file:Suppress("EXPERIMENTAL_API_USAGE", "EXPERIMENTAL_UNSIGNED_LITERALS")
package net.mamoe.mirai.network.packet.action
package net.mamoe.mirai.network.protocol.tim.packet.action
import net.mamoe.mirai.network.Protocol
import net.mamoe.mirai.network.packet.*
import net.mamoe.mirai.network.protocol.tim.TIMProtocol
import net.mamoe.mirai.network.protocol.tim.packet.*
import net.mamoe.mirai.utils.getRandomByteArray
import net.mamoe.mirai.utils.toUHexString
import java.io.DataInputStream
@ -31,7 +31,7 @@ class ClientCanAddFriendPacket(
this.write(packetIdLast)//id, 2bytes
this.writeQQ(bot)
this.writeHex(Protocol.fixVer2)
this.writeHex(TIMProtocol.fixVer2)
this.encryptAndWrite(sessionKey) {
it.writeQQ(qq)
}
@ -96,7 +96,7 @@ class ClientAddFriendPacket(
this.write(packetIdLast)//id, 2bytes
this.writeQQ(bot)
this.writeHex(Protocol.fixVer2)
this.writeHex(TIMProtocol.fixVer2)
this.encryptAndWrite(sessionKey) {
it.writeHex("01 00 01")
it.writeQQ(qq)

View File

@ -1,4 +1,4 @@
package net.mamoe.mirai.network.packet.action
package net.mamoe.mirai.network.protocol.tim.packet.action
/**
* 添加好友结果

View File

@ -1,8 +1,8 @@
package net.mamoe.mirai.network.packet.action
package net.mamoe.mirai.network.protocol.tim.packet.action
import net.mamoe.mirai.message.defaults.MessageChain
import net.mamoe.mirai.network.Protocol
import net.mamoe.mirai.network.packet.*
import net.mamoe.mirai.network.protocol.tim.TIMProtocol
import net.mamoe.mirai.network.protocol.tim.packet.*
import net.mamoe.mirai.utils.lazyEncode
import java.io.DataInputStream
@ -21,7 +21,7 @@ class ClientSendFriendMessagePacket(
this.writeRandom(2)//part of packet id
this.writeQQ(botQQ)
this.writeHex(Protocol.fixVer2)
this.writeHex(TIMProtocol.fixVer2)
this.encryptAndWrite(sessionKey) {
it.writeQQ(botQQ)
@ -38,7 +38,7 @@ class ClientSendFriendMessagePacket(
it.writeTime()
it.writeRandom(4)
it.writeHex("00 00 00 00 09 00 86")
it.writeHex(Protocol.messageConst1)//... 85 E9 BB 91
it.writeHex(TIMProtocol.messageConst1)//... 85 E9 BB 91
it.writeZero(2)
it.write(message.toByteArray())

View File

@ -1,8 +1,8 @@
package net.mamoe.mirai.network.packet.action
package net.mamoe.mirai.network.protocol.tim.packet.action
import net.mamoe.mirai.message.defaults.MessageChain
import net.mamoe.mirai.network.Protocol
import net.mamoe.mirai.network.packet.*
import net.mamoe.mirai.network.protocol.tim.TIMProtocol
import net.mamoe.mirai.network.protocol.tim.packet.*
import net.mamoe.mirai.utils.lazyEncode
import net.mamoe.mirai.utils.toUHexString
import java.io.DataInputStream
@ -20,7 +20,7 @@ class ClientSendGroupMessagePacket(
override fun encode() {
this.writeRandom(2)//part of packet id
this.writeQQ(botQQ)
this.writeHex(Protocol.fixVer2)
this.writeHex(TIMProtocol.fixVer2)
this.encryptAndWrite(sessionKey) {
val bytes = message.toByteArray()
@ -34,7 +34,7 @@ class ClientSendGroupMessagePacket(
child.writeTime()
child.writeRandom(4)
child.writeHex("00 00 00 00 09 00 86")
child.writeHex(Protocol.messageConst1)
child.writeHex(TIMProtocol.messageConst1)
child.writeZero(2)
//messages

View File

@ -1,8 +1,8 @@
@file:Suppress("EXPERIMENTAL_API_USAGE", "EXPERIMENTAL_UNSIGNED_LITERALS")
package net.mamoe.mirai.network.packet.image
package net.mamoe.mirai.network.protocol.tim.packet.image
import net.mamoe.mirai.network.packet.*
import net.mamoe.mirai.network.protocol.tim.packet.*
import net.mamoe.mirai.utils.toByteArray
import net.mamoe.mirai.utils.writeUVarInt
import java.awt.image.BufferedImage

View File

@ -1,7 +1,7 @@
package net.mamoe.mirai.network.packet.login
package net.mamoe.mirai.network.protocol.tim.packet.login
import net.mamoe.mirai.network.Protocol
import net.mamoe.mirai.network.packet.*
import net.mamoe.mirai.network.protocol.tim.TIMProtocol
import net.mamoe.mirai.network.protocol.tim.packet.*
import net.mamoe.mirai.utils.ClientLoginStatus
/**
@ -22,7 +22,7 @@ class ClientChangeOnlineStatusPacket(
this.writeRandom(2)//part of packet id
this.writeQQ(qq)
this.writeHex(Protocol.fixVer2)
this.writeHex(TIMProtocol.fixVer2)
this.encryptAndWrite(sessionKey) {
it.writeHex("01 00")
it.writeByte(loginStatus.id)

View File

@ -1,7 +1,7 @@
package net.mamoe.mirai.network.packet.login
package net.mamoe.mirai.network.protocol.tim.packet.login
import net.mamoe.mirai.network.Protocol
import net.mamoe.mirai.network.packet.*
import net.mamoe.mirai.network.protocol.tim.TIMProtocol
import net.mamoe.mirai.network.protocol.tim.packet.*
import net.mamoe.mirai.utils.TEA
import net.mamoe.mirai.utils.Tested
import net.mamoe.mirai.utils.hexToBytes
@ -25,15 +25,15 @@ class ClientPasswordSubmissionPacket(
override fun encode() {
this.writeQQ(qq)
this.writeHex(Protocol.passwordSubmissionTLV1)
this.writeHex(TIMProtocol.passwordSubmissionTLV1)
this.writeShort(25)
this.writeHex(Protocol.publicKey)//25
this.writeHex(TIMProtocol.publicKey)//25
this.writeHex("00 00 00 10")
this.writeHex(Protocol.key0836)
this.writeHex(TIMProtocol.key0836)
this.encryptAndWrite(Protocol.shareKey.hexToBytes()) {
this.encryptAndWrite(TIMProtocol.shareKey.hexToBytes()) {
it.writePart1(qq, password, loginTime, loginIP, tgtgtKey, token0825)
it.writePart2()
}
@ -68,15 +68,15 @@ open class ClientLoginResendPacket internal constructor(
) : ClientPacket() {
override fun encode() {
this.writeQQ(qq)
this.writeHex(Protocol.passwordSubmissionTLV1)
this.writeHex(TIMProtocol.passwordSubmissionTLV1)
this.writeShort(25)
this.writeHex(Protocol.publicKey)//25
this.writeHex(TIMProtocol.publicKey)//25
this.writeHex("00 00 00 10")//=16
this.writeHex(Protocol.key0836)//16
this.writeHex(TIMProtocol.key0836)//16
this.encryptAndWrite(Protocol.shareKey.hexToBytes()) {
this.encryptAndWrite(TIMProtocol.shareKey.hexToBytes()) {
it.writePart1(qq, password, loginTime, loginIP, tgtgtKey, token0825, tlv0006)
it.writeHex("01 10") //tag
@ -114,12 +114,12 @@ private fun DataOutputStream.writePart1(qq: Long, password: String, loginTime: I
this.writeTLV0006(qq, password, loginTime, loginIP, tgtgtKey)
}
//fix
this.writeHex(Protocol.passwordSubmissionTLV2)
this.writeHex(TIMProtocol.passwordSubmissionTLV2)
this.writeHex("00 1A")//tag
this.writeHex("00 40")//length
this.write(TEA.encrypt(Protocol.passwordSubmissionTLV2.hexToBytes(), tgtgtKey))
this.writeHex(Protocol.constantData1)
this.writeHex(Protocol.constantData2)
this.write(TEA.encrypt(TIMProtocol.passwordSubmissionTLV2.hexToBytes(), tgtgtKey))
this.writeHex(TIMProtocol.constantData1)
this.writeHex(TIMProtocol.constantData2)
this.writeQQ(qq)
this.writeZero(4)

View File

@ -1,4 +1,4 @@
package net.mamoe.mirai.network.packet.login
package net.mamoe.mirai.network.protocol.tim.packet.login
/**
* @author Him188moe

View File

@ -1,6 +1,6 @@
package net.mamoe.mirai.network.packet.login
package net.mamoe.mirai.network.protocol.tim.packet.login
import net.mamoe.mirai.network.packet.ServerPacket
import net.mamoe.mirai.network.protocol.tim.packet.ServerPacket
import java.io.DataInputStream
/**

View File

@ -1,9 +1,9 @@
package net.mamoe.mirai.network.packet.login
package net.mamoe.mirai.network.protocol.tim.packet.login
import net.mamoe.mirai.network.Protocol
import net.mamoe.mirai.network.packet.PacketId
import net.mamoe.mirai.network.packet.ServerPacket
import net.mamoe.mirai.network.packet.goto
import net.mamoe.mirai.network.protocol.tim.TIMProtocol
import net.mamoe.mirai.network.protocol.tim.packet.PacketId
import net.mamoe.mirai.network.protocol.tim.packet.ServerPacket
import net.mamoe.mirai.network.protocol.tim.packet.goto
import net.mamoe.mirai.utils.Tested
import java.io.DataInputStream
@ -49,7 +49,7 @@ class ServerLoginResponseKeyExchangePacket(input: DataInputStream, val flag: Fla
@Tested
fun decrypt(tgtgtKey: ByteArray): ServerLoginResponseKeyExchangePacket {
return ServerLoginResponseKeyExchangePacket(this.decryptBy(Protocol.shareKey, tgtgtKey), flag).setId(this.idHex)
return ServerLoginResponseKeyExchangePacket(this.decryptBy(TIMProtocol.shareKey, tgtgtKey), flag).setId(this.idHex)
}
}
}

View File

@ -1,12 +1,12 @@
@file:Suppress("EXPERIMENTAL_API_USAGE")
package net.mamoe.mirai.network.packet.login
package net.mamoe.mirai.network.protocol.tim.packet.login
import net.mamoe.mirai.network.Protocol
import net.mamoe.mirai.network.packet.ServerPacket
import net.mamoe.mirai.network.packet.goto
import net.mamoe.mirai.network.packet.readNBytesAt
import net.mamoe.mirai.network.packet.readString
import net.mamoe.mirai.network.protocol.tim.TIMProtocol
import net.mamoe.mirai.network.protocol.tim.packet.ServerPacket
import net.mamoe.mirai.network.protocol.tim.packet.goto
import net.mamoe.mirai.network.protocol.tim.packet.readNBytesAt
import net.mamoe.mirai.network.protocol.tim.packet.readString
import net.mamoe.mirai.utils.Tested
import net.mamoe.mirai.utils.toUHexString
import java.io.DataInputStream
@ -57,7 +57,7 @@ class ServerLoginResponseSuccessPacket(input: DataInputStream) : ServerPacket(in
fun decrypt(tgtgtKey: ByteArray): ServerLoginResponseSuccessPacket {
input goto 14
return ServerLoginResponseSuccessPacket(this.decryptBy(Protocol.shareKey, tgtgtKey)).setId(this.idHex)
return ServerLoginResponseSuccessPacket(this.decryptBy(TIMProtocol.shareKey, tgtgtKey)).setId(this.idHex)
}
}

View File

@ -1,11 +1,11 @@
@file:Suppress("EXPERIMENTAL_API_USAGE")
package net.mamoe.mirai.network.packet.login
package net.mamoe.mirai.network.protocol.tim.packet.login
import net.mamoe.mirai.network.Protocol
import net.mamoe.mirai.network.packet.ServerPacket
import net.mamoe.mirai.network.packet.dataInputStream
import net.mamoe.mirai.network.packet.goto
import net.mamoe.mirai.network.protocol.tim.TIMProtocol
import net.mamoe.mirai.network.protocol.tim.packet.ServerPacket
import net.mamoe.mirai.network.protocol.tim.packet.dataInputStream
import net.mamoe.mirai.network.protocol.tim.packet.goto
import net.mamoe.mirai.utils.Tested
import net.mamoe.mirai.utils.hexToUBytes
import java.io.DataInputStream
@ -44,7 +44,7 @@ class ServerLoginResponseVerificationCodeInitPacket(input: DataInputStream, priv
fun decrypt(): ServerLoginResponseVerificationCodeInitPacket {
this.input goto 14
val data = this.decryptBy(Protocol.shareKey).goto(0).readAllBytes()
val data = this.decryptBy(TIMProtocol.shareKey).goto(0).readAllBytes()
return ServerLoginResponseVerificationCodeInitPacket(data.dataInputStream(), data.size).setId(this.idHex)
}
}

View File

@ -0,0 +1,13 @@
package net.mamoe.mirai.network.protocol.tim.packet.login
import net.mamoe.mirai.network.protocol.tim.packet.PacketId
import net.mamoe.mirai.network.protocol.tim.packet.ServerPacket
import java.io.DataInputStream
/**
* Congratulations!
*
* @author Him188moe
*/
@PacketId("00 EC")
class ServerLoginSuccessPacket(input: DataInputStream) : ServerPacket(input)

View File

@ -4,7 +4,7 @@ package net.mamoe.mirai.utils;
* QQ 在线状态
*
* @author Him188moe
* @see net.mamoe.mirai.network.packet.login.ClientChangeOnlineStatusPacket
* @see net.mamoe.mirai.network.protocol.tim.packet.login.ClientChangeOnlineStatusPacket
*/
public enum ClientLoginStatus {
/**

View File

@ -1,8 +1,8 @@
package net.mamoe.mirai.utils
import net.mamoe.mirai.Bot
import net.mamoe.mirai.network.packet.ServerPacket
import net.mamoe.mirai.network.packet.goto
import net.mamoe.mirai.network.protocol.tim.packet.ServerPacket
import net.mamoe.mirai.network.protocol.tim.packet.goto
import java.text.SimpleDateFormat
import java.util.*

View File

@ -2,8 +2,8 @@
package net.mamoe.mirai.utils
import net.mamoe.mirai.network.Protocol
import net.mamoe.mirai.network.packet.dataInputStream
import net.mamoe.mirai.network.protocol.tim.TIMProtocol
import net.mamoe.mirai.network.protocol.tim.packet.dataInputStream
import java.awt.image.BufferedImage
import java.io.ByteArrayOutputStream
import java.io.DataInputStream
@ -60,10 +60,10 @@ fun UByteArray.toUHexString(): String = this.toUHexString(" ")
fun Byte.toUHexString(): String = this.toUByte().toString(16)
fun String.hexToBytes(): ByteArray = Protocol.hexToBytes(this)
fun String.hexToBytes(): ByteArray = TIMProtocol.hexToBytes(this)
fun String.hexToUBytes(): UByteArray = Protocol.hexToUBytes(this)
fun String.hexToUBytes(): UByteArray = TIMProtocol.hexToUBytes(this)
fun String.hexToInt(): Int = hexToBytes().toUInt().toInt()

View File

@ -2,7 +2,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import net.mamoe.mirai.Bot
import net.mamoe.mirai.network.packet.login.LoginState
import net.mamoe.mirai.network.protocol.tim.packet.login.LoginState
import net.mamoe.mirai.utils.BotAccount
import net.mamoe.mirai.utils.Console
import java.util.*

View File

@ -2,8 +2,8 @@ import kotlin.ranges.IntRange;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;
import net.mamoe.mirai.network.Protocol;
import net.mamoe.mirai.network.packet.ClientPacketKt;
import net.mamoe.mirai.network.protocol.tim.TIMProtocol;
import net.mamoe.mirai.network.protocol.tim.packet.ClientPacketKt;
import net.mamoe.mirai.utils.UtilsKt;
import java.awt.*;
@ -44,7 +44,7 @@ public class HexComparator {
private static class ConstMatcher {
private static final List<Field> CONST_FIELDS = new LinkedList<>() {{
List.of(Protocol.class).forEach(aClass -> Arrays.stream(aClass.getDeclaredFields()).peek(this::add).forEach(Field::trySetAccessible));
List.of(TIMProtocol.class).forEach(aClass -> Arrays.stream(aClass.getDeclaredFields()).peek(this::add).forEach(Field::trySetAccessible));
List.of(TestConsts.class).forEach(aClass -> Arrays.stream(aClass.getDeclaredFields()).peek(this::add).forEach(Field::trySetAccessible));
}};

View File

@ -3,12 +3,12 @@
import jpcap.JpcapCaptor
import jpcap.packet.IPPacket
import jpcap.packet.UDPPacket
import net.mamoe.mirai.network.Protocol
import net.mamoe.mirai.network.packet.*
import net.mamoe.mirai.network.packet.login.ServerLoginResponseFailedPacket
import net.mamoe.mirai.network.packet.login.ServerLoginResponseKeyExchangePacket
import net.mamoe.mirai.network.packet.login.ServerLoginResponseSuccessPacket
import net.mamoe.mirai.network.packet.login.ServerLoginResponseVerificationCodeInitPacket
import net.mamoe.mirai.network.protocol.tim.TIMProtocol
import net.mamoe.mirai.network.protocol.tim.packet.*
import net.mamoe.mirai.network.protocol.tim.packet.login.ServerLoginResponseFailedPacket
import net.mamoe.mirai.network.protocol.tim.packet.login.ServerLoginResponseKeyExchangePacket
import net.mamoe.mirai.network.protocol.tim.packet.login.ServerLoginResponseSuccessPacket
import net.mamoe.mirai.network.protocol.tim.packet.login.ServerLoginResponseVerificationCodeInitPacket
import net.mamoe.mirai.utils.*
import java.io.DataInputStream
@ -153,17 +153,17 @@ object Main {
}
"08 36" -> {
println("tim的 passwordSubmissionKey1 = " + it.readNBytes(Protocol.passwordSubmissionTLV1.hexToBytes().size).toUHexString())
println("tim的 passwordSubmissionKey1 = " + it.readNBytes(TIMProtocol.passwordSubmissionTLV1.hexToBytes().size).toUHexString())
//it.skipHex(Protocol.passwordSubmissionKey1)
println(it.readNBytes(2).toUHexString())
println("tim的 publicKey = " + it.readNBytes(Protocol.publicKey.hexToBytes().size).toUHexString())
println("tim的 publicKey = " + it.readNBytes(TIMProtocol.publicKey.hexToBytes().size).toUHexString())
println(it.readNBytes(2).toUHexString())
println("tim的 key0836=" + it.readLVByteArray().toUHexString())
//it.skipHex(Protocol.key0836)
val encrypted = it.readAllBytes()
println(encrypted.size)
println(encrypted.toUHexString())
val tlv0006data = lazyDecode(encrypted.decryptBy(Protocol.shareKey)) { section ->
val tlv0006data = lazyDecode(encrypted.decryptBy(TIMProtocol.shareKey)) { section ->
section.skip(2 + 2 + 56 + 2)
section.skip(section.readShort())//device name
section.skip(6 + 4 + 2 + 2)
@ -173,7 +173,7 @@ object Main {
}
lazyDecode(tlv0006data) { tlv0006 ->
tlv0006.skip(4 + 2 + 4)
tlv0006.skipHex(Protocol.constantData2)
tlv0006.skipHex(TIMProtocol.constantData2)
tlv0006.skip(3)
tlv0006.skip(16 + 4 + 1 + 4 * 3 + 4 + 8 + 2)
tlv0006.skipHex("15 74 C4 89 85 7A 19 F5 5E A9 C9 A3 5E 8A 5A 9B")

View File

@ -7,7 +7,7 @@ import net.mamoe.mirai.event.events.qq.FriendMessageEvent
import net.mamoe.mirai.event.hookAlways
import net.mamoe.mirai.message.defaults.Image
import net.mamoe.mirai.message.defaults.PlainText
import net.mamoe.mirai.network.packet.login.LoginState
import net.mamoe.mirai.network.protocol.tim.packet.login.LoginState
import net.mamoe.mirai.utils.BotAccount
import net.mamoe.mirai.utils.Console
@ -45,13 +45,13 @@ fun main() {
}
/*it.message eq "发图片群" -> sendGroupMessage(Group(session.bot, 580266363), PlainText("test") + UnsolvedImage(File("C:\\Users\\Him18\\Desktop\\faceImage_1559564477775.jpg")).also { image ->
image.upload(session, Group(session.bot, 580266363)).get()
image.upload(session, Group(session.bot, 580266363)).of()
})*/
it.message eq "发图片群2" -> Group(bot, 580266363).sendMessage(Image("{7AA4B3AA-8C3C-0F45-2D9B-7F302A0ACEAA}.jpg"))
/* it.message eq "发图片" -> sendFriendMessage(it.sender, PlainText("test") + UnsolvedImage(File("C:\\Users\\Him18\\Desktop\\faceImage_1559564477775.jpg")).also { image ->
image.upload(session, it.sender).get()
image.upload(session, it.sender).of()
})*/
it.message eq "发图片2" -> it.reply(PlainText("test") + Image("{7AA4B3AA-8C3C-0F45-2D9B-7F302A0ACEAA}.jpg"))
}