mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 11:07:40 +08:00
fix(#209): OpenWriterF encode error
This commit is contained in:
parent
e043181fc1
commit
d3ab5965d5
@ -46,7 +46,6 @@ func (r *JceReader) skipHead() {
|
|||||||
l = 2
|
l = 2
|
||||||
}
|
}
|
||||||
r.off += l
|
r.off += l
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *JceReader) skip(l int) {
|
func (r *JceReader) skip(l int) {
|
||||||
|
@ -546,9 +546,6 @@ func (pkt *RequestPacket) ToBytes() []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (pkt *RequestPacket) ReadFrom(r *JceReader) {
|
func (pkt *RequestPacket) ReadFrom(r *JceReader) {
|
||||||
pkt.SBuffer = []byte{}
|
|
||||||
pkt.Context = make(map[string]string)
|
|
||||||
pkt.Status = make(map[string]string)
|
|
||||||
pkt.IVersion = r.ReadInt16(1)
|
pkt.IVersion = r.ReadInt16(1)
|
||||||
pkt.CPacketType = r.ReadByte(2)
|
pkt.CPacketType = r.ReadByte(2)
|
||||||
pkt.IMessageType = r.ReadInt32(3)
|
pkt.IMessageType = r.ReadInt32(3)
|
||||||
@ -596,9 +593,9 @@ func (pkt *FileStoragePushFSSvcList) ReadFrom(r *JceReader) {
|
|||||||
pkt.QZoneProxyServiceList = r.ReadFileStorageServerInfos(3)
|
pkt.QZoneProxyServiceList = r.ReadFileStorageServerInfos(3)
|
||||||
pkt.UrlEncodeServiceList = r.ReadFileStorageServerInfos(4)
|
pkt.UrlEncodeServiceList = r.ReadFileStorageServerInfos(4)
|
||||||
pkt.BigDataChannel = &BigDataChannel{}
|
pkt.BigDataChannel = &BigDataChannel{}
|
||||||
pkt.VipEmotionList = r.ReadFileStorageServerInfos(5)
|
|
||||||
pkt.C2CPicDownList = r.ReadFileStorageServerInfos(7)
|
|
||||||
r.ReadJceStruct(pkt.BigDataChannel, 5)
|
r.ReadJceStruct(pkt.BigDataChannel, 5)
|
||||||
|
pkt.VipEmotionList = r.ReadFileStorageServerInfos(6)
|
||||||
|
pkt.C2CPicDownList = r.ReadFileStorageServerInfos(7)
|
||||||
pkt.PttList = r.ReadBytes(10)
|
pkt.PttList = r.ReadBytes(10)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,9 +7,9 @@ import (
|
|||||||
|
|
||||||
type TEA [4]uint32
|
type TEA [4]uint32
|
||||||
|
|
||||||
// Uint32 returns a lock free uint32 value.
|
// randuint32 returns a lock free uint32 value.
|
||||||
//go:linkname Uint32 runtime.fastrand
|
//go:linkname randuint32 runtime.fastrand
|
||||||
func Uint32() uint32
|
func randuint32() uint32
|
||||||
|
|
||||||
// Encrypt tea 加密
|
// Encrypt tea 加密
|
||||||
// http://bbs.chinaunix.net/thread-583468-1-1.html
|
// http://bbs.chinaunix.net/thread-583468-1-1.html
|
||||||
@ -18,9 +18,9 @@ func (t TEA) Encrypt(src []byte) (dst []byte) {
|
|||||||
lens := len(src)
|
lens := len(src)
|
||||||
fill := 10 - (lens+1)%8
|
fill := 10 - (lens+1)%8
|
||||||
dst = make([]byte, fill+lens+7)
|
dst = make([]byte, fill+lens+7)
|
||||||
binary.LittleEndian.PutUint32(dst, Uint32())
|
binary.LittleEndian.PutUint32(dst, randuint32())
|
||||||
binary.LittleEndian.PutUint32(dst[4:], Uint32())
|
binary.LittleEndian.PutUint32(dst[4:], randuint32())
|
||||||
binary.LittleEndian.PutUint32(dst[8:], Uint32())
|
binary.LittleEndian.PutUint32(dst[8:], randuint32())
|
||||||
dst[0] = byte(fill-3) | 0xF8 // 存储pad长度
|
dst[0] = byte(fill-3) | 0xF8 // 存储pad长度
|
||||||
copy(dst[fill:], src)
|
copy(dst[fill:], src)
|
||||||
|
|
||||||
|
@ -19,10 +19,9 @@ func NewWriterF(f func(writer *Writer)) []byte {
|
|||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpenWriterF must call func close
|
// OpenWriterF must call func cl to close
|
||||||
func OpenWriterF(f func(writer *Writer)) (b []byte, close func()) {
|
func OpenWriterF(f func(*Writer)) (b []byte, cl func()) {
|
||||||
w := SelectWriter()
|
w := SelectWriter()
|
||||||
w.WriteByte(0)
|
|
||||||
f(w)
|
f(w)
|
||||||
return w.Bytes(), func() { PutWriter(w) }
|
return w.Bytes(), func() { PutWriter(w) }
|
||||||
}
|
}
|
||||||
@ -80,11 +79,11 @@ func (w *Writer) EncryptAndWrite(key []byte, data []byte) {
|
|||||||
w.Write(NewTeaCipher(key).Encrypt(data))
|
w.Write(NewTeaCipher(key).Encrypt(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Writer) WriteIntLvPacket(offset int, f func(writer *Writer)) {
|
func (w *Writer) WriteIntLvPacket(offset int, f func(*Writer)) {
|
||||||
data, close := OpenWriterF(f)
|
data, cl := OpenWriterF(f)
|
||||||
w.WriteUInt32(uint32(len(data) + offset))
|
w.WriteUInt32(uint32(len(data) + offset))
|
||||||
w.Write(data)
|
w.Write(data)
|
||||||
close()
|
cl()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Writer) WriteUniPacket(commandName string, sessionId, extraData, body []byte) {
|
func (w *Writer) WriteUniPacket(commandName string, sessionId, extraData, body []byte) {
|
||||||
|
@ -169,9 +169,9 @@ func (c *QQClient) buildQRCodeLoginPacket(t106, t16a, t318 []byte) (uint16, []by
|
|||||||
|
|
||||||
w.Write(tlv.T18(16, uint32(c.Uin)))
|
w.Write(tlv.T18(16, uint32(c.Uin)))
|
||||||
w.Write(tlv.T1(uint32(c.Uin), c.deviceInfo.IpAddress))
|
w.Write(tlv.T1(uint32(c.Uin), c.deviceInfo.IpAddress))
|
||||||
wb, cl := binary.OpenWriterF(func(w *binary.Writer) {
|
wb, cl := binary.OpenWriterF(func(bw *binary.Writer) {
|
||||||
w.WriteUInt16(0x106)
|
bw.WriteUInt16(0x106)
|
||||||
w.WriteBytesShort(t106)
|
bw.WriteBytesShort(t106)
|
||||||
})
|
})
|
||||||
w.Write(wb)
|
w.Write(wb)
|
||||||
cl()
|
cl()
|
||||||
@ -196,9 +196,9 @@ func (c *QQClient) buildQRCodeLoginPacket(t106, t16a, t318 []byte) (uint16, []by
|
|||||||
|
|
||||||
w.Write(tlv.T145(c.deviceInfo.Guid))
|
w.Write(tlv.T145(c.deviceInfo.Guid))
|
||||||
w.Write(tlv.T147(16, []byte(c.version.SortVersionName), c.version.ApkSign))
|
w.Write(tlv.T147(16, []byte(c.version.SortVersionName), c.version.ApkSign))
|
||||||
wb, cl = binary.OpenWriterF(func(w *binary.Writer) {
|
wb, cl = binary.OpenWriterF(func(bw *binary.Writer) {
|
||||||
w.WriteUInt16(0x16A)
|
bw.WriteUInt16(0x16A)
|
||||||
w.WriteBytesShort(t16a)
|
bw.WriteBytesShort(t16a)
|
||||||
})
|
})
|
||||||
w.Write(wb)
|
w.Write(wb)
|
||||||
cl()
|
cl()
|
||||||
@ -223,9 +223,9 @@ func (c *QQClient) buildQRCodeLoginPacket(t106, t16a, t318 []byte) (uint16, []by
|
|||||||
w.Write(tlv.T516())
|
w.Write(tlv.T516())
|
||||||
w.Write(tlv.T521(8))
|
w.Write(tlv.T521(8))
|
||||||
// w.Write(tlv.T525(tlv.T536([]byte{0x01, 0x00})))
|
// w.Write(tlv.T525(tlv.T536([]byte{0x01, 0x00})))
|
||||||
wb, cl = binary.OpenWriterF(func(w *binary.Writer) {
|
wb, cl = binary.OpenWriterF(func(bw *binary.Writer) {
|
||||||
w.WriteUInt16(0x318)
|
bw.WriteUInt16(0x318)
|
||||||
w.WriteBytesShort(t318)
|
bw.WriteBytesShort(t318)
|
||||||
})
|
})
|
||||||
w.Write(wb)
|
w.Write(wb)
|
||||||
cl()
|
cl()
|
||||||
@ -312,9 +312,9 @@ func (c *QQClient) buildRequestTgtgtNopicsigPacket() (uint16, []byte) {
|
|||||||
|
|
||||||
w.Write(tlv.T18(16, uint32(c.Uin)))
|
w.Write(tlv.T18(16, uint32(c.Uin)))
|
||||||
w.Write(tlv.T1(uint32(c.Uin), c.deviceInfo.IpAddress))
|
w.Write(tlv.T1(uint32(c.Uin), c.deviceInfo.IpAddress))
|
||||||
wb, cl := binary.OpenWriterF(func(w *binary.Writer) {
|
wb, cl := binary.OpenWriterF(func(bw *binary.Writer) {
|
||||||
w.WriteUInt16(0x106)
|
bw.WriteUInt16(0x106)
|
||||||
w.WriteBytesShort(c.sigInfo.encryptedA1)
|
bw.WriteBytesShort(c.sigInfo.encryptedA1)
|
||||||
})
|
})
|
||||||
w.Write(wb)
|
w.Write(wb)
|
||||||
cl()
|
cl()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user