Skip to content

Commit

Permalink
fix: image highway
Browse files Browse the repository at this point in the history
  • Loading branch information
Linwenxuan04 committed Apr 22, 2024
1 parent 7add116 commit c47c6e4
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 25 deletions.
36 changes: 26 additions & 10 deletions client/highway.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package client
import (
"bytes"
binary2 "encoding/binary"
"encoding/hex"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
}

Expand Down
3 changes: 2 additions & 1 deletion client/imageUploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand Down
28 changes: 14 additions & 14 deletions packets/pb/service/highway/highway.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c47c6e4

Please sign in to comment.