1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 11:07:40 +08:00

refactor: packets.BuildUniPacket -> c.uniPacket

mostly auto-generated by

```
rf '
ex {
    var c QQClient
    var seq uint16
    var payload []byte
    var command string
    BuildUniPacket(c.Uin, seq, command, 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload) -> c.uniPacket(seq, command, payload)
}
'
```
This commit is contained in:
wdvxdr 2021-12-17 22:58:41 +08:00
parent f464a0d474
commit 1c29ac7d96
No known key found for this signature in database
GPG Key ID: 703F8C071DE7A1B6
29 changed files with 329 additions and 264 deletions

View File

@ -8,6 +8,7 @@ import (
"github.com/Mrs4s/MiraiGo/binary"
"github.com/Mrs4s/MiraiGo/binary/jce"
"github.com/Mrs4s/MiraiGo/client/internal/codec"
"github.com/Mrs4s/MiraiGo/client/pb"
"github.com/Mrs4s/MiraiGo/client/pb/cmd0x352"
"github.com/Mrs4s/MiraiGo/client/pb/msg"
@ -27,7 +28,7 @@ var (
func (c *QQClient) buildLoginPacket() (uint16, []byte) {
seq := c.nextSeq()
req := packets.BuildOicqRequestPacket(c.Uin, 0x0810, c.ecdh, c.RandomKey, func(w *binary.Writer) {
req := c.buildOicqRequestPacket(c.Uin, 0x0810, binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(9)
if c.AllowSlider {
w.WriteUInt16(0x17)
@ -87,15 +88,15 @@ func (c *QQClient) buildLoginPacket() (uint16, []byte) {
w.Write(tlv.T516())
w.Write(tlv.T521(0))
w.Write(tlv.T525(tlv.T536([]byte{0x01, 0x00})))
})
sso := packets.BuildSsoPacket(seq, c.version.AppId, c.version.SubAppId, "wtlogin.login", c.deviceInfo.IMEI, []byte{}, c.OutGoingPacketSessionId, req, c.ksid)
packet := packets.BuildLoginPacket(c.Uin, 2, make([]byte, 16), sso, []byte{})
}))
sso := packets.BuildSsoPacket(seq, c.version.AppId, c.version.SubAppId, "wtlogin.login", c.deviceInfo.IMEI, EmptyBytes, c.OutGoingPacketSessionId, req, c.ksid)
packet := packets.BuildLoginPacket(c.Uin, 2, make([]byte, 16), sso, EmptyBytes)
return seq, packet
}
func (c *QQClient) buildDeviceLockLoginPacket() (uint16, []byte) {
seq := c.nextSeq()
req := packets.BuildOicqRequestPacket(c.Uin, 0x0810, c.ecdh, c.RandomKey, func(w *binary.Writer) {
req := c.buildOicqRequestPacket(c.Uin, 0x0810, binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(20)
w.WriteUInt16(4)
@ -103,16 +104,16 @@ func (c *QQClient) buildDeviceLockLoginPacket() (uint16, []byte) {
w.Write(tlv.T104(c.t104))
w.Write(tlv.T116(c.version.MiscBitmap, c.version.SubSigmap))
w.Write(tlv.T401(c.g))
})
sso := packets.BuildSsoPacket(seq, c.version.AppId, c.version.SubAppId, "wtlogin.login", c.deviceInfo.IMEI, []byte{}, c.OutGoingPacketSessionId, req, c.ksid)
packet := packets.BuildLoginPacket(c.Uin, 2, make([]byte, 16), sso, []byte{})
}))
sso := packets.BuildSsoPacket(seq, c.version.AppId, c.version.SubAppId, "wtlogin.login", c.deviceInfo.IMEI, EmptyBytes, c.OutGoingPacketSessionId, req, c.ksid)
packet := packets.BuildLoginPacket(c.Uin, 2, make([]byte, 16), sso, EmptyBytes)
return seq, packet
}
func (c *QQClient) buildQRCodeFetchRequestPacket() (uint16, []byte) {
watch := genVersionInfo(AndroidWatch)
seq := c.nextSeq()
req := packets.BuildOicqRequestPacket(0, 0x812, c.ecdh, c.RandomKey, func(w *binary.Writer) {
req := c.buildOicqRequestPacket(0, 0x0812, binary.NewWriterF(func(w *binary.Writer) {
w.WriteHex(`0001110000001000000072000000`) // trans header
w.WriteUInt32(uint32(time.Now().Unix()))
w.Write(packets.BuildCode2DRequestPacket(0, 0, 0x31, func(w *binary.Writer) {
@ -130,16 +131,16 @@ func (c *QQClient) buildQRCodeFetchRequestPacket() (uint16, []byte) {
w.Write(tlv.T33(c.deviceInfo.Guid))
w.Write(tlv.T35(8))
}))
})
sso := packets.BuildSsoPacket(seq, watch.AppId, c.version.SubAppId, "wtlogin.trans_emp", c.deviceInfo.IMEI, []byte{}, c.OutGoingPacketSessionId, req, c.ksid)
packet := packets.BuildLoginPacket(0, 2, make([]byte, 16), sso, []byte{})
}))
sso := packets.BuildSsoPacket(seq, watch.AppId, c.version.SubAppId, "wtlogin.trans_emp", c.deviceInfo.IMEI, EmptyBytes, c.OutGoingPacketSessionId, req, c.ksid)
packet := packets.BuildLoginPacket(0, 2, make([]byte, 16), sso, EmptyBytes)
return seq, packet
}
func (c *QQClient) buildQRCodeResultQueryRequestPacket(sig []byte) (uint16, []byte) {
watch := genVersionInfo(AndroidWatch)
seq := c.nextSeq()
req := packets.BuildOicqRequestPacket(0, 0x812, c.ecdh, c.RandomKey, func(w *binary.Writer) {
req := c.buildOicqRequestPacket(0, 0x0812, binary.NewWriterF(func(w *binary.Writer) {
w.WriteHex(`0000620000001000000072000000`) // trans header
w.WriteUInt32(uint32(time.Now().Unix()))
w.Write(packets.BuildCode2DRequestPacket(1, 0, 0x12, func(w *binary.Writer) {
@ -153,15 +154,15 @@ func (c *QQClient) buildQRCodeResultQueryRequestPacket(sig []byte) (uint16, []by
w.WriteBytesShort(EmptyBytes)
w.WriteUInt16(0) // const
}))
})
sso := packets.BuildSsoPacket(seq, watch.AppId, c.version.SubAppId, "wtlogin.trans_emp", c.deviceInfo.IMEI, []byte{}, c.OutGoingPacketSessionId, req, c.ksid)
packet := packets.BuildLoginPacket(0, 2, make([]byte, 16), sso, []byte{})
}))
sso := packets.BuildSsoPacket(seq, watch.AppId, c.version.SubAppId, "wtlogin.trans_emp", c.deviceInfo.IMEI, EmptyBytes, c.OutGoingPacketSessionId, req, c.ksid)
packet := packets.BuildLoginPacket(0, 2, make([]byte, 16), sso, EmptyBytes)
return seq, packet
}
func (c *QQClient) buildQRCodeLoginPacket(t106, t16a, t318 []byte) (uint16, []byte) {
seq := c.nextSeq()
req := packets.BuildOicqRequestPacket(c.Uin, 0x0810, c.ecdh, c.RandomKey, func(w *binary.Writer) {
req := c.buildOicqRequestPacket(c.Uin, 0x0810, binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(9)
w.WriteUInt16(24)
@ -227,15 +228,15 @@ func (c *QQClient) buildQRCodeLoginPacket(t106, t16a, t318 []byte) (uint16, []by
})
w.Write(wb)
cl()
})
sso := packets.BuildSsoPacket(seq, c.version.AppId, c.version.SubAppId, "wtlogin.login", c.deviceInfo.IMEI, []byte{}, c.OutGoingPacketSessionId, req, c.ksid)
packet := packets.BuildLoginPacket(c.Uin, 2, make([]byte, 16), sso, []byte{})
}))
sso := packets.BuildSsoPacket(seq, c.version.AppId, c.version.SubAppId, "wtlogin.login", c.deviceInfo.IMEI, EmptyBytes, c.OutGoingPacketSessionId, req, c.ksid)
packet := packets.BuildLoginPacket(c.Uin, 2, make([]byte, 16), sso, EmptyBytes)
return seq, packet
}
func (c *QQClient) buildCaptchaPacket(result string, sign []byte) (uint16, []byte) {
seq := c.nextSeq()
req := packets.BuildOicqRequestPacket(c.Uin, 0x810, c.ecdh, c.RandomKey, func(w *binary.Writer) {
req := c.buildOicqRequestPacket(c.Uin, 0x0810, binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(2) // sub command
w.WriteUInt16(4)
@ -243,15 +244,15 @@ func (c *QQClient) buildCaptchaPacket(result string, sign []byte) (uint16, []byt
w.Write(tlv.T8(2052))
w.Write(tlv.T104(c.t104))
w.Write(tlv.T116(c.version.MiscBitmap, c.version.SubSigmap))
})
sso := packets.BuildSsoPacket(seq, c.version.AppId, c.version.SubAppId, "wtlogin.login", c.deviceInfo.IMEI, []byte{}, c.OutGoingPacketSessionId, req, c.ksid)
packet := packets.BuildLoginPacket(c.Uin, 2, make([]byte, 16), sso, []byte{})
}))
sso := packets.BuildSsoPacket(seq, c.version.AppId, c.version.SubAppId, "wtlogin.login", c.deviceInfo.IMEI, EmptyBytes, c.OutGoingPacketSessionId, req, c.ksid)
packet := packets.BuildLoginPacket(c.Uin, 2, make([]byte, 16), sso, EmptyBytes)
return seq, packet
}
func (c *QQClient) buildSMSRequestPacket() (uint16, []byte) {
seq := c.nextSeq()
req := packets.BuildOicqRequestPacket(c.Uin, 0x810, c.ecdh, c.RandomKey, func(w *binary.Writer) {
req := c.buildOicqRequestPacket(c.Uin, 0x0810, binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(8)
w.WriteUInt16(6)
@ -261,15 +262,15 @@ func (c *QQClient) buildSMSRequestPacket() (uint16, []byte) {
w.Write(tlv.T174(c.t174))
w.Write(tlv.T17A(9))
w.Write(tlv.T197())
})
sso := packets.BuildSsoPacket(seq, c.version.AppId, c.version.SubAppId, "wtlogin.login", c.deviceInfo.IMEI, []byte{}, c.OutGoingPacketSessionId, req, c.ksid)
packet := packets.BuildLoginPacket(c.Uin, 2, make([]byte, 16), sso, []byte{})
}))
sso := packets.BuildSsoPacket(seq, c.version.AppId, c.version.SubAppId, "wtlogin.login", c.deviceInfo.IMEI, EmptyBytes, c.OutGoingPacketSessionId, req, c.ksid)
packet := packets.BuildLoginPacket(c.Uin, 2, make([]byte, 16), sso, EmptyBytes)
return seq, packet
}
func (c *QQClient) buildSMSCodeSubmitPacket(code string) (uint16, []byte) {
seq := c.nextSeq()
req := packets.BuildOicqRequestPacket(c.Uin, 0x810, c.ecdh, c.RandomKey, func(w *binary.Writer) {
req := c.buildOicqRequestPacket(c.Uin, 0x0810, binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(7)
w.WriteUInt16(7)
@ -280,15 +281,15 @@ func (c *QQClient) buildSMSCodeSubmitPacket(code string) (uint16, []byte) {
w.Write(tlv.T17C(code))
w.Write(tlv.T401(c.g))
w.Write(tlv.T198())
})
sso := packets.BuildSsoPacket(seq, c.version.AppId, c.version.SubAppId, "wtlogin.login", c.deviceInfo.IMEI, []byte{}, c.OutGoingPacketSessionId, req, c.ksid)
packet := packets.BuildLoginPacket(c.Uin, 2, make([]byte, 16), sso, []byte{})
}))
sso := packets.BuildSsoPacket(seq, c.version.AppId, c.version.SubAppId, "wtlogin.login", c.deviceInfo.IMEI, EmptyBytes, c.OutGoingPacketSessionId, req, c.ksid)
packet := packets.BuildLoginPacket(c.Uin, 2, make([]byte, 16), sso, EmptyBytes)
return seq, packet
}
func (c *QQClient) buildTicketSubmitPacket(ticket string) (uint16, []byte) {
seq := c.nextSeq()
req := packets.BuildOicqRequestPacket(c.Uin, 0x810, c.ecdh, c.RandomKey, func(w *binary.Writer) {
req := c.buildOicqRequestPacket(c.Uin, 0x0810, binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(2)
w.WriteUInt16(4)
@ -296,15 +297,15 @@ func (c *QQClient) buildTicketSubmitPacket(ticket string) (uint16, []byte) {
w.Write(tlv.T8(2052))
w.Write(tlv.T104(c.t104))
w.Write(tlv.T116(c.version.MiscBitmap, c.version.SubSigmap))
})
sso := packets.BuildSsoPacket(seq, c.version.AppId, c.version.SubAppId, "wtlogin.login", c.deviceInfo.IMEI, []byte{}, c.OutGoingPacketSessionId, req, c.ksid)
packet := packets.BuildLoginPacket(c.Uin, 2, make([]byte, 16), sso, []byte{})
}))
sso := packets.BuildSsoPacket(seq, c.version.AppId, c.version.SubAppId, "wtlogin.login", c.deviceInfo.IMEI, EmptyBytes, c.OutGoingPacketSessionId, req, c.ksid)
packet := packets.BuildLoginPacket(c.Uin, 2, make([]byte, 16), sso, EmptyBytes)
return seq, packet
}
func (c *QQClient) buildRequestTgtgtNopicsigPacket() (uint16, []byte) {
seq := c.nextSeq()
req := packets.BuildOicqRequestPacket(c.Uin, 0x0810, crypto.NewEncryptSession(c.sigInfo.t133), c.sigInfo.wtSessionTicketKey, func(w *binary.Writer) {
req := binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(15)
w.WriteUInt16(24)
@ -357,13 +358,32 @@ func (c *QQClient) buildRequestTgtgtNopicsigPacket() (uint16, []byte) {
// w.Write(tlv.545())
w.Write(tlv.T545([]byte(c.deviceInfo.IMEI)))
})
packet := packets.BuildUniPacket(c.Uin, seq, "wtlogin.exchange_emp", 2, c.OutGoingPacketSessionId, []byte{}, make([]byte, 16), req)
return seq, packet
oicq := codec.OICQ{
Uin: uint32(c.Uin),
Command: 0x810,
EncryptMethod: crypto.NewEncryptSession(c.sigInfo.t133),
Key: c.sigInfo.wtSessionTicketKey,
Body: req,
}
uni := codec.Uni{
Uin: c.Uin,
Seq: seq,
CommandName: "wtlogin.exchange_emp",
EncryptType: 2,
SessionID: c.OutGoingPacketSessionId,
ExtraData: EmptyBytes,
Key: make([]byte, 16),
Body: oicq.Encode(),
}
return seq, uni.Encode()
}
func (c *QQClient) buildRequestChangeSigPacket(mainSigMap uint32) (uint16, []byte) {
seq := c.nextSeq()
req := packets.BuildOicqRequestPacket(c.Uin, 0x0810, c.ecdh, c.RandomKey, func(w *binary.Writer) {
req := c.buildOicqRequestPacket(c.Uin, 0x0810, binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(11)
w.WriteUInt16(17)
@ -402,9 +422,9 @@ func (c *QQClient) buildRequestChangeSigPacket(mainSigMap uint32) (uint16, []byt
"office.qq.com", "ti.qq.com", "mail.qq.com", "qzone.com", "mma.qq.com",
}))
// w.Write(tlv.T202(c.deviceInfo.WifiBSSID, c.deviceInfo.WifiSSID))
})
}))
sso := packets.BuildSsoPacket(seq, c.version.AppId, c.version.SubAppId, "wtlogin.exchange_emp", c.deviceInfo.IMEI, c.sigInfo.tgt, c.OutGoingPacketSessionId, req, c.ksid)
packet := packets.BuildLoginPacket(c.Uin, 2, make([]byte, 16), sso, []byte{})
packet := packets.BuildLoginPacket(c.Uin, 2, make([]byte, 16), sso, EmptyBytes)
return seq, packet
}
@ -457,7 +477,6 @@ func (c *QQClient) buildClientRegisterPacket() (uint16, []byte) {
}
func (c *QQClient) buildStatusSetPacket(status, extStatus int32) (uint16, []byte) {
seq := c.nextSeq()
svc := &jce.SvcReqRegister{
ConnType: 0,
Uin: c.Uin,
@ -490,13 +509,11 @@ func (c *QQClient) buildStatusSetPacket(status, extStatus int32) (uint16, []byte
Context: make(map[string]string),
Status: make(map[string]string),
}
packet := packets.BuildUniPacket(c.Uin, seq, "StatSvc.SetStatusFromClient", 1, c.OutGoingPacketSessionId, []byte{}, c.sigInfo.d2Key, pkt.ToBytes())
return seq, packet
return c.uniPacketWithSeq("StatSvc.SetStatusFromClient", pkt.ToBytes())
}
// ConfigPushSvc.PushResp
func (c *QQClient) buildConfPushRespPacket(t int32, pktSeq int64, jceBuf []byte) (uint16, []byte) {
seq := c.nextSeq()
req := jce.NewJceWriter()
req.WriteInt32(t, 1)
req.WriteInt64(pktSeq, 2)
@ -512,13 +529,11 @@ func (c *QQClient) buildConfPushRespPacket(t int32, pktSeq int64, jceBuf []byte)
Context: make(map[string]string),
Status: make(map[string]string),
}
packet := packets.BuildUniPacket(c.Uin, seq, "ConfigPushSvc.PushResp", 1, c.OutGoingPacketSessionId, []byte{}, c.sigInfo.d2Key, pkt.ToBytes())
return seq, packet
return c.uniPacketWithSeq("ConfigPushSvc.PushResp", pkt.ToBytes())
}
// friendlist.getFriendGroupList
func (c *QQClient) buildFriendGroupListRequestPacket(friendStartIndex, friendListCount, groupStartIndex, groupListCount int16) (uint16, []byte) {
seq := c.nextSeq()
d50, _ := proto.Marshal(&pb.D50ReqBody{
Appid: 1002,
ReqMusicSwitch: 1,
@ -554,7 +569,7 @@ func (c *QQClient) buildFriendGroupListRequestPacket(friendStartIndex, friendLis
IfGetDOVId: 0,
IfGetBothFlag: 0,
D50: d50,
D6B: []byte{},
D6B: EmptyBytes,
SnsTypeList: []int64{13580, 13581, 13582},
}
buf := &jce.RequestDataVersion3{
@ -570,8 +585,7 @@ func (c *QQClient) buildFriendGroupListRequestPacket(friendStartIndex, friendLis
Context: make(map[string]string),
Status: make(map[string]string),
}
packet := packets.BuildUniPacket(c.Uin, seq, "friendlist.getFriendGroupList", 1, c.OutGoingPacketSessionId, []byte{}, c.sigInfo.d2Key, pkt.ToBytes())
return seq, packet
return c.uniPacketWithSeq("friendlist.getFriendGroupList", pkt.ToBytes())
}
// SummaryCard.ReqSummaryCard
@ -655,8 +669,7 @@ func (c *QQClient) buildSummaryCardRequestPacket(target int64) (uint16, []byte)
Context: make(map[string]string),
Status: make(map[string]string),
}
packet := packets.BuildUniPacket(c.Uin, seq, "SummaryCard.ReqSummaryCard", 1, c.OutGoingPacketSessionId, []byte{}, c.sigInfo.d2Key, pkt.ToBytes())
return seq, packet
return seq, c.uniPacket(seq, "SummaryCard.ReqSummaryCard", pkt.ToBytes())
}
// friendlist.delFriend
@ -680,7 +693,7 @@ func (c *QQClient) buildFriendDeletePacket(target int64) (uint16, []byte) {
Context: make(map[string]string),
Status: make(map[string]string),
}
packet := packets.BuildUniPacket(c.Uin, seq, "friendlist.delFriend", 1, c.OutGoingPacketSessionId, []byte{}, c.sigInfo.d2Key, pkt.ToBytes())
packet := c.uniPacket(seq, "friendlist.delFriend", pkt.ToBytes())
return seq, packet
}
@ -711,7 +724,7 @@ func (c *QQClient) buildGroupListRequestPacket(vecCookie []byte) (uint16, []byte
Context: make(map[string]string),
Status: make(map[string]string),
}
packet := packets.BuildUniPacket(c.Uin, seq, "friendlist.GetTroopListReqV2", 1, c.OutGoingPacketSessionId, []byte{}, c.sigInfo.d2Key, pkt.ToBytes())
packet := c.uniPacket(seq, "friendlist.GetTroopListReqV2", pkt.ToBytes())
return seq, packet
}
@ -739,7 +752,7 @@ func (c *QQClient) buildGroupMemberListRequestPacket(groupUin, groupCode, nextUi
Context: make(map[string]string),
Status: make(map[string]string),
}
packet := packets.BuildUniPacket(c.Uin, seq, "friendlist.GetTroopMemberListReq", 1, c.OutGoingPacketSessionId, []byte{}, c.sigInfo.d2Key, pkt.ToBytes())
packet := c.uniPacket(seq, "friendlist.GetTroopMemberListReq", pkt.ToBytes())
return seq, packet
}
@ -754,7 +767,7 @@ func (c *QQClient) buildGroupMemberInfoRequestPacket(groupCode, uin int64) (uint
RichCardNameVer: 1,
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "group_member_card.get_group_member_card_info", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "group_member_card.get_group_member_card_info", payload)
return seq, packet
}
@ -780,12 +793,12 @@ func (c *QQClient) buildGetMessageRequestPacket(flag msg.SyncFlag, msgTime int64
OnlineSyncFlag: proto.Int32(1),
ContextFlag: proto.Int32(1),
MsgReqType: proto.Int32(1),
PubaccountCookie: []byte{},
MsgCtrlBuf: []byte{},
ServerBuf: []byte{},
PubaccountCookie: EmptyBytes,
MsgCtrlBuf: EmptyBytes,
ServerBuf: EmptyBytes,
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "MessageSvc.PbGetMsg", 1, c.OutGoingPacketSessionId, []byte{}, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "MessageSvc.PbGetMsg", payload)
return seq, packet
}
@ -794,7 +807,7 @@ func (c *QQClient) buildDeleteMessageRequestPacket(msg []*pb.MessageItem) (uint1
seq := c.nextSeq()
req := &pb.DeleteMessageRequest{Items: msg}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "MessageSvc.PbDeleteMsg", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "MessageSvc.PbDeleteMsg", payload)
return seq, packet
}
@ -822,7 +835,7 @@ func (c *QQClient) buildDeleteOnlinePushPacket(uin int64, svrip int32, pushToken
Context: make(map[string]string),
Status: make(map[string]string),
}
return packets.BuildUniPacket(c.Uin, seq, "OnlinePush.RespPush", 1, c.OutGoingPacketSessionId, []byte{}, c.sigInfo.d2Key, pkt.ToBytes())
return c.uniPacket(seq, "OnlinePush.RespPush", pkt.ToBytes())
}
// LongConn.OffPicUp
@ -850,7 +863,7 @@ func (c *QQClient) buildOffPicUpPacket(target int64, md5 []byte, size int32) (ui
},
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "LongConn.OffPicUp", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "LongConn.OffPicUp", payload)
return seq, packet
}
@ -871,7 +884,7 @@ func (c *QQClient) buildSystemMsgNewFriendPacket() (uint16, []byte) {
FriendMsgTypeFlag: 1,
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "ProfileService.Pb.ReqSystemMsgNew.Friend", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "ProfileService.Pb.ReqSystemMsgNew.Friend", payload)
return seq, packet
}
@ -898,7 +911,7 @@ func (c *QQClient) buildEditGroupTagPacket(groupCode, memberUin int64, newTag st
Context: map[string]string{},
Status: map[string]string{},
}
packet := packets.BuildUniPacket(c.Uin, seq, "friendlist.ModifyGroupCardReq", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, pkt.ToBytes())
packet := c.uniPacket(seq, "friendlist.ModifyGroupCardReq", pkt.ToBytes())
return seq, packet
}
@ -918,7 +931,7 @@ func (c *QQClient) buildEditSpecialTitlePacket(groupCode, memberUin int64, newTi
}
b, _ := proto.Marshal(body)
payload := c.packOIDBPackage(2300, 2, b)
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x8fc_2", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "OidbSvc.0x8fc_2", payload)
return seq, packet
}
@ -927,7 +940,7 @@ func (c *QQClient) buildGroupOperationPacket(body *oidb.D89AReqBody) (uint16, []
seq := c.nextSeq()
b, _ := proto.Marshal(body)
payload := c.packOIDBPackage(2202, 0, b)
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x89a_0", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "OidbSvc.0x89a_0", payload)
return seq, packet
}
@ -987,7 +1000,7 @@ func (c *QQClient) buildGroupKickPacket(groupCode, memberUin int64, kickMsg stri
}
b, _ := proto.Marshal(body)
payload := c.packOIDBPackage(2208, 0, b)
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x8a0_0", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "OidbSvc.0x8a0_0", payload)
return seq, packet
}
@ -1003,7 +1016,7 @@ func (c *QQClient) buildGroupMutePacket(groupCode, memberUin int64, time uint32)
})
payload := c.packOIDBPackage(1392, 8, b)
cl()
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x570_8", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "OidbSvc.0x570_8", payload)
return seq, packet
}
@ -1016,7 +1029,7 @@ func (c *QQClient) buildGroupPokePacket(groupCode, target int64) (uint16, []byte
}
b, _ := proto.Marshal(body)
payload := c.packOIDBPackage(3795, 1, b)
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0xed3", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "OidbSvc.0xed3", payload)
return seq, packet
}
@ -1029,7 +1042,7 @@ func (c *QQClient) buildFriendPokePacket(target int64) (uint16, []byte) {
}
b, _ := proto.Marshal(body)
payload := c.packOIDBPackage(3795, 1, b)
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0xed3", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "OidbSvc.0xed3", payload)
return seq, packet
}
@ -1048,7 +1061,7 @@ func (c *QQClient) buildGroupAdminSetPacket(groupCode, member int64, flag bool)
})
payload := c.packOIDBPackage(1372, 1, b)
cl()
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x55c_1", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "OidbSvc.0x55c_1", payload)
return seq, packet
}
@ -1074,7 +1087,7 @@ func (c *QQClient) buildQuitGroupPacket(groupCode int64) (uint16, []byte) {
Context: map[string]string{},
Status: map[string]string{},
}
packet := packets.BuildUniPacket(c.Uin, seq, "ProfileService.GroupMngReq", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, pkt.ToBytes())
packet := c.uniPacket(seq, "ProfileService.GroupMngReq", pkt.ToBytes())
return seq, packet
}
@ -1107,6 +1120,6 @@ func (c *QQClient) buildWordSegmentationPacket(data []byte) (uint16, []byte) {
Content: data,
Qua: []byte("and_537065262_8.4.5"),
})
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0xd79", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "OidbSvc.0xd79", payload)
return seq, packet
}

