Enhanced output

This commit is contained in:
Him188moe 2019-09-07 19:55:55 +08:00
parent 09495c0ca9
commit 2c108b17a2
3 changed files with 23 additions and 12 deletions

View File

@ -279,7 +279,7 @@ class RobotNetworkHandler(private val robot: Robot) : Closeable {
*/ */
inner class DebugHandler : PacketHandler() { inner class DebugHandler : PacketHandler() {
override fun onPacketReceived(packet: ServerPacket) { override fun onPacketReceived(packet: ServerPacket) {
if (!packet.javaClass.name.endsWith("Encrypted")) { if (!packet.javaClass.name.endsWith("Encrypted") && !packet.javaClass.name.endsWith("Raw")) {
robot notice "Packet received: $packet" robot notice "Packet received: $packet"
} }
if (packet is ServerEventPacket) { if (packet is ServerEventPacket) {

View File

@ -49,7 +49,7 @@ class ClientVerificationCodeTransmissionRequestPacket(
@PacketId("00 BA 32") @PacketId("00 BA 32")
@ExperimentalUnsignedTypes @ExperimentalUnsignedTypes
class ClientVerificationCodeSubmitPacket( class ClientVerificationCodeSubmitPacket(
private val packetId: Int, private val packetIdLast: Int,
private val qq: Long, private val qq: Long,
private val token0825: ByteArray, private val token0825: ByteArray,
private val verificationCode: String, private val verificationCode: String,
@ -60,7 +60,7 @@ class ClientVerificationCodeSubmitPacket(
} }
override fun encode() { override fun encode() {
this.writeByte(packetId)//part of packet id this.writeByte(packetIdLast)//part of packet id
this.writeQQ(qq) this.writeQQ(qq)
this.writeHex(Protocol.fixVer) this.writeHex(Protocol.fixVer)
@ -84,6 +84,10 @@ class ClientVerificationCodeSubmitPacket(
it.writeHex(Protocol.key00BAFix) it.writeHex(Protocol.key00BAFix)
} }
} }
override fun getFixedId(): String {
return this.idHex + " " + packetIdLast
}
} }
@ExperimentalUnsignedTypes @ExperimentalUnsignedTypes
@ -120,12 +124,12 @@ fun main() {
@PacketId("00 BA 31") @PacketId("00 BA 31")
@ExperimentalUnsignedTypes @ExperimentalUnsignedTypes
class ClientVerificationCodeRefreshPacket( class ClientVerificationCodeRefreshPacket(
private val packetId: Int, private val packetIdLast: Int,
private val qq: Long, private val qq: Long,
private val token0825: ByteArray private val token0825: ByteArray
) : ClientPacket() { ) : ClientPacket() {
override fun encode() { override fun encode() {
this.writeByte(packetId)//part of packet id this.writeByte(packetIdLast)//part of packet id
this.writeQQ(qq) this.writeQQ(qq)
this.writeHex(Protocol.fixVer) this.writeHex(Protocol.fixVer)
@ -141,19 +145,17 @@ class ClientVerificationCodeRefreshPacket(
it.writeHex(Protocol.key00BAFix) it.writeHex(Protocol.key00BAFix)
} }
} }
override fun getFixedId(): String {
return this.idHex + " " + packetIdLast
}
} }
/** /**
* 验证码输入错误 * 验证码输入错误
*/ */
@PacketId("00 BA 32") @PacketId("00 BA 32")
class ServerVerificationCodeWrongPacket(input: DataInputStream, val dataSize: Int, packetId: ByteArray) : ServerVerificationCodeTransmissionPacket(input, dataSize, packetId) { class ServerVerificationCodeWrongPacket(input: DataInputStream, dataSize: Int, packetId: ByteArray) : ServerVerificationCodeTransmissionPacket(input, dataSize, packetId)
override fun decode() {
MiraiLogger debug dataSize
super.decode()
}
}
/** /**
* 服务器发送验证码图片文件一部分过来 * 服务器发送验证码图片文件一部分过来
@ -183,6 +185,10 @@ open class ServerVerificationCodeTransmissionPacket(input: DataInputStream, priv
this.token00BA = this.input.readNBytesAt(dataSize - 56 - 2, 40) this.token00BA = this.input.readNBytesAt(dataSize - 56 - 2, 40)
this.packetIdLast = packetId[3].toInt() this.packetIdLast = packetId[3].toInt()
} }
override fun getFixedId(): String {
return this.idHex + " " + packetIdLast
}
} }
/* /*

View File

@ -17,8 +17,13 @@ class ClientChangeOnlineStatusPacket(
private val loginStatus: ClientLoginStatus private val loginStatus: ClientLoginStatus
) : ClientPacket() { ) : ClientPacket() {
override fun getFixedId(): String {
return this.idHex + " ?? ??";
}
override fun encode() { override fun encode() {
this.writeRandom(2)//part of packet id this.writeRandom(2)//part of packet id
this.writeQQ(qq) this.writeQQ(qq)
this.writeHex(Protocol.fixVer2) this.writeHex(Protocol.fixVer2)
this.encryptAndWrite(sessionKey) { this.encryptAndWrite(sessionKey) {