mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 19:17:38 +08:00
client: remove similar code
This commit is contained in:
parent
421755d938
commit
fb2d3d28f0
@ -64,7 +64,7 @@ func (s *Session) UploadBDH(input BdhInput) ([]byte, error) {
|
|||||||
sum, length := utils.ComputeMd5AndLength(input.Body)
|
sum, length := utils.ComputeMd5AndLength(input.Body)
|
||||||
_, _ = input.Body.Seek(0, io.SeekStart)
|
_, _ = input.Body.Seek(0, io.SeekStart)
|
||||||
if err := input.encrypt(s.SessionKey); err != nil {
|
if err := input.encrypt(s.SessionKey); err != nil {
|
||||||
return nil, errors.Wrap(err, "encrypt error")
|
return nil, err
|
||||||
}
|
}
|
||||||
conn, err := net.DialTimeout("tcp", addr, time.Second*20)
|
conn, err := net.DialTimeout("tcp", addr, time.Second*20)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -94,16 +94,7 @@ func (s *Session) UploadBDH(input BdhInput) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
ch := md5.Sum(chunk)
|
ch := md5.Sum(chunk)
|
||||||
head, _ := proto.Marshal(&pb.ReqDataHighwayHead{
|
head, _ := proto.Marshal(&pb.ReqDataHighwayHead{
|
||||||
MsgBasehead: &pb.DataHighwayHead{
|
MsgBasehead: s.dataHighwayHead(4096, input.CommandID, 2052),
|
||||||
Version: 1,
|
|
||||||
Uin: s.Uin,
|
|
||||||
Command: "PicUp.DataUp",
|
|
||||||
Seq: s.nextSeq(),
|
|
||||||
Appid: s.AppID,
|
|
||||||
Dataflag: 4096,
|
|
||||||
CommandId: input.CommandID,
|
|
||||||
LocaleId: 2052,
|
|
||||||
},
|
|
||||||
MsgSeghead: &pb.SegHead{
|
MsgSeghead: &pb.SegHead{
|
||||||
Filesize: length,
|
Filesize: length,
|
||||||
Dataoffset: int64(offset),
|
Dataoffset: int64(offset),
|
||||||
@ -157,7 +148,7 @@ func (s *Session) UploadBDHMultiThread(input BdhMultiThreadInput, threadCount in
|
|||||||
addr := s.SsoAddr[0].String()
|
addr := s.SsoAddr[0].String()
|
||||||
|
|
||||||
if err := input.encrypt(s.SessionKey); err != nil {
|
if err := input.encrypt(s.SessionKey); err != nil {
|
||||||
return nil, errors.Wrap(err, "encrypt error")
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
type BlockMetaData struct {
|
type BlockMetaData struct {
|
||||||
@ -236,16 +227,7 @@ func (s *Session) UploadBDHMultiThread(input BdhMultiThreadInput, threadCount in
|
|||||||
}
|
}
|
||||||
ch := md5.Sum(buffer)
|
ch := md5.Sum(buffer)
|
||||||
head, _ := proto.Marshal(&pb.ReqDataHighwayHead{
|
head, _ := proto.Marshal(&pb.ReqDataHighwayHead{
|
||||||
MsgBasehead: &pb.DataHighwayHead{
|
MsgBasehead: s.dataHighwayHead(4096, input.CommandID, 2052),
|
||||||
Version: 1,
|
|
||||||
Uin: s.Uin,
|
|
||||||
Command: "PicUp.DataUp",
|
|
||||||
Seq: s.nextSeq(),
|
|
||||||
Appid: s.AppID,
|
|
||||||
Dataflag: 4096,
|
|
||||||
CommandId: input.CommandID,
|
|
||||||
LocaleId: 2052,
|
|
||||||
},
|
|
||||||
MsgSeghead: &pb.SegHead{
|
MsgSeghead: &pb.SegHead{
|
||||||
Filesize: input.Size,
|
Filesize: input.Size,
|
||||||
Dataoffset: block.Offset,
|
Dataoffset: block.Offset,
|
||||||
|
@ -74,16 +74,7 @@ func (s *Session) Upload(addr Addr, input Input) error {
|
|||||||
}
|
}
|
||||||
ch := md5.Sum(chunk)
|
ch := md5.Sum(chunk)
|
||||||
head, _ := proto.Marshal(&pb.ReqDataHighwayHead{
|
head, _ := proto.Marshal(&pb.ReqDataHighwayHead{
|
||||||
MsgBasehead: &pb.DataHighwayHead{
|
MsgBasehead: s.dataHighwayHead(4096, input.CommandID, 2052),
|
||||||
Version: 1,
|
|
||||||
Uin: s.Uin,
|
|
||||||
Command: "PicUp.DataUp",
|
|
||||||
Seq: s.nextSeq(),
|
|
||||||
Appid: s.AppID,
|
|
||||||
Dataflag: 4096,
|
|
||||||
CommandId: input.CommandID,
|
|
||||||
LocaleId: 2052,
|
|
||||||
},
|
|
||||||
MsgSeghead: &pb.SegHead{
|
MsgSeghead: &pb.SegHead{
|
||||||
Filesize: length,
|
Filesize: length,
|
||||||
Dataoffset: int64(offset),
|
Dataoffset: int64(offset),
|
||||||
@ -144,16 +135,7 @@ func (s *Session) UploadExciting(input ExcitingInput) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
ch := md5.Sum(chunk)
|
ch := md5.Sum(chunk)
|
||||||
head, _ := proto.Marshal(&pb.ReqDataHighwayHead{
|
head, _ := proto.Marshal(&pb.ReqDataHighwayHead{
|
||||||
MsgBasehead: &pb.DataHighwayHead{
|
MsgBasehead: s.dataHighwayHead(0, input.CommandID, 0),
|
||||||
Version: 1,
|
|
||||||
Uin: s.Uin,
|
|
||||||
Command: "PicUp.DataUp",
|
|
||||||
Seq: s.nextSeq(),
|
|
||||||
Appid: s.AppID,
|
|
||||||
Dataflag: 0,
|
|
||||||
CommandId: input.CommandID,
|
|
||||||
LocaleId: 0,
|
|
||||||
},
|
|
||||||
MsgSeghead: &pb.SegHead{
|
MsgSeghead: &pb.SegHead{
|
||||||
Filesize: fileLength,
|
Filesize: fileLength,
|
||||||
Dataoffset: offset,
|
Dataoffset: offset,
|
||||||
@ -202,6 +184,19 @@ func (s *Session) nextSeq() int32 {
|
|||||||
return atomic.AddInt32(&s.seq, 2)
|
return atomic.AddInt32(&s.seq, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Session) dataHighwayHead(flag, cmd, locale int32) *pb.DataHighwayHead {
|
||||||
|
return &pb.DataHighwayHead{
|
||||||
|
Version: 1,
|
||||||
|
Uin: s.Uin,
|
||||||
|
Command: "PicUp.DataUp",
|
||||||
|
Seq: s.nextSeq(),
|
||||||
|
Appid: s.AppID,
|
||||||
|
Dataflag: flag,
|
||||||
|
CommandId: cmd,
|
||||||
|
LocaleId: locale,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Session) sendHeartbreak(conn net.Conn) error {
|
func (s *Session) sendHeartbreak(conn net.Conn) error {
|
||||||
head, _ := proto.Marshal(&pb.ReqDataHighwayHead{
|
head, _ := proto.Marshal(&pb.ReqDataHighwayHead{
|
||||||
MsgBasehead: &pb.DataHighwayHead{
|
MsgBasehead: &pb.DataHighwayHead{
|
||||||
|
@ -162,20 +162,9 @@ func (c *QQClient) buildFriendSendingPacket(target int64, msgSeq, r, pkgNum, pkg
|
|||||||
Ptt: ptt,
|
Ptt: ptt,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
MsgSeq: &msgSeq,
|
MsgSeq: &msgSeq,
|
||||||
MsgRand: &r,
|
MsgRand: &r,
|
||||||
SyncCookie: func() []byte {
|
SyncCookie: syncCookie(time),
|
||||||
cookie := &msg.SyncCookie{
|
|
||||||
Time: &time,
|
|
||||||
Ran1: proto.Int64(rand.Int63()),
|
|
||||||
Ran2: proto.Int64(rand.Int63()),
|
|
||||||
Const1: &syncConst1,
|
|
||||||
Const2: &syncConst2,
|
|
||||||
Const3: proto.Int64(0x1d),
|
|
||||||
}
|
|
||||||
b, _ := proto.Marshal(cookie)
|
|
||||||
return b
|
|
||||||
}(),
|
|
||||||
}
|
}
|
||||||
payload, _ := proto.Marshal(req)
|
payload, _ := proto.Marshal(req)
|
||||||
return c.uniPacket("MessageSvc.PbSendMsg", payload)
|
return c.uniPacket("MessageSvc.PbSendMsg", payload)
|
||||||
@ -194,26 +183,16 @@ func (c *QQClient) buildGroupTempSendingPacket(groupUin, target int64, msgSeq, r
|
|||||||
Elems: message.ToProtoElems(m.Elements, false),
|
Elems: message.ToProtoElems(m.Elements, false),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
MsgSeq: &msgSeq,
|
MsgSeq: &msgSeq,
|
||||||
MsgRand: &r,
|
MsgRand: &r,
|
||||||
SyncCookie: func() []byte {
|
SyncCookie: syncCookie(time),
|
||||||
cookie := &msg.SyncCookie{
|
|
||||||
Time: &time,
|
|
||||||
Ran1: proto.Int64(rand.Int63()),
|
|
||||||
Ran2: proto.Int64(rand.Int63()),
|
|
||||||
Const1: &syncConst1,
|
|
||||||
Const2: &syncConst2,
|
|
||||||
Const3: proto.Int64(0x1d),
|
|
||||||
}
|
|
||||||
b, _ := proto.Marshal(cookie)
|
|
||||||
return b
|
|
||||||
}(),
|
|
||||||
}
|
}
|
||||||
payload, _ := proto.Marshal(req)
|
payload, _ := proto.Marshal(req)
|
||||||
return c.uniPacket("MessageSvc.PbSendMsg", payload)
|
return c.uniPacket("MessageSvc.PbSendMsg", payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *QQClient) buildWPATempSendingPacket(uin int64, sig []byte, msgSeq, r int32, time int64, m *message.SendingMessage) (uint16, []byte) {
|
func (c *QQClient) buildWPATempSendingPacket(uin int64, sig []byte, msgSeq, r int32, time int64, m *message.SendingMessage) (uint16, []byte) {
|
||||||
|
|
||||||
req := &msg.SendMessageRequest{
|
req := &msg.SendMessageRequest{
|
||||||
RoutingHead: &msg.RoutingHead{WpaTmp: &msg.WPATmp{
|
RoutingHead: &msg.RoutingHead{WpaTmp: &msg.WPATmp{
|
||||||
ToUin: proto.Uint64(uint64(uin)),
|
ToUin: proto.Uint64(uint64(uin)),
|
||||||
@ -225,21 +204,22 @@ func (c *QQClient) buildWPATempSendingPacket(uin int64, sig []byte, msgSeq, r in
|
|||||||
Elems: message.ToProtoElems(m.Elements, false),
|
Elems: message.ToProtoElems(m.Elements, false),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
MsgSeq: &msgSeq,
|
MsgSeq: &msgSeq,
|
||||||
MsgRand: &r,
|
MsgRand: &r,
|
||||||
SyncCookie: func() []byte {
|
SyncCookie: syncCookie(time),
|
||||||
cookie := &msg.SyncCookie{
|
|
||||||
Time: &time,
|
|
||||||
Ran1: proto.Int64(rand.Int63()),
|
|
||||||
Ran2: proto.Int64(rand.Int63()),
|
|
||||||
Const1: &syncConst1,
|
|
||||||
Const2: &syncConst2,
|
|
||||||
Const3: proto.Int64(0x1d),
|
|
||||||
}
|
|
||||||
b, _ := proto.Marshal(cookie)
|
|
||||||
return b
|
|
||||||
}(),
|
|
||||||
}
|
}
|
||||||
payload, _ := proto.Marshal(req)
|
payload, _ := proto.Marshal(req)
|
||||||
return c.uniPacket("MessageSvc.PbSendMsg", payload)
|
return c.uniPacket("MessageSvc.PbSendMsg", payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func syncCookie(time int64) []byte {
|
||||||
|
cookie, _ := proto.Marshal(&msg.SyncCookie{
|
||||||
|
Time: &time,
|
||||||
|
Ran1: proto.Int64(rand.Int63()),
|
||||||
|
Ran2: proto.Int64(rand.Int63()),
|
||||||
|
Const1: &syncConst1,
|
||||||
|
Const2: &syncConst2,
|
||||||
|
Const3: proto.Int64(0x1d),
|
||||||
|
})
|
||||||
|
return cookie
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user