View File

@ -819,8 +819,8 @@ func (c *QQClient) doHeartbeat() {
for c.Online.Load() {
time.Sleep(time.Second * 30)
seq := c.nextSeq()
sso := packets.BuildSsoPacket(seq, c.version.AppId, c.version.SubAppId, "Heartbeat.Alive", c.deviceInfo.IMEI, []byte{}, c.OutGoingPacketSessionId, []byte{}, c.ksid)
packet := packets.BuildLoginPacket(c.Uin, 0, []byte{}, sso, []byte{})
sso := packets.BuildSsoPacket(seq, c.version.AppId, c.version.SubAppId, "Heartbeat.Alive", c.deviceInfo.IMEI, EmptyBytes, c.OutGoingPacketSessionId, EmptyBytes, c.ksid)
packet := packets.BuildLoginPacket(c.Uin, 0, EmptyBytes, sso, EmptyBytes)
_, err := c.sendAndWait(seq, packet)
if errors.Is(err, utils.ErrConnectionClosed) {
continue

View File

@ -21,7 +21,6 @@ import (
"github.com/Mrs4s/MiraiGo/client/pb/oidb"
"github.com/Mrs4s/MiraiGo/client/pb/profilecard"
"github.com/Mrs4s/MiraiGo/client/pb/structmsg"
"github.com/Mrs4s/MiraiGo/internal/packets"
"github.com/Mrs4s/MiraiGo/internal/proto"
"github.com/Mrs4s/MiraiGo/utils"
)
@ -803,7 +802,7 @@ func decodeSidExpiredPacket(c *QQClient, i *incomingPacketInfo, _ []byte) (inter
if err = c.registerClient(); err != nil {
return nil, errors.Wrap(err, "register error")
}
_ = c.sendPacket(packets.BuildUniPacket(c.Uin, i.SequenceId, "OnlinePush.SidTicketExpired", 1, c.OutGoingPacketSessionId, []byte{}, c.sigInfo.d2Key, EmptyBytes))
_ = c.sendPacket(c.uniPacket(i.SequenceId, "OnlinePush.SidTicketExpired", EmptyBytes))
return nil, nil
}

View File

@ -6,7 +6,6 @@ import (
"github.com/pkg/errors"
"github.com/Mrs4s/MiraiGo/client/pb/faceroam"
"github.com/Mrs4s/MiraiGo/internal/packets"
"github.com/Mrs4s/MiraiGo/internal/proto"
)
@ -39,7 +38,7 @@ func (c *QQClient) buildFaceroamRequestPacket() (uint16, []byte) {
SubCmd: proto.Uint32(1),
ReqUserInfo: &faceroam.ReqUserInfo{},
})
packet := packets.BuildUniPacket(c.Uin, seq, "Faceroam.OpReq", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "Faceroam.OpReq", payload)
return seq, packet
}

View File

@ -136,7 +136,7 @@ var SystemDeviceInfo = &DeviceInfo{
FingerPrint: []byte("mamoe/mirai/mirai:10/MIRAI.200122.001/1234567:user/release-keys"),
BootId: []byte("cb886ae2-00b6-4d68-a230-787f111d12c7"),
ProcVersion: []byte("Linux version 3.0.31-cb886ae2 (android-build@xxx.xxx.xxx.xxx.com)"),
BaseBand: []byte{},
BaseBand: EmptyBytes,
SimInfo: []byte("T-Mobile"),
OSType: []byte("android"),
MacAddress: []byte("00:50:56:C0:00:08"),

View File

@ -14,7 +14,6 @@ import (
"github.com/Mrs4s/MiraiGo/client/internal/highway"
"github.com/Mrs4s/MiraiGo/client/pb/exciting"
"github.com/Mrs4s/MiraiGo/client/pb/oidb"
"github.com/Mrs4s/MiraiGo/internal/packets"
"github.com/Mrs4s/MiraiGo/internal/proto"
"github.com/Mrs4s/MiraiGo/utils"
)
@ -297,7 +296,7 @@ func (c *QQClient) buildGroupFileUploadReqPacket(parentFolderID, fileName string
ClientVersion: "android 8.4.8",
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x6d6_0", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "OidbSvc.0x6d6_0", payload)
return seq, packet
}
@ -313,7 +312,7 @@ func (c *QQClient) buildGroupFileFeedsRequest(groupCode int64, fileID string, bu
MsgRandom: proto.Uint32(uint32(msgRand)),
}},
}})
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x6d9_4", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, req)
packet := c.uniPacket(seq, "OidbSvc.0x6d9_4", req)
return seq, packet
}
@ -341,7 +340,7 @@ func (c *QQClient) buildGroupFileListRequestPacket(groupCode int64, folderID str
ClientVersion: "android 8.4.8",
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x6d8_1", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "OidbSvc.0x6d8_1", payload)
return seq, packet
}
@ -360,7 +359,7 @@ func (c *QQClient) buildGroupFileCountRequestPacket(groupCode int64) (uint16, []
ClientVersion: "android 8.4.8",
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x6d8_1", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "OidbSvc.0x6d8_1", payload)
return seq, packet
}
@ -378,7 +377,7 @@ func (c *QQClient) buildGroupFileSpaceRequestPacket(groupCode int64) (uint16, []
ClientVersion: "android 8.4.8",
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x6d8_1", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "OidbSvc.0x6d8_1", payload)
return seq, packet
}
@ -390,7 +389,7 @@ func (c *QQClient) buildGroupFileCreateFolderPacket(groupCode int64, parentFolde
ParentFolderId: &parentFolder,
FolderName: &name,
}})
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x6d7_0", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "OidbSvc.0x6d7_0", payload)
return seq, packet
}
@ -402,7 +401,7 @@ func (c *QQClient) buildGroupFileRenameFolderPacket(groupCode int64, folderId, n
FolderId: proto.String(folderId),
NewFolderName: proto.String(newName),
}})
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x6d7_2", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "OidbSvc.0x6d7_2", payload)
return seq, packet
}
@ -413,7 +412,7 @@ func (c *QQClient) buildGroupFileDeleteFolderPacket(groupCode int64, folderId st
AppId: proto.Uint32(3),
FolderId: proto.String(folderId),
}})
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x6d7_1", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "OidbSvc.0x6d7_1", payload)
return seq, packet
}
@ -435,7 +434,7 @@ func (c *QQClient) buildGroupFileDownloadReqPacket(groupCode int64, fileId strin
Bodybuffer: b,
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x6d6_2", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "OidbSvc.0x6d6_2", payload)
return seq, packet
}
@ -456,7 +455,7 @@ func (c *QQClient) buildGroupFileDeleteReqPacket(groupCode int64, parentFolderId
ClientVersion: "android 8.4.8",
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x6d6_3", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "OidbSvc.0x6d6_3", payload)
return seq, packet
}

