mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 11:07:40 +08:00
try to fix image upload.
This commit is contained in:
parent
fe8e98b9d8
commit
7654a7a2a1
@ -552,7 +552,7 @@ func (c *QQClient) buildGroupImageStorePacket(groupCode int64, md5 []byte, size
|
||||
|
||||
func (c *QQClient) buildImageUploadPacket(data, updKey []byte, commandId int32, fmd5 [16]byte) (r [][]byte) {
|
||||
offset := 0
|
||||
binary.ToChunkedBytesF(data, 8192*1024, func(chunked []byte) {
|
||||
binary.ToChunkedBytesF(data, 8192*8, func(chunked []byte) {
|
||||
w := binary.NewWriter()
|
||||
cmd5 := md5.Sum(chunked)
|
||||
head, _ := proto.Marshal(&pb.ReqDataHighwayHead{
|
||||
|
@ -8,10 +8,9 @@ import (
|
||||
"github.com/Mrs4s/MiraiGo/binary"
|
||||
"github.com/Mrs4s/MiraiGo/client/pb"
|
||||
"github.com/Mrs4s/MiraiGo/utils"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"net"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (c *QQClient) highwayUploadImage(ip uint32, port int, updKey, img []byte, cmdId int32) error {
|
||||
@ -25,25 +24,23 @@ func (c *QQClient) highwayUploadImage(ip uint32, port int, updKey, img []byte, c
|
||||
return err
|
||||
}
|
||||
defer conn.Close()
|
||||
if err = conn.SetDeadline(time.Now().Add(time.Second * 10)); err != nil {
|
||||
return err
|
||||
}
|
||||
h := md5.Sum(img)
|
||||
pkt := c.buildImageUploadPacket(img, updKey, cmdId, h)
|
||||
r := binary.NewNetworkReader(conn)
|
||||
for _, p := range pkt {
|
||||
_, err = conn.Write(p)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r := binary.NewNetworkReader(conn)
|
||||
_, err = r.ReadByte()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
hl, _ := r.ReadInt32()
|
||||
_, _ = r.ReadBytes(4)
|
||||
a2, _ := r.ReadInt32()
|
||||
payload, _ := r.ReadBytes(int(hl))
|
||||
_, _ = r.ReadBytes(int(a2))
|
||||
r.ReadByte()
|
||||
rsp := new(pb.RspDataHighwayHead)
|
||||
if err = proto.Unmarshal(payload, rsp); err != nil {
|
||||
return err
|
||||
@ -51,6 +48,8 @@ func (c *QQClient) highwayUploadImage(ip uint32, port int, updKey, img []byte, c
|
||||
if rsp.ErrorCode != 0 {
|
||||
return errors.New("upload failed")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user