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) {
|
func (c *QQClient) buildImageUploadPacket(data, updKey []byte, commandId int32, fmd5 [16]byte) (r [][]byte) {
|
||||||
offset := 0
|
offset := 0
|
||||||
binary.ToChunkedBytesF(data, 8192*1024, func(chunked []byte) {
|
binary.ToChunkedBytesF(data, 8192*8, func(chunked []byte) {
|
||||||
w := binary.NewWriter()
|
w := binary.NewWriter()
|
||||||
cmd5 := md5.Sum(chunked)
|
cmd5 := md5.Sum(chunked)
|
||||||
head, _ := proto.Marshal(&pb.ReqDataHighwayHead{
|
head, _ := proto.Marshal(&pb.ReqDataHighwayHead{
|
||||||
|
@ -8,10 +8,9 @@ import (
|
|||||||
"github.com/Mrs4s/MiraiGo/binary"
|
"github.com/Mrs4s/MiraiGo/binary"
|
||||||
"github.com/Mrs4s/MiraiGo/client/pb"
|
"github.com/Mrs4s/MiraiGo/client/pb"
|
||||||
"github.com/Mrs4s/MiraiGo/utils"
|
"github.com/Mrs4s/MiraiGo/utils"
|
||||||
"github.com/golang/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *QQClient) highwayUploadImage(ip uint32, port int, updKey, img []byte, cmdId int32) error {
|
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
|
return err
|
||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
if err = conn.SetDeadline(time.Now().Add(time.Second * 10)); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
h := md5.Sum(img)
|
h := md5.Sum(img)
|
||||||
pkt := c.buildImageUploadPacket(img, updKey, cmdId, h)
|
pkt := c.buildImageUploadPacket(img, updKey, cmdId, h)
|
||||||
|
r := binary.NewNetworkReader(conn)
|
||||||
for _, p := range pkt {
|
for _, p := range pkt {
|
||||||
_, err = conn.Write(p)
|
_, err = conn.Write(p)
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
r := binary.NewNetworkReader(conn)
|
|
||||||
_, err = r.ReadByte()
|
_, err = r.ReadByte()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
hl, _ := r.ReadInt32()
|
hl, _ := r.ReadInt32()
|
||||||
_, _ = r.ReadBytes(4)
|
a2, _ := r.ReadInt32()
|
||||||
payload, _ := r.ReadBytes(int(hl))
|
payload, _ := r.ReadBytes(int(hl))
|
||||||
|
_, _ = r.ReadBytes(int(a2))
|
||||||
|
r.ReadByte()
|
||||||
rsp := new(pb.RspDataHighwayHead)
|
rsp := new(pb.RspDataHighwayHead)
|
||||||
if err = proto.Unmarshal(payload, rsp); err != nil {
|
if err = proto.Unmarshal(payload, rsp); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -51,6 +48,8 @@ func (c *QQClient) highwayUploadImage(ip uint32, port int, updKey, img []byte, c
|
|||||||
if rsp.ErrorCode != 0 {
|
if rsp.ErrorCode != 0 {
|
||||||
return errors.New("upload failed")
|
return errors.New("upload failed")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user