View File

@ -17,7 +17,6 @@ import (
"github.com/Mrs4s/MiraiGo/binary/jce"
"github.com/Mrs4s/MiraiGo/client/pb/oidb"
"github.com/Mrs4s/MiraiGo/client/pb/profilecard"
"github.com/Mrs4s/MiraiGo/internal/packets"
"github.com/Mrs4s/MiraiGo/internal/proto"
"github.com/Mrs4s/MiraiGo/utils"
)
@ -123,7 +122,7 @@ func (c *QQClient) buildGroupInfoRequestPacket(groupCode int64) (uint16, []byte)
Bodybuffer: b,
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x88d_0", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "OidbSvc.0x88d_0", payload)
return seq, packet
}
@ -187,7 +186,7 @@ func (c *QQClient) buildGroupSearchPacket(keyword string) (uint16, []byte) {
Context: make(map[string]string),
Status: make(map[string]string),
}
packet := packets.BuildUniPacket(c.Uin, seq, "SummaryCard.ReqSearch", 1, c.OutGoingPacketSessionId, []byte{}, c.sigInfo.d2Key, pkt.ToBytes())
packet := c.uniPacket(seq, "SummaryCard.ReqSearch", pkt.ToBytes())
return seq, packet
}

View File

@ -18,7 +18,6 @@ import (
"github.com/Mrs4s/MiraiGo/client/pb/msg"
"github.com/Mrs4s/MiraiGo/client/pb/multimsg"
"github.com/Mrs4s/MiraiGo/client/pb/oidb"
"github.com/Mrs4s/MiraiGo/internal/packets"
"github.com/Mrs4s/MiraiGo/internal/proto"
"github.com/Mrs4s/MiraiGo/message"
"github.com/Mrs4s/MiraiGo/utils"
@ -272,7 +271,7 @@ func (c *QQClient) buildGroupSendingPacket(groupCode int64, r, pkgNum, pkgIndex,
}(),
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "MessageSvc.PbSendMsg", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "MessageSvc.PbSendMsg", payload)
return seq, packet
}
@ -285,7 +284,7 @@ func (c *QQClient) buildGetGroupMsgRequest(groupCode, beginSeq, endSeq int64) (u
PublicGroup: proto.Bool(false),
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "MessageSvc.PbGetGroupMsg", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "MessageSvc.PbGetGroupMsg", payload)
return seq, packet
}
@ -298,7 +297,7 @@ func (c *QQClient) buildAtAllRemainRequestPacket(groupCode int64) (uint16, []byt
Uin: proto.Uint64(uint64(c.Uin)),
GroupCode: proto.Uint64(uint64(groupCode)),
})
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x8a7_0", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "OidbSvc.0x8a7_0", payload)
return seq, packet
}
@ -601,7 +600,7 @@ func (c *QQClient) buildEssenceMsgOperatePacket(groupCode int64, msgSeq, msgRand
Seq: proto.Uint32(msgSeq),
Random: proto.Uint32(msgRand),
})
packet := packets.BuildUniPacket(c.Uin, seq, commandName, 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, commandName, payload)
return seq, packet
}

