diff --git a/client/highway.go b/client/highway.go index 2fafd962..a92dc213 100644 --- a/client/highway.go +++ b/client/highway.go @@ -3,6 +3,7 @@ package client import ( "bytes" binary2 "encoding/binary" + "encoding/hex" "fmt" "io" "net/http" @@ -100,7 +101,7 @@ func (c *QQClient) UploadSrcByStreamAsync(commonId int, stream io.ReadSeeker, ti reqBody := UpBlock{ CommandId: commonId, Uin: uint(c.sig.Uin), - Sequence: uint(c.highwaySequence.Load()), + Sequence: uint(c.highwaySequence.Load() + 1), FileSize: fileSize, Offset: offset, Ticket: ticket, @@ -128,22 +129,27 @@ func (c *QQClient) UploadSrcByStreamAsync(commonId int, stream io.ReadSeeker, ti func (c *QQClient) SendUpBlockAsync(block UpBlock, server string) bool { head := &highway.DataHighwayHead{ - Version: 1, - Uin: proto.Some(strconv.Itoa(int(block.Uin))), - Command: proto.Some("PicUp.DataUp"), - Seq: uint32(block.Sequence), - AppId: uint32(c.appInfo.AppID), - DataFlag: 16, - CommandId: uint32(block.CommandId), + Version: 1, + Uin: proto.Some(strconv.Itoa(int(block.Uin))), + Command: proto.Some("PicUp.DataUp"), + Seq: proto.Some(uint32(block.Sequence)), + RetryTimes: proto.Some(uint32(0)), + AppId: uint32(c.appInfo.SubAppID), + DataFlag: 16, + CommandId: uint32(block.CommandId), } md5 := utils.Md5Digest(block.Block) segHead := &highway.SegHead{ + ServiceId: proto.Some(uint32(0)), Filesize: block.FileSize, - DataOffset: block.Offset, + DataOffset: proto.Some(block.Offset), DataLength: uint32(len(block.Block)), + RetCode: proto.Some(uint32(0)), ServiceTicket: block.Ticket, Md5: md5, FileMd5: block.FileMd5, + CacheAddr: proto.Some(uint32(0)), + CachePort: proto.Some(uint32(0)), } loginHead := &highway.LoginSigHead{ Uint32LoginSigType: 8, @@ -198,7 +204,17 @@ func SendPacketAsync(packet *highway.ReqDataHighwayHead, buffer *binary.Builder, if err != nil { return nil, err } - writer := binary.NewBuilder(nil).WriteBytes([]byte{0x28}, false).WriteU32(uint32(len(marshal))).WriteU32(uint32(buffer.Len())).WriteBytes(buffer.Data(), false).WriteBytes([]byte{0x29}, false) + + println(hex.EncodeToString(marshal)) + + writer := binary.NewBuilder(nil). + WriteBytes([]byte{0x28}, false). + WriteU32(uint32(len(marshal))). + WriteU32(uint32(buffer.Len())). + WriteBytes(marshal, false). + WriteBytes(buffer.Data(), false). + WriteBytes([]byte{0x29}, false) + return SendDataAsync(writer.Data(), serverURL, end) } diff --git a/client/imageUploader.go b/client/imageUploader.go index f89d6993..7c306d7b 100644 --- a/client/imageUploader.go +++ b/client/imageUploader.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/hex" "errors" + "fmt" "github.com/LagrangeDev/LagrangeGo/message" "github.com/LagrangeDev/LagrangeGo/packets/oidb" "github.com/LagrangeDev/LagrangeGo/packets/pb/service/highway" @@ -19,7 +20,7 @@ func ConvertIP(raw uint32) string { ip[1] = byte((raw >> 8) & 0xFF) ip[2] = byte((raw >> 16) & 0xFF) ip[3] = byte((raw >> 24) & 0xFF) - return string(ip) + return fmt.Sprintf("%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]) } func ConvertNTHighwayNetWork(ipv4s []*oidb2.IPv4) []*highway.NTHighwayIPv4 { diff --git a/packets/pb/service/highway/highway.pb.go b/packets/pb/service/highway/highway.pb.go index e93d92d3..128f853d 100644 --- a/packets/pb/service/highway/highway.pb.go +++ b/packets/pb/service/highway/highway.pb.go @@ -12,8 +12,8 @@ type DataHighwayHead struct { Version uint32 `protobuf:"varint,1,opt"` Uin proto.Option[string] `protobuf:"bytes,2,opt"` Command proto.Option[string] `protobuf:"bytes,3,opt"` - Seq uint32 `protobuf:"varint,4,opt"` - RetryTimes uint32 `protobuf:"varint,5,opt"` + Seq proto.Option[uint32] `protobuf:"varint,4,opt"` + RetryTimes proto.Option[uint32] `protobuf:"varint,5,opt"` AppId uint32 `protobuf:"varint,6,opt"` DataFlag uint32 `protobuf:"varint,7,opt"` CommandId uint32 `protobuf:"varint,8,opt"` @@ -142,17 +142,17 @@ type RespDataHighwayHead struct { } type SegHead struct { - ServiceId uint32 `protobuf:"varint,1,opt"` - Filesize uint64 `protobuf:"varint,2,opt"` - DataOffset uint64 `protobuf:"varint,3,opt"` - DataLength uint32 `protobuf:"varint,4,opt"` - RetCode uint32 `protobuf:"varint,5,opt"` - ServiceTicket []byte `protobuf:"bytes,6,opt"` + ServiceId proto.Option[uint32] `protobuf:"varint,1,opt"` + Filesize uint64 `protobuf:"varint,2,opt"` + DataOffset proto.Option[uint64] `protobuf:"varint,3,opt"` + DataLength uint32 `protobuf:"varint,4,opt"` + RetCode proto.Option[uint32] `protobuf:"varint,5,opt"` + ServiceTicket []byte `protobuf:"bytes,6,opt"` // uint32 Flag = 7; - Md5 []byte `protobuf:"bytes,8,opt"` - FileMd5 []byte `protobuf:"bytes,9,opt"` - CacheAddr uint32 `protobuf:"varint,10,opt"` - QueryTimes uint32 `protobuf:"varint,11,opt"` - UpdateCacheIp uint32 `protobuf:"varint,12,opt"` - CachePort uint32 `protobuf:"varint,13,opt"` + Md5 []byte `protobuf:"bytes,8,opt"` + FileMd5 []byte `protobuf:"bytes,9,opt"` + CacheAddr proto.Option[uint32] `protobuf:"varint,10,opt"` + QueryTimes uint32 `protobuf:"varint,11,opt"` + UpdateCacheIp uint32 `protobuf:"varint,12,opt"` + CachePort proto.Option[uint32] `protobuf:"varint,13,opt"` }