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