View File

@ -16,7 +16,6 @@ import (
"github.com/Mrs4s/MiraiGo/binary"
"github.com/Mrs4s/MiraiGo/client/pb/channel"
"github.com/Mrs4s/MiraiGo/internal/packets"
"github.com/Mrs4s/MiraiGo/utils"
)
@ -188,7 +187,7 @@ func (s *GuildService) GetUserProfile(tinyId uint64) (*GuildUserProfile, error)
3: tinyId,
4: uint32(0),
})
packet := packets.BuildUniPacket(s.c.Uin, seq, "OidbSvcTrpcTcp.0xfc9_1", 1, s.c.OutGoingPacketSessionId, []byte{}, s.c.sigInfo.d2Key, payload)
packet := s.c.uniPacket(seq, "OidbSvcTrpcTcp.0xfc9_1", payload)
rsp, err := s.c.sendAndWaitDynamic(seq, packet)
if err != nil {
return nil, errors.Wrap(err, "send packet error")
@ -227,7 +226,7 @@ func (s *GuildService) FetchGuildMemberListWithRole(guildId, channelId uint64, s
m[13] = param
}
m[14] = roleIdIndex
packet := packets.BuildUniPacket(s.c.Uin, seq, "OidbSvcTrpcTcp.0xf5b_1", 1, s.c.OutGoingPacketSessionId, []byte{}, s.c.sigInfo.d2Key, s.c.packOIDBPackageDynamically(3931, 1, m))
packet := s.c.uniPacket(seq, "OidbSvcTrpcTcp.0xf5b_1", s.c.packOIDBPackageDynamically(3931, 1, m))
rsp, err := s.c.sendAndWaitDynamic(seq, packet)
if err != nil {
return nil, errors.Wrap(err, "send packet error")
@ -282,7 +281,7 @@ func (s *GuildService) FetchGuildMemberProfileInfo(guildId, tinyId uint64) (*Gui
3: tinyId,
4: guildId,
})
packet := packets.BuildUniPacket(s.c.Uin, seq, "OidbSvcTrpcTcp.0xf88_1", 1, s.c.OutGoingPacketSessionId, []byte{}, s.c.sigInfo.d2Key, payload)
packet := s.c.uniPacket(seq, "OidbSvcTrpcTcp.0xf88_1", payload)
rsp, err := s.c.sendAndWaitDynamic(seq, packet)
if err != nil {
return nil, errors.Wrap(err, "send packet error")
@ -307,8 +306,7 @@ func (s *GuildService) FetchGuildMemberProfileInfo(guildId, tinyId uint64) (*Gui
func (s *GuildService) GetGuildRoles(guildId uint64) ([]*GuildRole, error) {
seq := s.c.nextSeq()
packet := packets.BuildUniPacket(s.c.Uin, seq, "OidbSvcTrpcTcp.0x1019_1", 1, s.c.OutGoingPacketSessionId, []byte{}, s.c.sigInfo.d2Key,
s.c.packOIDBPackageDynamically(4121, 1, binary.DynamicProtoMessage{1: guildId}))
packet := s.c.uniPacket(seq, "OidbSvcTrpcTcp.0x1019_1", s.c.packOIDBPackageDynamically(4121, 1, binary.DynamicProtoMessage{1: guildId}))
rsp, err := s.c.sendAndWaitDynamic(seq, packet)
if err != nil {
return nil, errors.Wrap(err, "send packet error")
@ -336,21 +334,20 @@ func (s *GuildService) GetGuildRoles(guildId uint64) ([]*GuildRole, error) {
func (s *GuildService) CreateGuildRole(guildId uint64, name string, color uint32, independent bool, initialUsers []uint64) (uint64, error) {
seq := s.c.nextSeq()
u1 := uint32(1)
packet := packets.BuildUniPacket(s.c.Uin, seq, "OidbSvcTrpcTcp.0x1016_1", 1, s.c.OutGoingPacketSessionId, []byte{}, s.c.sigInfo.d2Key,
s.c.packOIDBPackageDynamically(4118, 1, binary.DynamicProtoMessage{
1: guildId,
2: binary.DynamicProtoMessage{ // todo: 未知参数
1: u1,
2: u1,
3: u1,
},
3: binary.DynamicProtoMessage{
1: name,
2: color,
3: independent,
},
4: initialUsers,
}))
packet := s.c.uniPacket(seq, "OidbSvcTrpcTcp.0x1016_1", s.c.packOIDBPackageDynamically(4118, 1, binary.DynamicProtoMessage{
1: guildId,
2: binary.DynamicProtoMessage{ // todo: 未知参数
1: u1,
2: u1,
3: u1,
},
3: binary.DynamicProtoMessage{
1: name,
2: color,
3: independent,
},
4: initialUsers,
}))
rsp, err := s.c.sendAndWaitDynamic(seq, packet)
if err != nil {
return 0, errors.Wrap(err, "send packet error")
@ -364,11 +361,10 @@ func (s *GuildService) CreateGuildRole(guildId uint64, name string, color uint32
func (s *GuildService) DeleteGuildRole(guildId uint64, roleId uint64) error {
seq := s.c.nextSeq()
packet := packets.BuildUniPacket(s.c.Uin, seq, "OidbSvcTrpcTcp.0x100e_1", 1, s.c.OutGoingPacketSessionId, []byte{}, s.c.sigInfo.d2Key,
s.c.packOIDBPackageDynamically(4110, 1, binary.DynamicProtoMessage{
1: guildId,
2: roleId,
}))
packet := s.c.uniPacket(seq, "OidbSvcTrpcTcp.0x100e_1", s.c.packOIDBPackageDynamically(4110, 1, binary.DynamicProtoMessage{
1: guildId,
2: roleId,
}))
_, err := s.c.sendAndWaitDynamic(seq, packet)
if err != nil {
return errors.Wrap(err, "send packet error")
@ -386,11 +382,10 @@ func (s *GuildService) SetUserRoleInGuild(guildId uint64, set bool, roleId uint6
} else {
setOrRemove[3] = user
}
packet := packets.BuildUniPacket(s.c.Uin, seq, "OidbSvcTrpcTcp.0x101a_1", 1, s.c.OutGoingPacketSessionId, []byte{}, s.c.sigInfo.d2Key,
s.c.packOIDBPackageDynamically(4122, 1, binary.DynamicProtoMessage{
1: guildId,
2: setOrRemove,
}))
packet := s.c.uniPacket(seq, "OidbSvcTrpcTcp.0x101a_1", s.c.packOIDBPackageDynamically(4122, 1, binary.DynamicProtoMessage{
1: guildId,
2: setOrRemove,
}))
_, err := s.c.sendAndWaitDynamic(seq, packet)
if err != nil {
return errors.Wrap(err, "send packet error")
@ -402,21 +397,20 @@ func (s *GuildService) ModifyRoleInGuild(guildId uint64, roleId uint64, name str
seq := s.c.nextSeq()
var packet []byte
u1 := uint32(1)
packet = packets.BuildUniPacket(s.c.Uin, seq, "OidbSvcTrpcTcp.0x100d_1", 1, s.c.OutGoingPacketSessionId, []byte{}, s.c.sigInfo.d2Key,
s.c.packOIDBPackageDynamically(4109, 1, binary.DynamicProtoMessage{
1: guildId,
2: roleId,
3: binary.DynamicProtoMessage{
1: u1,
2: u1,
3: u1,
},
4: binary.DynamicProtoMessage{
1: name,
2: color,
3: indepedent,
},
}))
packet = s.c.uniPacket(seq, "OidbSvcTrpcTcp.0x100d_1", s.c.packOIDBPackageDynamically(4109, 1, binary.DynamicProtoMessage{
1: guildId,
2: roleId,
3: binary.DynamicProtoMessage{
1: u1,
2: u1,
3: u1,
},
4: binary.DynamicProtoMessage{
1: name,
2: color,
3: indepedent,
},
}))
_, err := s.c.sendAndWaitDynamic(seq, packet)
if err != nil {
return errors.Wrap(err, "send packet error")
@ -441,7 +435,7 @@ func (s *GuildService) FetchGuestGuild(guildId uint64) (*GuildMeta, error) {
1: guildId,
},
})
packet := packets.BuildUniPacket(s.c.Uin, seq, "OidbSvcTrpcTcp.0xf57_9", 1, s.c.OutGoingPacketSessionId, []byte{}, s.c.sigInfo.d2Key, payload)
packet := s.c.uniPacket(seq, "OidbSvcTrpcTcp.0xf57_9", payload)
rsp, err := s.c.sendAndWaitDynamic(seq, packet)
if err != nil {
return nil, errors.Wrap(err, "send packet error")
@ -464,8 +458,7 @@ func (s *GuildService) FetchGuestGuild(guildId uint64) (*GuildMeta, error) {
func (s *GuildService) FetchChannelList(guildId uint64) (r []*ChannelInfo, e error) {
seq := s.c.nextSeq()
packet := packets.BuildUniPacket(s.c.Uin, seq, "OidbSvcTrpcTcp.0xf5d_1", 1, s.c.OutGoingPacketSessionId, []byte{}, s.c.sigInfo.d2Key,
s.c.packOIDBPackageDynamically(3933, 1, binary.DynamicProtoMessage{1: guildId, 3: binary.DynamicProtoMessage{1: uint32(1)}}))
packet := s.c.uniPacket(seq, "OidbSvcTrpcTcp.0xf5d_1", s.c.packOIDBPackageDynamically(3933, 1, binary.DynamicProtoMessage{1: guildId, 3: binary.DynamicProtoMessage{1: uint32(1)}}))
rsp, err := s.c.sendAndWaitDynamic(seq, packet)
if err != nil {
return nil, errors.Wrap(err, "send packet error")
@ -482,8 +475,7 @@ func (s *GuildService) FetchChannelList(guildId uint64) (r []*ChannelInfo, e err
func (s *GuildService) FetchChannelInfo(guildId, channelId uint64) (*ChannelInfo, error) {
seq := s.c.nextSeq()
packet := packets.BuildUniPacket(s.c.Uin, seq, "OidbSvcTrpcTcp.0xf55_1", 1, s.c.OutGoingPacketSessionId, []byte{}, s.c.sigInfo.d2Key,
s.c.packOIDBPackageDynamically(3925, 1, binary.DynamicProtoMessage{1: guildId, 2: channelId}))
packet := s.c.uniPacket(seq, "OidbSvcTrpcTcp.0xf55_1", s.c.packOIDBPackageDynamically(3925, 1, binary.DynamicProtoMessage{1: guildId, 2: channelId}))
rsp, err := s.c.sendAndWaitDynamic(seq, packet)
if err != nil {
return nil, errors.Wrap(err, "send packet error")
@ -538,7 +530,7 @@ func (s *GuildService) GetTopicChannelFeeds(guildId, channelId uint64) ([]*topic
},
})
seq := s.c.nextSeq()
packet := packets.BuildUniPacket(s.c.Uin, seq, "QChannelSvr.trpc.qchannel.commreader.ComReader.GetChannelTimelineFeeds", 1, s.c.OutGoingPacketSessionId, []byte{}, s.c.sigInfo.d2Key, payload)
packet := s.c.uniPacket(seq, "QChannelSvr.trpc.qchannel.commreader.ComReader.GetChannelTimelineFeeds", payload)
rsp, err := s.c.sendAndWaitDynamic(seq, packet)
if err != nil {
return nil, errors.New("send packet error")
@ -609,7 +601,7 @@ func (s *GuildService) PostTopicChannelFeed(guildId, channelId uint64, feed *top
},
})
seq := s.c.nextSeq()
packet := packets.BuildUniPacket(s.c.Uin, seq, "QChannelSvr.trpc.qchannel.commwriter.ComWriter.PublishFeed", 1, s.c.OutGoingPacketSessionId, []byte{}, s.c.sigInfo.d2Key, payload)
packet := s.c.uniPacket(seq, "QChannelSvr.trpc.qchannel.commwriter.ComWriter.PublishFeed", payload)
rsp, err := s.c.sendAndWaitDynamic(seq, packet)
if err != nil {
return errors.New("send packet error")
@ -631,16 +623,15 @@ func (s *GuildService) PostTopicChannelFeed(guildId, channelId uint64, feed *top
func (s *GuildService) fetchMemberRoles(guildId uint64, tinyId uint64) ([]*GuildRole, error) {
seq := s.c.nextSeq()
u1 := uint32(1)
packet := packets.BuildUniPacket(s.c.Uin, seq, "OidbSvcTrpcTcp.0x1017_1", 1, s.c.OutGoingPacketSessionId, []byte{}, s.c.sigInfo.d2Key,
s.c.packOIDBPackageDynamically(4119, 1, binary.DynamicProtoMessage{
1: guildId,
2: tinyId,
4: binary.DynamicProtoMessage{
1: u1,
2: u1,
3: u1,
},
}))
packet := s.c.uniPacket(seq, "OidbSvcTrpcTcp.0x1017_1", s.c.packOIDBPackageDynamically(4119, 1, binary.DynamicProtoMessage{
1: guildId,
2: tinyId,
4: binary.DynamicProtoMessage{
1: u1,
2: u1,
3: u1,
},
}))
rsp, err := s.c.sendAndWaitDynamic(seq, packet)
if err != nil {
return nil, errors.Wrap(err, "send packet error")
@ -750,7 +741,7 @@ func (c *QQClient) buildSyncChannelFirstViewPacket() (uint16, []byte) {
DirectMessageFlag: proto.Uint32(1),
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "trpc.group_pro.synclogic.SyncLogic.SyncFirstView", 1, c.OutGoingPacketSessionId, []byte{}, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "trpc.group_pro.synclogic.SyncLogic.SyncFirstView", payload)
return seq, packet
}

View File

@ -16,7 +16,6 @@ import (
"github.com/Mrs4s/MiraiGo/client/pb/cmd0x388"
"github.com/Mrs4s/MiraiGo/client/pb/msg"
"github.com/Mrs4s/MiraiGo/client/pb/pttcenter"
"github.com/Mrs4s/MiraiGo/internal/packets"
"github.com/Mrs4s/MiraiGo/internal/proto"
"github.com/Mrs4s/MiraiGo/message"
"github.com/Mrs4s/MiraiGo/utils"
@ -69,7 +68,7 @@ func (s *GuildService) SendGuildChannelMessage(guildId, channelId uint64, m *mes
}}
seq := s.c.nextSeq()
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(s.c.Uin, seq, "MsgProxy.SendMsg", 1, s.c.OutGoingPacketSessionId, []byte{}, s.c.sigInfo.d2Key, payload)
packet := s.c.uniPacket(seq, "MsgProxy.SendMsg", payload)
rsp, err := s.c.sendAndWaitDynamic(seq, packet)
if err != nil {
return nil, errors.Wrap(err, "send packet error")
@ -217,7 +216,7 @@ func (s *GuildService) pullChannelMessages(guildId, channelId, beginSeq, endSeq,
DirectMessageFlag: &directFlag,
})
seq := s.c.nextSeq()
packet := packets.BuildUniPacket(s.c.Uin, seq, "trpc.group_pro.synclogic.SyncLogic.GetChannelMsg", 1, s.c.OutGoingPacketSessionId, []byte{}, s.c.sigInfo.d2Key, payload)
packet := s.c.uniPacket(seq, "trpc.group_pro.synclogic.SyncLogic.GetChannelMsg", payload)
rsp, err := s.c.sendAndWaitDynamic(seq, packet)
if err != nil {
return nil, errors.Wrap(err, "send packet error")
@ -255,7 +254,7 @@ func (c *QQClient) buildGuildImageStorePacket(guildId, channelId uint64, hash []
},
CommandId: proto.Uint32(83),
})
packet := packets.BuildUniPacket(c.Uin, seq, "ImgStore.QQMeetPicUp", 1, c.OutGoingPacketSessionId, []byte{}, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "ImgStore.QQMeetPicUp", payload)
return seq, packet
}
@ -356,7 +355,7 @@ func (c *QQClient) buildPttGuildVideoUpReq(videoHash, thumbHash []byte, guildId,
pb.PttShortVideoUploadReq.ToUin = channelId
pb.ExtensionReq[0].SubBusiType = 4601
payload, _ := proto.Marshal(pb)
packet := packets.BuildUniPacket(c.Uin, seq, "PttCenterSvr.GroupShortVideoUpReq", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "PttCenterSvr.GroupShortVideoUpReq", payload)
return seq, packet
}

View File

@ -4,7 +4,6 @@ import (
"bytes"
"encoding/hex"
"image"
_ "image/gif"
"io"
"math/rand"
"os"
@ -18,7 +17,6 @@ import (
"github.com/Mrs4s/MiraiGo/client/pb/cmd0x388"
highway2 "github.com/Mrs4s/MiraiGo/client/pb/highway"
"github.com/Mrs4s/MiraiGo/client/pb/oidb"
"github.com/Mrs4s/MiraiGo/internal/packets"
"github.com/Mrs4s/MiraiGo/internal/proto"
"github.com/Mrs4s/MiraiGo/message"
"github.com/Mrs4s/MiraiGo/utils"
@ -266,7 +264,7 @@ func (c *QQClient) buildGroupImageStorePacket(groupCode int64, md5 []byte, size
Extension: EmptyBytes,
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "ImgStore.GroupPicUp", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "ImgStore.GroupPicUp", payload)
return seq, packet
}
@ -292,7 +290,7 @@ func (c *QQClient) buildGroupImageDownloadPacket(fileId, groupCode int64, fileMd
},
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "ImgStore.GroupPicDown", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "ImgStore.GroupPicDown", payload)
return seq, packet
}
@ -340,7 +338,7 @@ func (c *QQClient) buildImageOcrRequestPacket(url, md5 string, size, weight, hei
}
b, _ := proto.Marshal(body)
payload := c.packOIDBPackage(3591, 0, b)
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0xe07_0", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "OidbSvc.0xe07_0", payload)
return seq, packet
}

View File

@ -0,0 +1,40 @@
package codec
import "github.com/Mrs4s/MiraiGo/binary"
type Encryptor interface {
Encrypt([]byte, []byte) []byte
ID() byte
}
type OICQ struct {
Uin uint32
Command uint16
EncryptMethod Encryptor
Key []byte
Body []byte
}
func (m *OICQ) Encode() []byte {
body := m.EncryptMethod.Encrypt(m.Body, m.Key)
p := binary.SelectWriter()
defer binary.PutWriter(p)
p.WriteByte(0x02)
p.WriteUInt16(27 + 2 + uint16(len(body)))
p.WriteUInt16(8001)
p.WriteUInt16(m.Command)
p.WriteUInt16(1)
p.WriteUInt32(m.Uin)
p.WriteByte(3)
p.WriteByte(m.EncryptMethod.ID())
p.WriteByte(0)
p.WriteUInt32(2)
p.WriteUInt32(0)
p.WriteUInt32(0)
p.Write(body)
p.WriteByte(0x03)
return append([]byte(nil), p.Bytes()...)
}

View File

@ -0,0 +1,41 @@
package codec
import (
"strconv"
"github.com/Mrs4s/MiraiGo/binary"
)
type Uni struct {
Uin int64
Seq uint16
CommandName string
EncryptType byte
SessionID []byte
ExtraData []byte
Key []byte
Body []byte
}
func (u *Uni) Encode() []byte {
return binary.NewWriterF(func(w *binary.Writer) {
w2 := binary.SelectWriter()
{ // w.WriteIntLvPacket
w2.WriteUInt32(0x0B)
w2.WriteByte(u.EncryptType)
w2.WriteUInt32(uint32(u.Seq))
w2.WriteByte(0)
w2.WriteString(strconv.FormatInt(u.Uin, 10))
// inline NewWriterF
w3 := binary.SelectWriter()
w3.WriteUniPacket(u.CommandName, u.SessionID, u.ExtraData, u.Body)
w2.EncryptAndWrite(u.Key, w3.Bytes())
binary.PutWriter(w3)
}
data := w2.Bytes()
w.WriteUInt32(uint32(len(data) + 4))
w.Write(data)
binary.PutWriter(w2)
})
}

View File

@ -11,7 +11,6 @@ import (
"github.com/Mrs4s/MiraiGo/client/pb/longmsg"
"github.com/Mrs4s/MiraiGo/client/pb/msg"
"github.com/Mrs4s/MiraiGo/client/pb/multimsg"
"github.com/Mrs4s/MiraiGo/internal/packets"
"github.com/Mrs4s/MiraiGo/internal/proto"
"github.com/Mrs4s/MiraiGo/message"
"github.com/Mrs4s/MiraiGo/utils"
@ -42,7 +41,7 @@ func (c *QQClient) buildMultiApplyUpPacket(data, hash []byte, buType int32, grou
BuType: buType,
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "MultiMsg.ApplyUp", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "MultiMsg.ApplyUp", payload)
return seq, packet
}
@ -84,7 +83,7 @@ func (c *QQClient) buildMultiApplyDownPacket(resID string) (uint16, []byte) {
ReqChannelType: 2,
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "MultiMsg.ApplyDown", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "MultiMsg.ApplyDown", payload)
return seq, packet
}

View File

@ -4,7 +4,6 @@ import (
"github.com/pkg/errors"
"github.com/Mrs4s/MiraiGo/client/pb/cmd0x346"
"github.com/Mrs4s/MiraiGo/internal/packets"
"github.com/Mrs4s/MiraiGo/internal/proto"
)
@ -29,7 +28,7 @@ func (c *QQClient) buildOfflineFileDownloadRequestPacket(uuid []byte) (uint16, [
},
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "OfflineFilleHandleSvr.pb_ftn_CMD_REQ_APPLY_DOWNLOAD-1200", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "OfflineFilleHandleSvr.pb_ftn_CMD_REQ_APPLY_DOWNLOAD-1200", payload)
return seq, packet
}

48
client/packet.go Normal file
View File

@ -0,0 +1,48 @@
package client
import (
"github.com/Mrs4s/MiraiGo/client/internal/codec"
)
//go:noinline
func (c *QQClient) buildOicqRequestPacket(uin int64, command uint16, body []byte) []byte {
req := codec.OICQ{
Uin: uint32(uin),
Command: command,
EncryptMethod: c.ecdh,
Key: c.RandomKey,
Body: body,
}
return req.Encode()
}
//go:noinline
func (c *QQClient) uniPacketWithSeq(command string, body []byte) (uint16, []byte) {
seq := c.nextSeq()
req := codec.Uni{
Uin: c.Uin,
Seq: seq,
CommandName: command,
EncryptType: 1,
SessionID: c.OutGoingPacketSessionId,
ExtraData: EmptyBytes,
Key: c.sigInfo.d2Key,
Body: body,
}
return seq, req.Encode()
}
//go:noinline
func (c *QQClient) uniPacket(seq uint16, command string, body []byte) []byte {
req := codec.Uni{
Uin: c.Uin,
Seq: seq,
CommandName: command,
EncryptType: 1,
SessionID: c.OutGoingPacketSessionId,
ExtraData: EmptyBytes,
Key: c.sigInfo.d2Key,
Body: body,
}
return req.Encode()
}

View File

@ -7,7 +7,6 @@ import (
"github.com/pkg/errors"
"github.com/Mrs4s/MiraiGo/client/pb/msg"
"github.com/Mrs4s/MiraiGo/internal/packets"
"github.com/Mrs4s/MiraiGo/internal/proto"
"github.com/Mrs4s/MiraiGo/message"
)
@ -180,7 +179,7 @@ func (c *QQClient) buildFriendSendingPacket(target int64, msgSeq, r, pkgNum, pkg
}(),
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "MessageSvc.PbSendMsg", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "MessageSvc.PbSendMsg", payload)
return seq, packet
}
@ -214,7 +213,7 @@ func (c *QQClient) buildGroupTempSendingPacket(groupUin, target int64, msgSeq, r
}(),
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "MessageSvc.PbSendMsg", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "MessageSvc.PbSendMsg", payload)
return seq, packet
}
@ -247,6 +246,6 @@ func (c *QQClient) buildWPATempSendingPacket(uin int64, sig []byte, msgSeq, r in
}(),
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "MessageSvc.PbSendMsg", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "MessageSvc.PbSendMsg", payload)
return seq, packet
}

View File

@ -13,7 +13,6 @@ import (
"github.com/Mrs4s/MiraiGo/client/pb/cmd0x388"
"github.com/Mrs4s/MiraiGo/client/pb/msg"
"github.com/Mrs4s/MiraiGo/client/pb/pttcenter"
"github.com/Mrs4s/MiraiGo/internal/packets"
"github.com/Mrs4s/MiraiGo/internal/proto"
"github.com/Mrs4s/MiraiGo/message"
"github.com/Mrs4s/MiraiGo/utils"
@ -248,7 +247,7 @@ func (c *QQClient) buildPttShortVideoDownReqPacket(uuid, md5 []byte) (uint16, []
},
}
payload, _ := proto.Marshal(body)
packet := packets.BuildUniPacket(c.Uin, seq, "PttCenterSvr.ShortVideoDownReq", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "PttCenterSvr.ShortVideoDownReq", payload)
return seq, packet
}
@ -289,7 +288,7 @@ func (c *QQClient) buildPttGroupShortVideoProto(videoHash, thumbHash []byte, toU
func (c *QQClient) buildPttGroupShortVideoUploadReqPacket(videoHash, thumbHash []byte, toUin, videoSize, thumbSize int64) (uint16, []byte) {
seq := c.nextSeq()
payload, _ := proto.Marshal(c.buildPttGroupShortVideoProto(videoHash, thumbHash, toUin, videoSize, thumbSize, 1))
packet := packets.BuildUniPacket(c.Uin, seq, "PttCenterSvr.GroupShortVideoUpReq", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "PttCenterSvr.GroupShortVideoUpReq", payload)
return seq, packet
}

View File

@ -14,7 +14,6 @@ import (
"github.com/Mrs4s/MiraiGo/client/pb/cmd0x3f6"
"github.com/Mrs4s/MiraiGo/client/pb/cmd0x6ff"
"github.com/Mrs4s/MiraiGo/client/pb/msg"
"github.com/Mrs4s/MiraiGo/internal/packets"
"github.com/Mrs4s/MiraiGo/internal/proto"
"github.com/Mrs4s/MiraiGo/utils"
)
@ -87,7 +86,7 @@ func (c *QQClient) buildLoginExtraPacket() (uint16, []byte) {
},
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "qidianservice.69", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "qidianservice.69", payload)
return seq, packet
}
@ -104,7 +103,7 @@ func (c *QQClient) buildConnKeyRequestPacket() (uint16, []byte) {
},
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "HttpConn.0x6ff_501", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "HttpConn.0x6ff_501", payload)
return seq, packet
}

View File

@ -4,7 +4,6 @@ import (
"github.com/pkg/errors"
"github.com/Mrs4s/MiraiGo/client/pb/msg"
"github.com/Mrs4s/MiraiGo/internal/packets"
"github.com/Mrs4s/MiraiGo/internal/proto"
"github.com/Mrs4s/MiraiGo/message"
)
@ -63,7 +62,7 @@ func (c *QQClient) buildGroupRecallPacket(groupCode int64, msgSeq, msgRan int32)
},
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "PbMessageSvc.PbMsgWithDraw", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "PbMessageSvc.PbMsgWithDraw", payload)
return seq, packet
}
@ -92,7 +91,7 @@ func (c *QQClient) buildPrivateRecallPacket(uin, ts int64, msgSeq, random int32)
},
}}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "PbMessageSvc.PbMsgWithDraw", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "PbMessageSvc.PbMsgWithDraw", payload)
return seq, packet
}

