mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 11:07:40 +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)
|
||||
_, _ = input.Body.Seek(0, io.SeekStart)
|
||||
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)
|
||||
if err != nil {
|
||||
@ -94,16 +94,7 @@ func (s *Session) UploadBDH(input BdhInput) ([]byte, error) {
|
||||
}
|
||||
ch := md5.Sum(chunk)
|
||||
head, _ := proto.Marshal(&pb.ReqDataHighwayHead{
|
||||
MsgBasehead: &pb.DataHighwayHead{
|
||||
Version: 1,
|
||||
Uin: s.Uin,
|
||||
Command: "PicUp.DataUp",
|
||||
Seq: s.nextSeq(),
|
||||
Appid: s.AppID,
|
||||
Dataflag: 4096,
|
||||
CommandId: input.CommandID,
|
||||
LocaleId: 2052,
|
||||
},
|
||||
MsgBasehead: s.dataHighwayHead(4096, input.CommandID, 2052),
|
||||
MsgSeghead: &pb.SegHead{
|
||||
Filesize: length,
|
||||
Dataoffset: int64(offset),
|
||||
@ -157,7 +148,7 @@ func (s *Session) UploadBDHMultiThread(input BdhMultiThreadInput, threadCount in
|
||||
addr := s.SsoAddr[0].String()
|
||||
|
||||
if err := input.encrypt(s.SessionKey); err != nil {
|
||||
return nil, errors.Wrap(err, "encrypt error")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
type BlockMetaData struct {
|
||||
@ -236,16 +227,7 @@ func (s *Session) UploadBDHMultiThread(input BdhMultiThreadInput, threadCount in
|
||||
}
|
||||
ch := md5.Sum(buffer)
|
||||
head, _ := proto.Marshal(&pb.ReqDataHighwayHead{
|
||||
MsgBasehead: &pb.DataHighwayHead{
|
||||
Version: 1,
|
||||
Uin: s.Uin,
|
||||
Command: "PicUp.DataUp",
|
||||
Seq: s.nextSeq(),
|
||||
Appid: s.AppID,
|
||||
Dataflag: 4096,
|
||||
CommandId: input.CommandID,
|
||||
LocaleId: 2052,
|
||||
},
|
||||
MsgBasehead: s.dataHighwayHead(4096, input.CommandID, 2052),
|
||||
MsgSeghead: &pb.SegHead{
|
||||
Filesize: input.Size,
|
||||
Dataoffset: block.Offset,
|
||||
|
@ -74,16 +74,7 @@ func (s *Session) Upload(addr Addr, input Input) error {
|
||||
}
|
||||
ch := md5.Sum(chunk)
|
||||
head, _ := proto.Marshal(&pb.ReqDataHighwayHead{
|
||||
MsgBasehead: &pb.DataHighwayHead{
|
||||
Version: 1,
|
||||
Uin: s.Uin,
|
||||
Command: "PicUp.DataUp",
|
||||
Seq: s.nextSeq(),
|
||||
Appid: s.AppID,
|
||||
Dataflag: 4096,
|
||||
CommandId: input.CommandID,
|
||||
LocaleId: 2052,
|
||||
},
|
||||
MsgBasehead: s.dataHighwayHead(4096, input.CommandID, 2052),
|
||||
MsgSeghead: &pb.SegHead{
|
||||
Filesize: length,
|
||||
Dataoffset: int64(offset),
|
||||
@ -144,16 +135,7 @@ func (s *Session) UploadExciting(input ExcitingInput) ([]byte, error) {
|
||||
}
|
||||
ch := md5.Sum(chunk)
|
||||
head, _ := proto.Marshal(&pb.ReqDataHighwayHead{
|
||||
MsgBasehead: &pb.DataHighwayHead{
|
||||
Version: 1,
|
||||
Uin: s.Uin,
|
||||
Command: "PicUp.DataUp",
|
||||
Seq: s.nextSeq(),
|
||||
Appid: s.AppID,
|
||||
Dataflag: 0,
|
||||
CommandId: input.CommandID,
|
||||
LocaleId: 0,
|
||||
},
|
||||
MsgBasehead: s.dataHighwayHead(0, input.CommandID, 0),
|
||||
MsgSeghead: &pb.SegHead{
|
||||
Filesize: fileLength,
|
||||
Dataoffset: offset,
|
||||
@ -202,6 +184,19 @@ func (s *Session) nextSeq() int32 {
|
||||
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 {
|
||||
head, _ := proto.Marshal(&pb.ReqDataHighwayHead{
|
||||
MsgBasehead: &pb.DataHighwayHead{
|
||||
|
@ -164,18 +164,7 @@ func (c *QQClient) buildFriendSendingPacket(target int64, msgSeq, r, pkgNum, pkg
|
||||
},
|
||||
MsgSeq: &msgSeq,
|
||||
MsgRand: &r,
|
||||
SyncCookie: func() []byte {
|
||||
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
|
||||
}(),
|
||||
SyncCookie: syncCookie(time),
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniPacket("MessageSvc.PbSendMsg", payload)
|
||||
@ -196,24 +185,14 @@ func (c *QQClient) buildGroupTempSendingPacket(groupUin, target int64, msgSeq, r
|
||||
},
|
||||
MsgSeq: &msgSeq,
|
||||
MsgRand: &r,
|
||||
SyncCookie: func() []byte {
|
||||
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
|
||||
}(),
|
||||
SyncCookie: syncCookie(time),
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniPacket("MessageSvc.PbSendMsg", payload)
|
||||
}
|
||||
|
||||
func (c *QQClient) buildWPATempSendingPacket(uin int64, sig []byte, msgSeq, r int32, time int64, m *message.SendingMessage) (uint16, []byte) {
|
||||
|
||||
req := &msg.SendMessageRequest{
|
||||
RoutingHead: &msg.RoutingHead{WpaTmp: &msg.WPATmp{
|
||||
ToUin: proto.Uint64(uint64(uin)),
|
||||
@ -227,19 +206,20 @@ func (c *QQClient) buildWPATempSendingPacket(uin int64, sig []byte, msgSeq, r in
|
||||
},
|
||||
MsgSeq: &msgSeq,
|
||||
MsgRand: &r,
|
||||
SyncCookie: func() []byte {
|
||||
cookie := &msg.SyncCookie{
|
||||
SyncCookie: syncCookie(time),
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
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),
|
||||
}
|
||||
b, _ := proto.Marshal(cookie)
|
||||
return b
|
||||
}(),
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniPacket("MessageSvc.PbSendMsg", payload)
|
||||
})
|
||||
return cookie
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user