mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 11:07:40 +08:00
prealloc.
This commit is contained in:
parent
336be30cc8
commit
f3beaae4e4
@ -173,7 +173,7 @@ func (c *QQClient) buildQRCodeLoginPacket(t106, t16a, t318 []byte) (uint16, []by
|
||||
w.WriteUInt16(0x106)
|
||||
w.WriteBytesShort(t106)
|
||||
}))
|
||||
//w.Write(tlv.T106(uint32(c.Uin), 0, c.version.AppId, c.version.SSOVersion, c.PasswordMd5, true, SystemDeviceInfo.Guid, SystemDeviceInfo.TgtgtKey, 0))
|
||||
// w.Write(tlv.T106(uint32(c.Uin), 0, c.version.AppId, c.version.SSOVersion, c.PasswordMd5, true, SystemDeviceInfo.Guid, SystemDeviceInfo.TgtgtKey, 0))
|
||||
w.Write(tlv.T116(c.version.MiscBitmap, c.version.SubSigmap))
|
||||
w.Write(tlv.T100(c.version.SSOVersion, c.version.AppId, c.version.MainSigMap))
|
||||
w.Write(tlv.T107(0))
|
||||
@ -218,7 +218,7 @@ func (c *QQClient) buildQRCodeLoginPacket(t106, t16a, t318 []byte) (uint16, []by
|
||||
w.Write(tlv.T177(c.version.BuildTime, c.version.SdkVersion))
|
||||
w.Write(tlv.T516())
|
||||
w.Write(tlv.T521(8))
|
||||
//w.Write(tlv.T525(tlv.T536([]byte{0x01, 0x00})))
|
||||
// w.Write(tlv.T525(tlv.T536([]byte{0x01, 0x00})))
|
||||
w.Write(binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x318)
|
||||
w.WriteBytesShort(t318)
|
||||
@ -347,7 +347,6 @@ func (c *QQClient) buildRequestTgtgtNopicsigPacket() (uint16, []byte) {
|
||||
w.Write(tlv.T516())
|
||||
w.Write(tlv.T521(0))
|
||||
w.Write(tlv.T525(tlv.T536([]byte{0x01, 0x00})))
|
||||
|
||||
})
|
||||
packet := packets.BuildUniPacket(c.Uin, seq, "wtlogin.exchange_emp", 2, c.OutGoingPacketSessionId, []byte{}, make([]byte, 16), req)
|
||||
return seq, packet
|
||||
@ -1016,11 +1015,11 @@ func (c *QQClient) buildWordSegmentationPacket(data []byte) (uint16, []byte) {
|
||||
}
|
||||
|
||||
// OidbSvc.0xdad_1
|
||||
func (c *QQClient) sendGroupGiftPacket(groupCode, uin uint64, productId message.GroupGift) (uint16, []byte) {
|
||||
func (c *QQClient) sendGroupGiftPacket(groupCode, uin uint64, productID message.GroupGift) (uint16, []byte) {
|
||||
seq := c.nextSeq()
|
||||
payload := c.packOIDBPackageProto(3501, 1, &oidb.DADReqBody{
|
||||
Client: 1,
|
||||
ProductId: uint64(productId),
|
||||
ProductId: uint64(productID),
|
||||
ToUin: uin,
|
||||
Gc: groupCode,
|
||||
Version: "V 8.4.5.4745",
|
||||
|
@ -82,14 +82,14 @@ type QQClient struct {
|
||||
pwdFlag bool
|
||||
|
||||
lastMessageSeq int32
|
||||
//lastMessageSeqTmp sync.Map
|
||||
// lastMessageSeqTmp sync.Map
|
||||
msgSvcCache *utils.Cache
|
||||
transCache *utils.Cache
|
||||
lastLostMsg string
|
||||
groupSysMsgCache *GroupSystemMessages
|
||||
groupMsgBuilders sync.Map
|
||||
onlinePushCache *utils.Cache
|
||||
requestPacketRequestId int32
|
||||
requestPacketRequestID int32
|
||||
groupSeq int32
|
||||
friendSeq int32
|
||||
heartbeatEnabled bool
|
||||
@ -178,7 +178,7 @@ func NewClientMd5(uin int64, passwordMd5 [16]byte) *QQClient {
|
||||
RandomKey: make([]byte, 16),
|
||||
OutGoingPacketSessionId: []byte{0x02, 0xB0, 0x5B, 0x8B},
|
||||
sigInfo: &loginSigInfo{},
|
||||
requestPacketRequestId: 1921334513,
|
||||
requestPacketRequestID: 1921334513,
|
||||
groupSeq: int32(rand.Intn(20000)),
|
||||
friendSeq: 22911,
|
||||
highwayApplyUpSeq: 77918,
|
||||
@ -485,8 +485,8 @@ func (c *QQClient) GetFriendList() (*FriendListResponse, error) {
|
||||
return r, nil
|
||||
}
|
||||
|
||||
func (c *QQClient) GetForwardMessage(resId string) *message.ForwardMessage {
|
||||
m := c.DownloadForwardMessage(resId)
|
||||
func (c *QQClient) GetForwardMessage(resID string) *message.ForwardMessage {
|
||||
m := c.DownloadForwardMessage(resID)
|
||||
if m == nil {
|
||||
return nil
|
||||
}
|
||||
@ -779,10 +779,7 @@ func (c *QQClient) connect() error {
|
||||
return errors.New("All servers are unreachable")
|
||||
}
|
||||
c.Error("connect server error: %v", err)
|
||||
if err = c.connect(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
c.retryTimes = 0
|
||||
c.ConnectTime = time.Now()
|
||||
@ -817,7 +814,7 @@ func (c *QQClient) nextSeq() uint16 {
|
||||
}
|
||||
|
||||
func (c *QQClient) nextPacketSeq() int32 {
|
||||
return atomic.AddInt32(&c.requestPacketRequestId, 2)
|
||||
return atomic.AddInt32(&c.requestPacketRequestID, 2)
|
||||
}
|
||||
|
||||
func (c *QQClient) nextGroupSeq() int32 {
|
||||
@ -875,7 +872,7 @@ func (c *QQClient) sendAndWait(seq uint16, pkt []byte, params ...requestParams)
|
||||
}, params: p})
|
||||
|
||||
retry := 0
|
||||
for true {
|
||||
for {
|
||||
select {
|
||||
case rsp := <-ch:
|
||||
return rsp.Response, rsp.Error
|
||||
@ -886,12 +883,11 @@ func (c *QQClient) sendAndWait(seq uint16, pkt []byte, params ...requestParams)
|
||||
continue
|
||||
}
|
||||
c.handlers.Delete(seq)
|
||||
//c.Error("packet timed out, seq: %v", seq)
|
||||
//println("Packet Timed out")
|
||||
// c.Error("packet timed out, seq: %v", seq)
|
||||
// println("Packet Timed out")
|
||||
return nil, errors.New("Packet timed out")
|
||||
}
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// 等待一个或多个数据包解析, 优先级低于 sendAndWait
|
||||
@ -939,7 +935,7 @@ func (c *QQClient) netLoop() {
|
||||
}
|
||||
continue
|
||||
}
|
||||
data, err := reader.ReadBytes(int(l) - 4)
|
||||
data, _ := reader.ReadBytes(int(l) - 4)
|
||||
pkt, err := packets.ParseIncomingPacket(data, c.sigInfo.d2Key)
|
||||
if err != nil {
|
||||
c.Error("parse incoming packet error: %v", err)
|
||||
|
@ -59,7 +59,7 @@ func decodeLoginResponse(c *QQClient, _ *incomingPacketInfo, payload []byte) (in
|
||||
}, nil
|
||||
}
|
||||
if t == 2 {
|
||||
c.t104, _ = m[0x104]
|
||||
c.t104 = m[0x104]
|
||||
if m.Exists(0x192) {
|
||||
return LoginResponse{
|
||||
Success: false,
|
||||
@ -136,7 +136,6 @@ func decodeLoginResponse(c *QQClient, _ *incomingPacketInfo, payload []byte) (in
|
||||
ErrorMessage: "",
|
||||
}, nil
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if t == 162 {
|
||||
@ -444,7 +443,7 @@ func decodeFriendGroupListResponse(_ *QQClient, _ *incomingPacketInfo, payload [
|
||||
totalFriendCount := r.ReadInt16(5)
|
||||
friends := []jce.FriendInfo{}
|
||||
r.ReadSlice(&friends, 7)
|
||||
var l []*FriendInfo
|
||||
var l = make([]*FriendInfo, 0, len(friends))
|
||||
for _, f := range friends {
|
||||
l = append(l, &FriendInfo{
|
||||
Uin: f.FriendUin,
|
||||
@ -471,7 +470,7 @@ func decodeGroupListResponse(c *QQClient, _ *incomingPacketInfo, payload []byte)
|
||||
groups := []jce.TroopNumber{}
|
||||
r.ReadSlice(&vecCookie, 4)
|
||||
r.ReadSlice(&groups, 5)
|
||||
var l []*GroupInfo
|
||||
var l = make([]*GroupInfo, 0, len(groups))
|
||||
for _, g := range groups {
|
||||
l = append(l, &GroupInfo{
|
||||
Uin: g.GroupUin,
|
||||
@ -504,7 +503,7 @@ func decodeGroupMemberListResponse(_ *QQClient, _ *incomingPacketInfo, payload [
|
||||
members := []jce.TroopMemberInfo{}
|
||||
r.ReadSlice(&members, 3)
|
||||
next := r.ReadInt64(4)
|
||||
var l []*GroupMemberInfo
|
||||
var l = make([]*GroupMemberInfo, 0, len(members))
|
||||
for _, m := range members {
|
||||
l = append(l, &GroupMemberInfo{
|
||||
Uin: m.MemberUin,
|
||||
@ -627,14 +626,12 @@ func decodeOnlinePushTransPacket(c *QQClient, _ *incomingPacketInfo, payload []b
|
||||
case 0x02:
|
||||
if target == c.Uin {
|
||||
c.dispatchLeaveGroupEvent(&GroupLeaveEvent{Group: g})
|
||||
} else {
|
||||
if m := g.FindMember(target); m != nil {
|
||||
g.removeMember(target)
|
||||
c.dispatchMemberLeaveEvent(&MemberLeaveGroupEvent{
|
||||
Group: g,
|
||||
Member: m,
|
||||
})
|
||||
}
|
||||
} else if m := g.FindMember(target); m != nil {
|
||||
g.removeMember(target)
|
||||
c.dispatchMemberLeaveEvent(&MemberLeaveGroupEvent{
|
||||
Group: g,
|
||||
Member: m,
|
||||
})
|
||||
}
|
||||
case 0x03:
|
||||
if err = c.ReloadGroupList(); err != nil {
|
||||
@ -645,15 +642,13 @@ func decodeOnlinePushTransPacket(c *QQClient, _ *incomingPacketInfo, payload []b
|
||||
Group: g,
|
||||
Operator: g.FindMember(operator),
|
||||
})
|
||||
} else {
|
||||
if m := g.FindMember(target); m != nil {
|
||||
g.removeMember(target)
|
||||
c.dispatchMemberLeaveEvent(&MemberLeaveGroupEvent{
|
||||
Group: g,
|
||||
Member: m,
|
||||
Operator: g.FindMember(operator),
|
||||
})
|
||||
}
|
||||
} else if m := g.FindMember(target); m != nil {
|
||||
g.removeMember(target)
|
||||
c.dispatchMemberLeaveEvent(&MemberLeaveGroupEvent{
|
||||
Group: g,
|
||||
Member: m,
|
||||
Operator: g.FindMember(operator),
|
||||
})
|
||||
}
|
||||
case 0x82:
|
||||
if m := g.FindMember(target); m != nil {
|
||||
@ -678,7 +673,7 @@ func decodeOnlinePushTransPacket(c *QQClient, _ *incomingPacketInfo, payload []b
|
||||
if info.GetMsgType() == 44 {
|
||||
data.ReadBytes(5)
|
||||
var4 := int32(data.ReadByte())
|
||||
var var5 int64 = 0
|
||||
var var5 = int64(0)
|
||||
target := int64(uint32(data.ReadInt32()))
|
||||
if var4 != 0 && var4 != 1 {
|
||||
var5 = int64(uint32(data.ReadInt32()))
|
||||
@ -782,11 +777,11 @@ func decodeImageOcrResponse(_ *QQClient, _ *incomingPacketInfo, payload []byte)
|
||||
return nil, errors.New(rsp.Wording)
|
||||
}
|
||||
if rsp.RetCode != 0 {
|
||||
return nil, errors.New(fmt.Sprintf("server error, code: %v msg: %v", rsp.RetCode, rsp.ErrMsg))
|
||||
return nil, errors.Errorf("server error, code: %v msg: %v", rsp.RetCode, rsp.ErrMsg)
|
||||
}
|
||||
var texts []*TextDetection
|
||||
var texts = make([]*TextDetection, 0, len(rsp.OcrRspBody.TextDetections))
|
||||
for _, text := range rsp.OcrRspBody.TextDetections {
|
||||
var points []*Coordinate
|
||||
var points = make([]*Coordinate, 0, len(text.Polygon.Coordinates))
|
||||
for _, c := range text.Polygon.Coordinates {
|
||||
points = append(points, &Coordinate{
|
||||
X: c.X,
|
||||
|
@ -59,7 +59,7 @@ type (
|
||||
Nickname string
|
||||
Remark string
|
||||
FaceId int16
|
||||
//msgSeqList *utils.Cache
|
||||
// msgSeqList *utils.Cache
|
||||
}
|
||||
|
||||
SummaryCardInfo struct {
|
||||
|
@ -443,7 +443,7 @@ func getSSOAddress() ([]*net.TCPAddr, error) {
|
||||
reader := jce.NewJceReader(data.Map["HttpServerListRes"][1:])
|
||||
servers := []jce.SsoServerInfo{}
|
||||
reader.ReadSlice(&servers, 2)
|
||||
var adds []*net.TCPAddr
|
||||
var adds = make([]*net.TCPAddr, 0, len(servers))
|
||||
for _, s := range servers {
|
||||
if strings.Contains(s.Server, "com") {
|
||||
continue
|
||||
@ -552,9 +552,9 @@ func XmlEscape(c string) string {
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
func genForwardTemplate(resId, preview, title, brief, source, summary string, ts int64, items []*msg.PbMultiMsgItem) *message.ForwardElement {
|
||||
func genForwardTemplate(resID, preview, title, brief, source, summary string, ts int64, items []*msg.PbMultiMsgItem) *message.ForwardElement {
|
||||
template := fmt.Sprintf(`<?xml version='1.0' encoding='UTF-8'?><msg serviceID="35" templateID="1" action="viewMultiMsg" brief="%s" m_resid="%s" m_fileName="%d" tSum="3" sourceMsgId="0" url="" flag="3" adverSign="0" multiMsgFlag="0"><item layout="1"><title color="#000000" size="34">%s</title> %s<hr></hr><summary size="26" color="#808080">%s</summary></item><source name="%s"></source></msg>`,
|
||||
brief, resId, ts, title, preview, summary, source,
|
||||
brief, resID, ts, title, preview, summary, source,
|
||||
)
|
||||
for _, item := range items {
|
||||
if item.GetFileName() == "MultiMsg" {
|
||||
@ -564,12 +564,12 @@ func genForwardTemplate(resId, preview, title, brief, source, summary string, ts
|
||||
return &message.ForwardElement{
|
||||
FileName: strconv.FormatInt(ts, 10),
|
||||
Content: template,
|
||||
ResId: resId,
|
||||
ResId: resID,
|
||||
Items: items,
|
||||
}
|
||||
}
|
||||
|
||||
func genLongTemplate(resId, brief string, ts int64) *message.ServiceElement {
|
||||
func genLongTemplate(resID, brief string, ts int64) *message.ServiceElement {
|
||||
limited := func() string {
|
||||
if len(brief) > 30 {
|
||||
return brief[:30] + "…"
|
||||
@ -577,12 +577,12 @@ func genLongTemplate(resId, brief string, ts int64) *message.ServiceElement {
|
||||
return brief
|
||||
}()
|
||||
template := fmt.Sprintf(`<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><msg serviceID="35" templateID="1" action="viewMultiMsg" brief="%s" m_resid="%s" m_fileName="%d" sourceMsgId="0" url="" flag="3" adverSign="0" multiMsgFlag="1"> <item layout="1"> <title>%s</title> <hr hidden="false" style="0"/> <summary>点击查看完整消息</summary> </item> <source name="聊天记录" icon="" action="" appid="-1"/> </msg>`,
|
||||
XmlEscape(limited), resId, ts, XmlEscape(limited),
|
||||
XmlEscape(limited), resID, ts, XmlEscape(limited),
|
||||
)
|
||||
return &message.ServiceElement{
|
||||
Id: 35,
|
||||
Content: template,
|
||||
ResId: resId,
|
||||
ResId: resID,
|
||||
SubType: "Long",
|
||||
}
|
||||
}
|
||||
|
@ -109,12 +109,12 @@ func (fs *GroupFileSystem) Root() ([]*GroupFile, []*GroupFolder, error) {
|
||||
return fs.GetFilesByFolder("/")
|
||||
}
|
||||
|
||||
func (fs *GroupFileSystem) GetFilesByFolder(folderId string) ([]*GroupFile, []*GroupFolder, error) {
|
||||
func (fs *GroupFileSystem) GetFilesByFolder(folderID string) ([]*GroupFile, []*GroupFolder, error) {
|
||||
var startIndex uint32 = 0
|
||||
var files []*GroupFile
|
||||
var folders []*GroupFolder
|
||||
for {
|
||||
i, err := fs.client.sendAndWait(fs.client.buildGroupFileListRequestPacket(fs.GroupCode, folderId, startIndex))
|
||||
i, err := fs.client.sendAndWait(fs.client.buildGroupFileListRequestPacket(fs.GroupCode, folderID, startIndex))
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@ -191,7 +191,7 @@ func (fs *GroupFileSystem) UploadFile(p, name, folderId string) error {
|
||||
return fs.client.send(pkt)
|
||||
}
|
||||
if len(rsp.UploadIpLanV4) == 0 {
|
||||
return errors.New("server requires unsupported ftn upload.")
|
||||
return errors.New("server requires unsupported ftn upload")
|
||||
}
|
||||
ext, _ := proto.Marshal(&exciting.GroupFileUploadExt{
|
||||
Unknown1: proto.Int32(100),
|
||||
@ -243,22 +243,22 @@ func (fs *GroupFileSystem) GetDownloadUrl(file *GroupFile) string {
|
||||
|
||||
// DeleteFile 删除群文件,需要管理权限.
|
||||
// 返回错误, 空为删除成功
|
||||
func (fs *GroupFileSystem) DeleteFile(parentFolderId, fileId string, busId int32) string {
|
||||
i, err := fs.client.sendAndWait(fs.client.buildGroupFileDeleteReqPacket(fs.GroupCode, parentFolderId, fileId, busId))
|
||||
func (fs *GroupFileSystem) DeleteFile(parentFolderID, fileId string, busId int32) string {
|
||||
i, err := fs.client.sendAndWait(fs.client.buildGroupFileDeleteReqPacket(fs.GroupCode, parentFolderID, fileId, busId))
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
return i.(string)
|
||||
}
|
||||
|
||||
func (c *QQClient) buildGroupFileUploadReqPacket(parentFolderId, fileName string, groupCode, fileSize int64, md5, sha1 []byte) (uint16, []byte) {
|
||||
func (c *QQClient) buildGroupFileUploadReqPacket(parentFolderID, fileName string, groupCode, fileSize int64, md5, sha1 []byte) (uint16, []byte) {
|
||||
seq := c.nextSeq()
|
||||
b, _ := proto.Marshal(&oidb.D6D6ReqBody{UploadFileReq: &oidb.UploadFileReqBody{
|
||||
GroupCode: groupCode,
|
||||
AppId: 3,
|
||||
BusId: 102,
|
||||
Entrance: 5,
|
||||
ParentFolderId: parentFolderId,
|
||||
ParentFolderId: parentFolderID,
|
||||
FileName: fileName,
|
||||
LocalPath: "/storage/emulated/0/Pictures/files/s/" + fileName,
|
||||
Int64FileSize: fileSize,
|
||||
@ -277,13 +277,13 @@ func (c *QQClient) buildGroupFileUploadReqPacket(parentFolderId, fileName string
|
||||
return seq, packet
|
||||
}
|
||||
|
||||
func (c *QQClient) buildGroupFileFeedsRequest(groupCode int64, fileId string, busId, msgRand int32) (uint16, []byte) {
|
||||
func (c *QQClient) buildGroupFileFeedsRequest(groupCode int64, fileID string, busId, msgRand int32) (uint16, []byte) {
|
||||
seq := c.nextSeq()
|
||||
req := c.packOIDBPackageProto(1753, 4, &oidb.D6D9ReqBody{FeedsInfoReq: &oidb.FeedsReqBody{
|
||||
GroupCode: proto.Uint64(uint64(groupCode)),
|
||||
AppId: proto.Uint32(3),
|
||||
FeedsInfoList: []*oidb.GroupFileFeedsInfo{{
|
||||
FileId: &fileId,
|
||||
FileId: &fileID,
|
||||
FeedFlag: proto.Uint32(1),
|
||||
BusId: proto.Uint32(uint32(busId)),
|
||||
MsgRandom: proto.Uint32(uint32(msgRand)),
|
||||
@ -294,12 +294,12 @@ func (c *QQClient) buildGroupFileFeedsRequest(groupCode int64, fileId string, bu
|
||||
}
|
||||
|
||||
// OidbSvc.0x6d8_1
|
||||
func (c *QQClient) buildGroupFileListRequestPacket(groupCode int64, folderId string, startIndex uint32) (uint16, []byte) {
|
||||
func (c *QQClient) buildGroupFileListRequestPacket(groupCode int64, folderID string, startIndex uint32) (uint16, []byte) {
|
||||
seq := c.nextSeq()
|
||||
body := &oidb.D6D8ReqBody{FileListInfoReq: &oidb.GetFileListReqBody{
|
||||
GroupCode: proto.Uint64(uint64(groupCode)),
|
||||
AppId: proto.Uint32(3),
|
||||
FolderId: &folderId,
|
||||
FolderId: &folderID,
|
||||
FileCount: proto.Uint32(20),
|
||||
AllFileCount: proto.Uint32(0),
|
||||
ReqFrom: proto.Uint32(3),
|
||||
|
@ -564,8 +564,8 @@ func (c *QQClient) parseGroupMessage(m *msg.Message) *message.GroupMessage {
|
||||
}
|
||||
|
||||
// SetEssenceMessage 设为群精华消息
|
||||
func (c *QQClient) SetEssenceMessage(groupCode int64, msgId, msgInternalId int32) error {
|
||||
r, err := c.sendAndWait(c.buildEssenceMsgOperatePacket(groupCode, uint32(msgId), uint32(msgInternalId), 1))
|
||||
func (c *QQClient) SetEssenceMessage(groupCode int64, msgID, msgInternalId int32) error {
|
||||
r, err := c.sendAndWait(c.buildEssenceMsgOperatePacket(groupCode, uint32(msgID), uint32(msgInternalId), 1))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "set essence msg network")
|
||||
}
|
||||
@ -577,8 +577,8 @@ func (c *QQClient) SetEssenceMessage(groupCode int64, msgId, msgInternalId int32
|
||||
}
|
||||
|
||||
// DeleteEssenceMessage 移出群精华消息
|
||||
func (c *QQClient) DeleteEssenceMessage(groupCode int64, msgId, msgInternalId int32) error {
|
||||
r, err := c.sendAndWait(c.buildEssenceMsgOperatePacket(groupCode, uint32(msgId), uint32(msgInternalId), 2))
|
||||
func (c *QQClient) DeleteEssenceMessage(groupCode int64, msgID, msgInternalId int32) error {
|
||||
r, err := c.sendAndWait(c.buildEssenceMsgOperatePacket(groupCode, uint32(msgID), uint32(msgInternalId), 2))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "set essence msg networ")
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func (c *QQClient) highwayUpload(ip uint32, port int, updKey, data []byte, cmdId int32) error {
|
||||
return c.highwayUploadStream(ip, port, updKey, bytes.NewReader(data), cmdId)
|
||||
func (c *QQClient) highwayUpload(ip uint32, port int, updKey, data []byte, cmdID int32) error {
|
||||
return c.highwayUploadStream(ip, port, updKey, bytes.NewReader(data), cmdID)
|
||||
}
|
||||
|
||||
func (c *QQClient) highwayUploadStream(ip uint32, port int, updKey []byte, stream io.ReadSeeker, cmdId int32) error {
|
||||
@ -48,10 +48,10 @@ func (c *QQClient) highwayUploadStream(ip uint32, port int, updKey []byte, strea
|
||||
for {
|
||||
chunk := make([]byte, chunkSize)
|
||||
rl, err := io.ReadFull(stream, chunk)
|
||||
if err == io.EOF {
|
||||
if errors.Is(err, io.EOF) {
|
||||
break
|
||||
}
|
||||
if err == io.ErrUnexpectedEOF {
|
||||
if errors.Is(err, io.ErrUnexpectedEOF) {
|
||||
chunk = chunk[:rl]
|
||||
}
|
||||
ch := md5.Sum(chunk)
|
||||
@ -72,7 +72,7 @@ func (c *QQClient) highwayUploadStream(ip uint32, port int, updKey []byte, strea
|
||||
Datalength: int32(rl),
|
||||
Serviceticket: updKey,
|
||||
Md5: ch[:],
|
||||
FileMd5: fh[:],
|
||||
FileMd5: fh,
|
||||
},
|
||||
ReqExtendinfo: EmptyBytes,
|
||||
})
|
||||
@ -131,10 +131,10 @@ func (c *QQClient) highwayUploadByBDH(stream io.ReadSeeker, cmdId int32, ticket,
|
||||
for {
|
||||
chunk := make([]byte, chunkSize)
|
||||
rl, err := io.ReadFull(stream, chunk)
|
||||
if err == io.EOF {
|
||||
if errors.Is(err, io.EOF) {
|
||||
break
|
||||
}
|
||||
if err == io.ErrUnexpectedEOF {
|
||||
if errors.Is(err, io.ErrUnexpectedEOF) {
|
||||
chunk = chunk[:rl]
|
||||
}
|
||||
ch := md5.Sum(chunk)
|
||||
@ -306,7 +306,7 @@ func (c *QQClient) highwayUploadFileMultiThreadingByBDH(path string, cmdId int32
|
||||
Datalength: int32(ri),
|
||||
Serviceticket: ticket,
|
||||
Md5: ch[:],
|
||||
FileMd5: fh[:],
|
||||
FileMd5: fh,
|
||||
},
|
||||
ReqExtendinfo: ext,
|
||||
})
|
||||
|
@ -14,8 +14,8 @@ import (
|
||||
"github.com/Mrs4s/MiraiGo/message"
|
||||
"github.com/Mrs4s/MiraiGo/protocol/packets"
|
||||
"github.com/Mrs4s/MiraiGo/utils"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -26,7 +26,7 @@ func (c *QQClient) UploadGroupImage(groupCode int64, img io.ReadSeeker) (*messag
|
||||
_, _ = img.Seek(0, io.SeekStart) // safe
|
||||
fh, length := utils.ComputeMd5AndLength(img)
|
||||
_, _ = img.Seek(0, io.SeekStart)
|
||||
seq, pkt := c.buildGroupImageStorePacket(groupCode, fh[:], int32(length))
|
||||
seq, pkt := c.buildGroupImageStorePacket(groupCode, fh, int32(length))
|
||||
r, err := c.sendAndWait(seq, pkt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -57,7 +57,7 @@ ok:
|
||||
if bytes.Equal(tmp, []byte{0x47, 0x49, 0x46, 0x38}) {
|
||||
imageType = 2000
|
||||
}
|
||||
return message.NewGroupImage(binary.CalculateImageResourceId(fh[:]), fh[:], rsp.FileId, int32(length), int32(i.Width), int32(i.Height), imageType), nil
|
||||
return message.NewGroupImage(binary.CalculateImageResourceId(fh), fh, rsp.FileId, int32(length), int32(i.Width), int32(i.Height), imageType), nil
|
||||
}
|
||||
|
||||
func (c *QQClient) UploadGroupImageByFile(groupCode int64, path string) (*message.GroupImageElement, error) {
|
||||
@ -110,7 +110,7 @@ func (c *QQClient) uploadPrivateImage(target int64, img io.ReadSeeker, count int
|
||||
count++
|
||||
fh, length := utils.ComputeMd5AndLength(img)
|
||||
_, _ = img.Seek(0, io.SeekStart)
|
||||
e, err := c.QueryFriendImage(target, fh[:], int32(length))
|
||||
e, err := c.QueryFriendImage(target, fh, int32(length))
|
||||
if errors.Is(err, ErrNotExists) {
|
||||
// use group highway upload and query again for image id.
|
||||
if _, err = c.UploadGroupImage(target, img); err != nil {
|
||||
|
@ -62,7 +62,7 @@ func decodeMultiApplyUpResponse(_ *QQClient, _ *incomingPacketInfo, payload []by
|
||||
}
|
||||
|
||||
// MultiMsg.ApplyDown
|
||||
func (c *QQClient) buildMultiApplyDownPacket(resId string) (uint16, []byte) {
|
||||
func (c *QQClient) buildMultiApplyDownPacket(resID string) (uint16, []byte) {
|
||||
seq := c.nextSeq()
|
||||
req := &multimsg.MultiReqBody{
|
||||
Subcmd: 2,
|
||||
@ -72,7 +72,7 @@ func (c *QQClient) buildMultiApplyDownPacket(resId string) (uint16, []byte) {
|
||||
BuildVer: "8.2.0.1296",
|
||||
MultimsgApplydownReq: []*multimsg.MultiMsgApplyDownReq{
|
||||
{
|
||||
MsgResid: []byte(resId),
|
||||
MsgResid: []byte(resID),
|
||||
MsgType: 3,
|
||||
},
|
||||
},
|
||||
|
@ -38,9 +38,9 @@ type (
|
||||
)
|
||||
|
||||
// grayTipProcessor 提取出来专门用于处理群内 notify tips
|
||||
func (c *QQClient) grayTipProcessor(groupId int64, tipInfo *notify.GeneralGrayTipInfo) {
|
||||
func (c *QQClient) grayTipProcessor(groupID int64, tipInfo *notify.GeneralGrayTipInfo) {
|
||||
if tipInfo.BusiType == 12 && tipInfo.BusiId == 1061 {
|
||||
var sender int64 = 0
|
||||
var sender = int64(0)
|
||||
receiver := c.Uin
|
||||
for _, templ := range tipInfo.MsgTemplParam {
|
||||
if templ.Name == "uin_str1" {
|
||||
@ -52,7 +52,7 @@ func (c *QQClient) grayTipProcessor(groupId int64, tipInfo *notify.GeneralGrayTi
|
||||
}
|
||||
if sender != 0 {
|
||||
c.dispatchGroupNotifyEvent(&GroupPokeNotifyEvent{
|
||||
GroupCode: groupId,
|
||||
GroupCode: groupID,
|
||||
Sender: sender,
|
||||
Receiver: receiver,
|
||||
})
|
||||
@ -71,7 +71,7 @@ func (c *QQClient) grayTipProcessor(groupId int64, tipInfo *notify.GeneralGrayTi
|
||||
}
|
||||
}
|
||||
c.dispatchGroupNotifyEvent(&MemberHonorChangedNotifyEvent{
|
||||
GroupCode: groupId,
|
||||
GroupCode: groupID,
|
||||
Honor: func() HonorType {
|
||||
switch tipInfo.TemplId {
|
||||
case 1052:
|
||||
|
@ -41,7 +41,7 @@ func decodeOnlinePushReqPacket(c *QQClient, info *incomingPacketInfo, payload []
|
||||
// 0x2dc
|
||||
if m.MsgType == 732 {
|
||||
r := binary.NewReader(m.VMsg)
|
||||
groupId := int64(uint32(r.ReadInt32()))
|
||||
groupID := int64(uint32(r.ReadInt32()))
|
||||
iType := r.ReadByte()
|
||||
r.ReadByte()
|
||||
switch iType {
|
||||
@ -54,7 +54,7 @@ func decodeOnlinePushReqPacket(c *QQClient, info *incomingPacketInfo, payload []
|
||||
target := int64(uint32(r.ReadInt32()))
|
||||
t := r.ReadInt32()
|
||||
c.dispatchGroupMuteEvent(&GroupMuteEvent{
|
||||
GroupCode: groupId,
|
||||
GroupCode: groupID,
|
||||
OperatorUin: operator,
|
||||
TargetUin: target,
|
||||
Time: t,
|
||||
@ -69,7 +69,7 @@ func decodeOnlinePushReqPacket(c *QQClient, info *incomingPacketInfo, payload []
|
||||
continue
|
||||
}
|
||||
c.dispatchGroupMessageRecalledEvent(&GroupMessageRecalledEvent{
|
||||
GroupCode: groupId,
|
||||
GroupCode: groupID,
|
||||
OperatorUin: b.OptMsgRecall.Uin,
|
||||
AuthorUin: rm.AuthorUin,
|
||||
MessageId: rm.Seq,
|
||||
@ -78,12 +78,12 @@ func decodeOnlinePushReqPacket(c *QQClient, info *incomingPacketInfo, payload []
|
||||
}
|
||||
}
|
||||
if b.OptGeneralGrayTip != nil {
|
||||
c.grayTipProcessor(groupId, b.OptGeneralGrayTip)
|
||||
c.grayTipProcessor(groupID, b.OptGeneralGrayTip)
|
||||
}
|
||||
if b.OptMsgRedTips != nil {
|
||||
if b.OptMsgRedTips.LuckyFlag == 1 { // 运气王提示
|
||||
c.dispatchGroupNotifyEvent(&GroupRedBagLuckyKingNotifyEvent{
|
||||
GroupCode: groupId,
|
||||
GroupCode: groupID,
|
||||
Sender: int64(b.OptMsgRedTips.SenderUin),
|
||||
LuckyKing: int64(b.OptMsgRedTips.LuckyUin),
|
||||
})
|
||||
@ -178,8 +178,7 @@ func msgType0x210Sub27Decoder(c *QQClient, protobuf []byte) error {
|
||||
for _, m := range s27.ModInfos {
|
||||
if m.ModGroupProfile != nil {
|
||||
for _, info := range m.ModGroupProfile.GroupProfileInfos {
|
||||
switch info.GetField() { // 1 -> group name 2 -> group head 3 -> group creditLevel
|
||||
case 1:
|
||||
if info.GetField() == 1 {
|
||||
if g := c.FindGroup(int64(m.ModGroupProfile.GetGroupCode())); g != nil {
|
||||
old := g.Name
|
||||
g.Name = string(info.GetValue())
|
||||
|
@ -276,7 +276,7 @@ func decodeGroupPttStoreResponse(_ *QQClient, _ *incomingPacketInfo, payload []b
|
||||
if rsp.BoolFileExit {
|
||||
return pttUploadResponse{IsExists: true}, nil
|
||||
}
|
||||
var ip []string
|
||||
var ip = make([]string, 0, len(rsp.Uint32UpIp))
|
||||
for _, i := range rsp.Uint32UpIp {
|
||||
ip = append(ip, binary.UInt32ToIPV4Address(uint32(i)))
|
||||
}
|
||||
|
@ -10,24 +10,24 @@ import (
|
||||
|
||||
// 撤回相关处理逻辑
|
||||
|
||||
func (c *QQClient) RecallGroupMessage(groupCode int64, msgId, msgInternalId int32) error {
|
||||
if m, _ := c.GetGroupMessages(groupCode, int64(msgId), int64(msgId)); len(m) > 0 {
|
||||
func (c *QQClient) RecallGroupMessage(groupCode int64, msgID, msgInternalId int32) error {
|
||||
if m, _ := c.GetGroupMessages(groupCode, int64(msgID), int64(msgID)); len(m) > 0 {
|
||||
content := m[0].OriginalObject.Content
|
||||
if content.GetPkgNum() > 1 {
|
||||
if m, err := c.GetGroupMessages(groupCode, int64(msgId-content.GetPkgIndex()-1), int64(msgId+(content.GetPkgNum()-content.GetPkgIndex()+1))); err == nil {
|
||||
if m, err := c.GetGroupMessages(groupCode, int64(msgID-content.GetPkgIndex()-1), int64(msgID+(content.GetPkgNum()-content.GetPkgIndex()+1))); err == nil {
|
||||
if flag, _ := c.internalGroupRecall(groupCode, msgInternalId, m); flag {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_, err := c.sendAndWait(c.buildGroupRecallPacket(groupCode, msgId, msgInternalId))
|
||||
_, err := c.sendAndWait(c.buildGroupRecallPacket(groupCode, msgID, msgInternalId))
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *QQClient) internalGroupRecall(groupCode int64, msgInternalId int32, m []*message.GroupMessage) (flag bool, err error) {
|
||||
func (c *QQClient) internalGroupRecall(groupCode int64, msgInternalID int32, m []*message.GroupMessage) (flag bool, err error) {
|
||||
for _, item := range m {
|
||||
if item.InternalId == msgInternalId {
|
||||
if item.InternalId == msgInternalID {
|
||||
flag = true
|
||||
if _, err := c.sendAndWait(c.buildGroupRecallPacket(groupCode, item.Id, item.InternalId)); err != nil {
|
||||
return false, err
|
||||
@ -37,8 +37,8 @@ func (c *QQClient) internalGroupRecall(groupCode int64, msgInternalId int32, m [
|
||||
return flag, nil
|
||||
}
|
||||
|
||||
func (c *QQClient) RecallPrivateMessage(uin, ts int64, msgId, msgInternalId int32) error {
|
||||
_, err := c.sendAndWait(c.buildPrivateRecallPacket(uin, ts, msgId, msgInternalId))
|
||||
func (c *QQClient) RecallPrivateMessage(uin, ts int64, msgID, msgInternalId int32) error {
|
||||
_, err := c.sendAndWait(c.buildPrivateRecallPacket(uin, ts, msgID, msgInternalId))
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ func (c *QQClient) GetAllowedClients() ([]*OtherClientInfo, error) {
|
||||
return nil, err
|
||||
}
|
||||
list := i.([]jce.SvcDevLoginInfo)
|
||||
var ret []*OtherClientInfo
|
||||
var ret = make([]*OtherClientInfo, 0, len(list))
|
||||
for _, l := range list {
|
||||
ret = append(ret, &OtherClientInfo{
|
||||
AppId: l.AppId,
|
||||
@ -210,7 +210,7 @@ func (c *QQClient) buildSyncMsgRequestPacket() (uint16, []byte) {
|
||||
},
|
||||
}})
|
||||
regReq := &jce.SvcReqRegisterNew{
|
||||
RequestOptional: 128 | 0 | 64 | 256 | 2 | 8192 | 16384 | 65536,
|
||||
RequestOptional: 128 | 64 | 256 | 2 | 8192 | 16384 | 65536,
|
||||
DisGroupMsgFilter: 1,
|
||||
C2CMsg: &jce.SvcReqGetMsgV2{
|
||||
Uin: c.Uin,
|
||||
|
@ -134,11 +134,11 @@ func (c *QQClient) buildSystemMsgNewGroupPacket(suspicious bool) (uint16, []byte
|
||||
}
|
||||
|
||||
// ProfileService.Pb.ReqSystemMsgAction.Group
|
||||
func (c *QQClient) buildSystemMsgGroupActionPacket(reqId, requester, group int64, msgType int32, isInvite, accept, block bool, reason string) (uint16, []byte) {
|
||||
func (c *QQClient) buildSystemMsgGroupActionPacket(reqID, requester, group int64, msgType int32, isInvite, accept, block bool, reason string) (uint16, []byte) {
|
||||
seq := c.nextSeq()
|
||||
req := &structmsg.ReqSystemMsgAction{
|
||||
MsgType: msgType,
|
||||
MsgSeq: reqId,
|
||||
MsgSeq: reqID,
|
||||
ReqUin: requester,
|
||||
SubType: 1,
|
||||
SrcId: 3,
|
||||
@ -174,11 +174,11 @@ func (c *QQClient) buildSystemMsgGroupActionPacket(reqId, requester, group int64
|
||||
}
|
||||
|
||||
// ProfileService.Pb.ReqSystemMsgAction.Friend
|
||||
func (c *QQClient) buildSystemMsgFriendActionPacket(reqId, requester int64, accept bool) (uint16, []byte) {
|
||||
func (c *QQClient) buildSystemMsgFriendActionPacket(reqID, requester int64, accept bool) (uint16, []byte) {
|
||||
seq := c.nextSeq()
|
||||
req := &structmsg.ReqSystemMsgAction{
|
||||
MsgType: 1,
|
||||
MsgSeq: reqId,
|
||||
MsgSeq: reqID,
|
||||
ReqUin: requester,
|
||||
SubType: 1,
|
||||
SrcId: 6,
|
||||
|
@ -150,9 +150,9 @@ func (c *QQClient) decodeT186(data []byte) {
|
||||
|
||||
// --- tlv readers ---
|
||||
|
||||
func readT125(data []byte) (openId, openKey []byte) {
|
||||
func readT125(data []byte) (openID, openKey []byte) {
|
||||
reader := binary.NewReader(data)
|
||||
openId = reader.ReadBytesShort()
|
||||
openID = reader.ReadBytesShort()
|
||||
openKey = reader.ReadBytesShort()
|
||||
return
|
||||
}
|
||||
@ -166,9 +166,9 @@ func readT11A(data []byte) (nick string, age, gender uint16) {
|
||||
return
|
||||
}
|
||||
|
||||
func readT199(data []byte) (openId, payToken []byte) {
|
||||
func readT199(data []byte) (openID, payToken []byte) {
|
||||
reader := binary.NewReader(data)
|
||||
openId = reader.ReadBytesShort()
|
||||
openID = reader.ReadBytesShort()
|
||||
payToken = reader.ReadBytesShort()
|
||||
return
|
||||
}
|
||||
|
@ -588,7 +588,7 @@ func (forMsg *ForwardMessage) CalculateValidationDataForward(seq, random int32,
|
||||
}
|
||||
|
||||
func (forMsg *ForwardMessage) packForwardMsg(seq int32, random int32, groupCode int64) []*msg.Message {
|
||||
var msgs []*msg.Message
|
||||
var msgs = make([]*msg.Message, 0, len(forMsg.Nodes))
|
||||
for _, node := range forMsg.Nodes {
|
||||
msgs = append(msgs, &msg.Message{
|
||||
Head: &msg.MessageHead{
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/Mrs4s/MiraiGo/binary"
|
||||
"github.com/Mrs4s/MiraiGo/client/pb/msg"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
var imgOld = []byte{0x15, 0x36, 0x20, 0x39, 0x32, 0x6B, 0x41, 0x31, 0x00, 0x38, 0x37, 0x32, 0x66, 0x30, 0x36, 0x36, 0x30, 0x33, 0x61, 0x65, 0x31, 0x30, 0x33, 0x62, 0x37, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
@ -101,7 +101,7 @@ func (e *GroupImageElement) Pack() (r []*msg.Elem) {
|
||||
FilePath: &e.ImageId,
|
||||
ImageType: &e.ImageType,
|
||||
Size: &e.Size,
|
||||
Md5: e.Md5[:],
|
||||
Md5: e.Md5,
|
||||
Flag: make([]byte, 4),
|
||||
//OldData: imgOld,
|
||||
},
|
||||
@ -216,7 +216,7 @@ func (e *GroupFlashPicElement) Pack() (r []*msg.Elem) {
|
||||
FileId: proto.Int32(int32(e.FileId)),
|
||||
FilePath: &e.ImageId,
|
||||
Size: &e.Size,
|
||||
Md5: e.Md5[:],
|
||||
Md5: e.Md5,
|
||||
Flag: make([]byte, 4),
|
||||
},
|
||||
}
|
||||
@ -250,7 +250,7 @@ func (e *GroupShowPicElement) Pack() (r []*msg.Elem) {
|
||||
FileId: proto.Int32(int32(e.FileId)),
|
||||
FilePath: &e.ImageId,
|
||||
Size: &e.Size,
|
||||
Md5: e.Md5[:],
|
||||
Md5: e.Md5,
|
||||
Flag: []byte{0x11, 0x00, 0x00, 0x00},
|
||||
//OldData: imgOld,
|
||||
PbReserve: reserve,
|
||||
|
@ -25,7 +25,7 @@ func BuildLoginPacket(uin int64, bodyType byte, key, body, extraData []byte) []b
|
||||
return w.Bytes()
|
||||
}
|
||||
|
||||
func BuildUniPacket(uin int64, seq uint16, commandName string, encryptType byte, sessionId, extraData, key, body []byte) []byte {
|
||||
func BuildUniPacket(uin int64, seq uint16, commandName string, encryptType byte, sessionID, extraData, key, body []byte) []byte {
|
||||
w := binary.NewWriter()
|
||||
w.WriteIntLvPacket(4, func(w *binary.Writer) {
|
||||
w.WriteUInt32(0x0B)
|
||||
@ -34,7 +34,7 @@ func BuildUniPacket(uin int64, seq uint16, commandName string, encryptType byte,
|
||||
w.WriteByte(0)
|
||||
w.WriteString(strconv.FormatInt(uin, 10))
|
||||
w.EncryptAndWrite(key, binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUniPacket(commandName, sessionId, extraData, body)
|
||||
w.WriteUniPacket(commandName, sessionID, extraData, body)
|
||||
}))
|
||||
})
|
||||
return w.Bytes()
|
||||
|
@ -72,12 +72,12 @@ func BuildCode2DRequestPacket(seq uint32, j uint64, cmd uint16, bodyFunc func(wr
|
||||
})
|
||||
}
|
||||
|
||||
func BuildSsoPacket(seq uint16, appId uint32, commandName, imei string, extData, outPacketSessionId, body, ksid []byte) []byte {
|
||||
func BuildSsoPacket(seq uint16, appID uint32, commandName, imei string, extData, outPacketSessionId, body, ksid []byte) []byte {
|
||||
p := binary.NewWriter()
|
||||
p.WriteIntLvPacket(4, func(writer *binary.Writer) {
|
||||
writer.WriteUInt32(uint32(seq))
|
||||
writer.WriteUInt32(appId)
|
||||
writer.WriteUInt32(appId)
|
||||
writer.WriteUInt32(appID)
|
||||
writer.WriteUInt32(appID)
|
||||
writer.Write([]byte{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00})
|
||||
if len(extData) == 0 || len(extData) == 4 {
|
||||
writer.WriteUInt32(0x04)
|
||||
@ -142,7 +142,7 @@ func parseSsoFrame(payload []byte, flag2 byte) (*IncomingPacket, error) {
|
||||
if reader.ReadInt32()-4 > int32(reader.Len()) {
|
||||
return nil, errors.WithStack(ErrPacketDropped)
|
||||
}
|
||||
seqId := reader.ReadInt32()
|
||||
seqID := reader.ReadInt32()
|
||||
retCode := reader.ReadInt32()
|
||||
if retCode != 0 {
|
||||
if retCode == -10008 {
|
||||
@ -152,13 +152,13 @@ func parseSsoFrame(payload []byte, flag2 byte) (*IncomingPacket, error) {
|
||||
}
|
||||
reader.ReadBytes(int(reader.ReadInt32()) - 4) // extra data
|
||||
commandName := reader.ReadString()
|
||||
sessionId := reader.ReadBytes(int(reader.ReadInt32()) - 4)
|
||||
sessionID := reader.ReadBytes(int(reader.ReadInt32()) - 4)
|
||||
if commandName == "Heartbeat.Alive" {
|
||||
return &IncomingPacket{
|
||||
SequenceId: uint16(seqId),
|
||||
SequenceId: uint16(seqID),
|
||||
Flag2: flag2,
|
||||
CommandName: commandName,
|
||||
SessionId: sessionId,
|
||||
SessionId: sessionID,
|
||||
Payload: []byte{},
|
||||
}, nil
|
||||
}
|
||||
@ -182,10 +182,10 @@ func parseSsoFrame(payload []byte, flag2 byte) (*IncomingPacket, error) {
|
||||
return nil
|
||||
}()
|
||||
return &IncomingPacket{
|
||||
SequenceId: uint16(seqId),
|
||||
SequenceId: uint16(seqID),
|
||||
Flag2: flag2,
|
||||
CommandName: commandName,
|
||||
SessionId: sessionId,
|
||||
SessionId: sessionID,
|
||||
Payload: packet,
|
||||
}, nil
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ func ChunkString(s string, chunkSize int) []string {
|
||||
|
||||
func ChineseLength(str string, limit int) int {
|
||||
sum := 0
|
||||
for _, r := range []rune(str) {
|
||||
for _, r := range str {
|
||||
switch {
|
||||
case r >= '\u0000' && r <= '\u007F':
|
||||
sum += 1
|
||||
@ -62,9 +62,9 @@ func ChineseLength(str string, limit int) int {
|
||||
return sum
|
||||
}
|
||||
|
||||
// from github.com/savsgio/gotils/strconv
|
||||
// B2S converts byte slice to a string without memory allocation.
|
||||
// See https://groups.google.com/forum/#!msg/Golang-Nuts/ENgbUzYvCuU/90yGx7GUAgAJ .
|
||||
// from github.com/savsgio/gotils/strconv
|
||||
func B2S(b []byte) string {
|
||||
return *(*string)(unsafe.Pointer(&b))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user