View File

@ -7,7 +7,6 @@ import (
"github.com/pkg/errors"
"github.com/Mrs4s/MiraiGo/client/pb/oidb"
"github.com/Mrs4s/MiraiGo/internal/packets"
"github.com/Mrs4s/MiraiGo/internal/proto"
"github.com/Mrs4s/MiraiGo/message"
"github.com/Mrs4s/MiraiGo/utils"
@ -130,6 +129,6 @@ func (c *QQClient) buildRichMsgSendingPacket(guild uint64, target int64, msg *me
}
b, _ := proto.Marshal(body)
payload := c.packOIDBPackage(2935, 9, b)
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0xb77_9", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "OidbSvc.0xb77_9", payload)
return seq, packet
}

View File

@ -4,7 +4,6 @@ import (
"github.com/pkg/errors"
"github.com/Mrs4s/MiraiGo/client/pb/oidb"
"github.com/Mrs4s/MiraiGo/internal/packets"
"github.com/Mrs4s/MiraiGo/internal/proto"
)
@ -46,7 +45,7 @@ func (c *QQClient) buildUrlCheckRequest(url string) (uint16, []byte) {
Qua: proto.String("AQQ_2013 4.6/2013 8.4.184945&NA_0/000000&ADR&null18&linux&2017&C2293D02BEE31158&7.1.2&V3"),
},
})
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0xbcb_0", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "OidbSvc.0xbcb_0", payload)
return seq, packet
}

