1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 19:17:38 +08:00

add file storage svc.

This commit is contained in:
Mrs4s 2020-12-31 02:21:11 +08:00
parent 2476ece99e
commit 12ea6ae4c7
4 changed files with 139 additions and 28 deletions

View File

@ -322,6 +322,18 @@ func (r *JceReader) ReadAny(tag int) interface{} {
} }
} }
func (r *JceReader) ReadJceStruct(obj IJceStruct, tag int) {
if !r.skipToTag(tag) {
return
}
hd, _ := r.readHead()
if hd.Type != 10 {
return
}
obj.ReadFrom(r)
r.skipToStructEnd()
}
func (r *JceReader) ReadMapF(tag int, f func(interface{}, interface{})) { func (r *JceReader) ReadMapF(tag int, f func(interface{}, interface{})) {
if !r.skipToTag(tag) { if !r.skipToTag(tag) {
return return

View File

@ -33,6 +33,46 @@ type (
Location string `jceId:"8"` Location string `jceId:"8"`
} }
FileStoragePushFSSvcList struct {
UploadList []FileStorageServerInfo `jceId:"0"`
PicDownloadList []FileStorageServerInfo `jceId:"1"`
GPicDownloadList []FileStorageServerInfo `jceId:"2"`
QZoneProxyServiceList []FileStorageServerInfo `jceId:"3"`
UrlEncodeServiceList []FileStorageServerInfo `jceId:"4"`
BigDataChannel *BigDataChannel `jceId:"5"`
VipEmotionList []FileStorageServerInfo `jceId:"6"`
C2CPicDownList []FileStorageServerInfo `jceId:"7"`
//FmtIPInfo *FmtIPInfo `jceId:"8"`
//DomainIPChannel *DomainIPChannel `jceId:"9"`
PttList []byte `jceId:"10"`
}
FileStorageServerInfo struct {
Server string `jceId:"1"`
Port int32 `jceId:"2"`
}
BigDataChannel struct {
IPLists []BigDataIPList `jceId:"0"`
SigSession []byte `jceId:"1"`
KeySession []byte `jceId:"2"`
SigUin int64 `jceId:"3"`
ConnectFlag int32 `jceId:"4"`
PbBuf []byte `jceId:"5"`
}
BigDataIPList struct {
ServiceType int64 `jceId:"0"`
IPList []BigDataIPInfo `jceId:"1"`
FragmentSize int64 `jceId:"3"`
}
BigDataIPInfo struct {
Type int64 `jceId:"0"`
Server string `jceId:"1"`
Port int64 `jceId:"2"`
}
SvcReqRegister struct { SvcReqRegister struct {
IJceStruct IJceStruct
Uin int64 `jceId:"0"` Uin int64 `jceId:"0"`
@ -452,6 +492,54 @@ func (pkt *SsoServerInfo) ReadFrom(r *JceReader) {
pkt.Location = r.ReadString(8) pkt.Location = r.ReadString(8)
} }
func (pkt *FileStoragePushFSSvcList) ReadFrom(r *JceReader) {
pkt.UploadList = []FileStorageServerInfo{}
pkt.PicDownloadList = []FileStorageServerInfo{}
pkt.GPicDownloadList = []FileStorageServerInfo{}
pkt.QZoneProxyServiceList = []FileStorageServerInfo{}
pkt.UrlEncodeServiceList = []FileStorageServerInfo{}
pkt.BigDataChannel = &BigDataChannel{}
pkt.VipEmotionList = []FileStorageServerInfo{}
pkt.C2CPicDownList = []FileStorageServerInfo{}
r.ReadSlice(&pkt.UploadList, 0)
r.ReadSlice(&pkt.PicDownloadList, 1)
r.ReadSlice(&pkt.GPicDownloadList, 2)
r.ReadSlice(&pkt.QZoneProxyServiceList, 3)
r.ReadSlice(&pkt.UrlEncodeServiceList, 4)
r.ReadJceStruct(pkt.BigDataChannel, 5)
r.ReadSlice(&pkt.VipEmotionList, 6)
r.ReadSlice(&pkt.C2CPicDownList, 7)
pkt.PttList = r.ReadAny(10).([]byte)
}
func (pkt *FileStorageServerInfo) ReadFrom(r *JceReader) {
pkt.Server = r.ReadString(1)
pkt.Port = r.ReadInt32(2)
}
func (pkt *BigDataChannel) ReadFrom(r *JceReader) {
pkt.IPLists = []BigDataIPList{}
r.ReadSlice(&pkt.IPLists, 0)
pkt.SigSession = r.ReadAny(1).([]byte)
pkt.KeySession = r.ReadAny(2).([]byte)
pkt.SigUin = r.ReadInt64(3)
pkt.ConnectFlag = r.ReadInt32(4)
pkt.PbBuf = r.ReadAny(5).([]byte)
}
func (pkt *BigDataIPList) ReadFrom(r *JceReader) {
pkt.IPList = []BigDataIPInfo{}
pkt.ServiceType = r.ReadInt64(0)
r.ReadSlice(&pkt.IPList, 1)
pkt.FragmentSize = r.ReadInt64(3)
}
func (pkt *BigDataIPInfo) ReadFrom(r *JceReader) {
pkt.Type = r.ReadInt64(0)
pkt.Server = r.ReadString(1)
pkt.Port = r.ReadInt64(2)
}
func (pkt *SvcReqRegister) ToBytes() []byte { func (pkt *SvcReqRegister) ToBytes() []byte {
w := NewJceWriter() w := NewJceWriter()
w.WriteJceStructRaw(pkt) w.WriteJceStructRaw(pkt)

View File

@ -6,6 +6,7 @@ import (
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/Mrs4s/MiraiGo/binary/jce"
"image" "image"
"io" "io"
"math/rand" "math/rand"
@ -68,6 +69,7 @@ type QQClient struct {
rollbackSig []byte rollbackSig []byte
timeDiff int64 timeDiff int64
sigInfo *loginSigInfo sigInfo *loginSigInfo
fileStorageInfo *jce.FileStoragePushFSSvcList
pwdFlag bool pwdFlag bool
lastMessageSeq int32 lastMessageSeq int32

View File

@ -210,39 +210,48 @@ func decodePushReqPacket(c *QQClient, _ uint16, payload []byte) (interface{}, er
data := &jce.RequestDataVersion2{} data := &jce.RequestDataVersion2{}
data.ReadFrom(jce.NewJceReader(request.SBuffer)) data.ReadFrom(jce.NewJceReader(request.SBuffer))
r := jce.NewJceReader(data.Map["PushReq"]["ConfigPush.PushReq"][1:]) r := jce.NewJceReader(data.Map["PushReq"]["ConfigPush.PushReq"][1:])
jceBuf := []byte{}
t := r.ReadInt32(1) t := r.ReadInt32(1)
r.ReadSlice(&jceBuf, 2) jceBuf := r.ReadAny(2).([]byte)
if t == 1 && len(jceBuf) > 0 { if len(jceBuf) > 0 {
ssoPkt := jce.NewJceReader(jceBuf) switch t {
servers := []jce.SsoServerInfo{} case 1:
ssoPkt.ReadSlice(&servers, 1) ssoPkt := jce.NewJceReader(jceBuf)
if len(servers) > 0 { servers := []jce.SsoServerInfo{}
var adds []*net.TCPAddr ssoPkt.ReadSlice(&servers, 1)
for _, s := range servers { if len(servers) > 0 {
if strings.Contains(s.Server, "com") { var adds []*net.TCPAddr
continue for _, s := range servers {
} if strings.Contains(s.Server, "com") {
c.Debug("got new server addr: %v location: %v", s.Server, s.Location) continue
adds = append(adds, &net.TCPAddr{
IP: net.ParseIP(s.Server),
Port: int(s.Port),
})
}
f := true
for _, e := range c.eventHandlers.serverUpdatedHandlers {
cover(func() {
if !e(c, &ServerUpdatedEvent{Servers: servers}) {
f = false
} }
}) c.Debug("got new server addr: %v location: %v", s.Server, s.Location)
adds = append(adds, &net.TCPAddr{
IP: net.ParseIP(s.Server),
Port: int(s.Port),
})
}
f := true
for _, e := range c.eventHandlers.serverUpdatedHandlers {
cover(func() {
if !e(c, &ServerUpdatedEvent{Servers: servers}) {
f = false
}
})
}
if f {
c.SetCustomServer(adds)
}
return nil, nil
} }
if f { case 2:
c.SetCustomServer(adds) fmtPkt := jce.NewJceReader(jceBuf)
} list := &jce.FileStoragePushFSSvcList{}
return nil, nil list.ReadFrom(fmtPkt)
c.Debug("got file storage svc push.")
c.fileStorageInfo = list
} }
} }
seq := r.ReadInt64(3) seq := r.ReadInt64(3)
_, pkt := c.buildConfPushRespPacket(t, seq, jceBuf) _, pkt := c.buildConfPushRespPacket(t, seq, jceBuf)
return nil, c.send(pkt) return nil, c.send(pkt)