View File

@ -11,7 +11,6 @@ import (
"github.com/Mrs4s/MiraiGo/client/pb/msf"
"github.com/Mrs4s/MiraiGo/client/pb/msg"
"github.com/Mrs4s/MiraiGo/client/pb/oidb"
"github.com/Mrs4s/MiraiGo/internal/packets"
"github.com/Mrs4s/MiraiGo/internal/proto"
"github.com/Mrs4s/MiraiGo/message"
)
@ -137,7 +136,7 @@ func (c *QQClient) buildDeviceListRequestPacket() (uint16, []byte) {
Context: make(map[string]string),
Status: make(map[string]string),
}
packet := packets.BuildUniPacket(c.Uin, seq, "StatSvc.GetDevLoginInfo", 1, c.OutGoingPacketSessionId, []byte{}, c.sigInfo.d2Key, pkt.ToBytes())
packet := c.uniPacket(seq, "StatSvc.GetDevLoginInfo", pkt.ToBytes())
return seq, packet
}
@ -193,7 +192,7 @@ func (c *QQClient) buildGetOfflineMsgRequestPacket() (uint16, []byte) {
Context: make(map[string]string),
Status: make(map[string]string),
}
packet := packets.BuildUniPacket(c.Uin, seq, "RegPrxySvc.getOffMsg", 1, c.OutGoingPacketSessionId, []byte{}, c.sigInfo.d2Key, pkt.ToBytes())
packet := c.uniPacket(seq, "RegPrxySvc.getOffMsg", pkt.ToBytes())
return seq, packet
}
@ -267,7 +266,7 @@ func (c *QQClient) buildSyncMsgRequestPacket() (uint16, []byte) {
Context: make(map[string]string),
Status: make(map[string]string),
}
packet := packets.BuildUniPacket(c.Uin, seq, "RegPrxySvc.infoSync", 1, c.OutGoingPacketSessionId, []byte{}, c.sigInfo.d2Key, pkt.ToBytes())
packet := c.uniPacket(seq, "RegPrxySvc.infoSync", pkt.ToBytes())
return seq, packet
}
@ -278,7 +277,7 @@ func (c *QQClient) buildGroupMsgReadedPacket(groupCode, msgSeq int64) (uint16, [
GroupCode: proto.Uint64(uint64(groupCode)),
LastReadSeq: proto.Uint64(uint64(msgSeq)),
}}})
packet := packets.BuildUniPacket(c.Uin, seq, "PbMessageSvc.PbMsgReadedReport", 1, c.OutGoingPacketSessionId, []byte{}, c.sigInfo.d2Key, req)
packet := c.uniPacket(seq, "PbMessageSvc.PbMsgReadedReport", req)
return seq, packet
}
@ -290,7 +289,7 @@ func (c *QQClient) buildPrivateMsgReadedPacket(uin, time int64) (uint16, []byte)
LastReadTime: proto.Uint32(uint32(time)),
},
}, SyncCookie: c.syncCookie}})
packet := packets.BuildUniPacket(c.Uin, seq, "PbMessageSvc.PbMsgReadedReport", 1, c.OutGoingPacketSessionId, []byte{}, c.sigInfo.d2Key, req)
packet := c.uniPacket(seq, "PbMessageSvc.PbMsgReadedReport", req)
return seq, packet
}

View File

@ -2,7 +2,6 @@ package client
import (
"github.com/Mrs4s/MiraiGo/client/pb/structmsg"
"github.com/Mrs4s/MiraiGo/internal/packets"
"github.com/Mrs4s/MiraiGo/internal/proto"
)
@ -131,7 +130,7 @@ func (c *QQClient) buildSystemMsgNewGroupPacket(suspicious bool) (uint16, []byte
}(),
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "ProfileService.Pb.ReqSystemMsgNew.Group", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "ProfileService.Pb.ReqSystemMsgNew.Group", payload)
return seq, packet
}
@ -166,7 +165,7 @@ func (c *QQClient) buildSystemMsgGroupActionPacket(reqID, requester, group int64
Language: 1000,
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "ProfileService.Pb.ReqSystemMsgAction.Group", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "ProfileService.Pb.ReqSystemMsgAction.Group", payload)
return seq, packet
}
@ -191,7 +190,7 @@ func (c *QQClient) buildSystemMsgFriendActionPacket(reqID, requester int64, acce
},
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "ProfileService.Pb.ReqSystemMsgAction.Friend", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "ProfileService.Pb.ReqSystemMsgAction.Friend", payload)
return seq, packet
}

View File

@ -4,7 +4,6 @@ import (
"github.com/pkg/errors"
"github.com/Mrs4s/MiraiGo/client/pb/oidb"
"github.com/Mrs4s/MiraiGo/internal/packets"
"github.com/Mrs4s/MiraiGo/internal/proto"
)
@ -24,7 +23,7 @@ func (c *QQClient) buildTranslatePacket(src, dst, text string) (uint16, []byte)
Bodybuffer: b,
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x990", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
packet := c.uniPacket(seq, "OidbSvc.0x990", payload)
return seq, packet
}

View File

@ -9,7 +9,6 @@ import (
"github.com/pkg/errors"
"github.com/Mrs4s/MiraiGo/client/pb/web"
"github.com/Mrs4s/MiraiGo/internal/packets"
"github.com/Mrs4s/MiraiGo/internal/proto"
"github.com/Mrs4s/MiraiGo/utils"
)
@ -92,7 +91,7 @@ func (c *QQClient) webSsoRequest(host, webCmd, data string) (string, error) {
Data: &data,
})
seq := c.nextSeq()
rspData, err := c.sendAndWaitDynamic(seq, packets.BuildUniPacket(c.Uin, seq, cmd, 1, c.OutGoingPacketSessionId, []byte{}, c.sigInfo.d2Key, req))
rspData, err := c.sendAndWaitDynamic(seq, c.uniPacket(seq, cmd, req))
if err != nil {
return "", errors.Wrap(err, "send web sso request error")
}

View File

@ -49,7 +49,7 @@ func (e *EncryptECDH) generateKey(sPubKey string) {
e.PublicKey = elliptic.Marshal(p256, sx, sy)
}
func (e *EncryptECDH) DoEncrypt(d, k []byte) []byte {
func (e *EncryptECDH) Encrypt(d, k []byte) []byte {
w := binary.SelectWriter()
w.WriteByte(0x02)
w.WriteByte(0x01)
@ -62,7 +62,7 @@ func (e *EncryptECDH) DoEncrypt(d, k []byte) []byte {
return w.Bytes()
}
func (e *EncryptECDH) Id() byte {
func (e *EncryptECDH) ID() byte {
return 0x87
}
@ -70,7 +70,7 @@ func NewEncryptSession(t133 []byte) *EncryptSession {
return &EncryptSession{T133: t133}
}
func (e *EncryptSession) DoEncrypt(d, k []byte) []byte {
func (e *EncryptSession) Encrypt(d, k []byte) []byte {
return binary.NewWriterF(func(w *binary.Writer) {
encrypt := binary.NewTeaCipher(k).Encrypt(d)
w.WriteUInt16(uint16(len(e.T133)))
@ -79,7 +79,7 @@ func (e *EncryptSession) DoEncrypt(d, k []byte) []byte {
})
}
func (e *EncryptSession) Id() byte {
func (e *EncryptSession) ID() byte {
return 69
}

View File

@ -24,26 +24,3 @@ func BuildLoginPacket(uin int64, bodyType byte, key, body, extraData []byte) []b
})
})
}
func BuildUniPacket(uin int64, seq uint16, commandName string, encryptType byte, sessionID, extraData, key, body []byte) []byte {
return binary.NewWriterF(func(w *binary.Writer) {
w2 := binary.SelectWriter()
{ // w.WriteIntLvPacket
w2.WriteUInt32(0x0B)
w2.WriteByte(encryptType)
w2.WriteUInt32(uint32(seq))
w2.WriteByte(0)
w2.WriteString(strconv.FormatInt(uin, 10))
// inline NewWriterF
w3 := binary.SelectWriter()
w3.WriteUniPacket(commandName, sessionID, extraData, body)
w2.EncryptAndWrite(key, w3.Bytes())
binary.PutWriter(w3)
}
data := w2.Bytes()
w.WriteUInt32(uint32(len(data) + 4))
w.Write(data)
binary.PutWriter(w2)
})
}

View File

@ -29,31 +29,6 @@ type IncomingPacket struct {
Payload []byte
}
type IEncryptMethod interface {
DoEncrypt([]byte, []byte) []byte
Id() byte
}
func BuildOicqRequestPacket(uin int64, commandId uint16, encrypt IEncryptMethod, key []byte, bodyFunc func(writer *binary.Writer)) []byte {
body := encrypt.DoEncrypt(binary.NewWriterF(bodyFunc), key)
return binary.NewWriterF(func(p *binary.Writer) {
p.WriteByte(0x02)
p.WriteUInt16(27 + 2 + uint16(len(body)))
p.WriteUInt16(8001)
p.WriteUInt16(commandId)
p.WriteUInt16(1)
p.WriteUInt32(uint32(uin))
p.WriteByte(3)
p.WriteByte(encrypt.Id())
p.WriteByte(0)
p.WriteUInt32(2)
p.WriteUInt32(0)
p.WriteUInt32(0)
p.Write(body)
p.WriteByte(0x03)
})
}
func BuildCode2DRequestPacket(seq uint32, j uint64, cmd uint16, bodyFunc func(writer *binary.Writer)) []byte {
return binary.NewWriterF(func(w *binary.Writer) {
body := binary.NewWriterF(bodyFunc)