1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 19:17:38 +08:00

fix: highway upload

caused by uin didn't set
This commit is contained in:
wdvxdr 2021-12-17 22:19:00 +08:00
parent 6179d2d351
commit f464a0d474
No known key found for this signature in database
GPG Key ID: 703F8C071DE7A1B6
4 changed files with 24 additions and 26 deletions

View File

@ -6,6 +6,7 @@ import (
"math/rand" "math/rand"
"net" "net"
"sort" "sort"
"strconv"
"sync" "sync"
"time" "time"
@ -208,6 +209,7 @@ func NewClientMd5(uin int64, passwordMd5 [16]byte) *QQClient {
servers: []*net.TCPAddr{}, servers: []*net.TCPAddr{},
alive: true, alive: true,
ecdh: crypto.NewEcdh(), ecdh: crypto.NewEcdh(),
highwaySession: new(highway.Session),
} }
{ // init atomic values { // init atomic values
cli.SequenceId.Store(0x3635) cli.SequenceId.Store(0x3635)
@ -216,6 +218,7 @@ func NewClientMd5(uin int64, passwordMd5 [16]byte) *QQClient {
cli.friendSeq.Store(22911) cli.friendSeq.Store(22911)
cli.highwayApplyUpSeq.Store(77918) cli.highwayApplyUpSeq.Store(77918)
} }
cli.highwaySession.Uin = strconv.FormatInt(cli.Uin, 10)
cli.GuildService = &GuildService{c: cli} cli.GuildService = &GuildService{c: cli}
cli.ecdh.FetchPubKey(uin) cli.ecdh.FetchPubKey(uin)
cli.UseDevice(SystemDeviceInfo) cli.UseDevice(SystemDeviceInfo)
@ -273,7 +276,7 @@ func NewClientMd5(uin int64, passwordMd5 [16]byte) *QQClient {
func (c *QQClient) UseDevice(info *DeviceInfo) { func (c *QQClient) UseDevice(info *DeviceInfo) {
c.version = genVersionInfo(info.Protocol) c.version = genVersionInfo(info.Protocol)
c.highwaySession = highway.NewSession(int32(c.version.AppId), c.Uin) c.highwaySession.AppID = int32(c.version.AppId)
c.ksid = []byte(fmt.Sprintf("|%s|A8.2.7.27f6ea96", info.IMEI)) c.ksid = []byte(fmt.Sprintf("|%s|A8.2.7.27f6ea96", info.IMEI))
c.deviceInfo = info c.deviceInfo = info
} }
@ -425,6 +428,7 @@ func (c *QQClient) init(tokenLogin bool) error {
if len(c.g) == 0 { if len(c.g) == 0 {
c.Warning("device lock is disable. http api may fail.") c.Warning("device lock is disable. http api may fail.")
} }
c.highwaySession.Uin = strconv.FormatInt(c.Uin, 10)
if err := c.registerClient(); err != nil { if err := c.registerClient(); err != nil {
return errors.Wrap(err, "register error") return errors.Wrap(err, "register error")
} }

View File

@ -10,7 +10,6 @@ import (
"sync" "sync"
"time" "time"
"github.com/Mrs4s/MiraiGo/internal/packets"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/Mrs4s/MiraiGo/binary" "github.com/Mrs4s/MiraiGo/binary"
@ -22,6 +21,7 @@ import (
"github.com/Mrs4s/MiraiGo/client/pb/oidb" "github.com/Mrs4s/MiraiGo/client/pb/oidb"
"github.com/Mrs4s/MiraiGo/client/pb/profilecard" "github.com/Mrs4s/MiraiGo/client/pb/profilecard"
"github.com/Mrs4s/MiraiGo/client/pb/structmsg" "github.com/Mrs4s/MiraiGo/client/pb/structmsg"
"github.com/Mrs4s/MiraiGo/internal/packets"
"github.com/Mrs4s/MiraiGo/internal/proto" "github.com/Mrs4s/MiraiGo/internal/proto"
"github.com/Mrs4s/MiraiGo/utils" "github.com/Mrs4s/MiraiGo/utils"
) )
@ -282,6 +282,7 @@ func decodeTransEmpResponse(c *QQClient, _ *incomingPacketInfo, payload []byte)
return nil, errors.Errorf("wtlogin.trans_emp sub cmd 0x12 error: %v", code) return nil, errors.Errorf("wtlogin.trans_emp sub cmd 0x12 error: %v", code)
} }
c.Uin = body.ReadInt64() c.Uin = body.ReadInt64()
c.highwaySession.Uin = strconv.FormatInt(c.Uin, 10)
body.ReadInt32() // sig create time body.ReadInt32() // sig create time
body.ReadUInt16() body.ReadUInt16()
m := body.ReadTlvMap(2) m := body.ReadTlvMap(2)

View File

@ -53,14 +53,15 @@ func (s *Session) UploadBDH(input BdhInput) ([]byte, error) {
return nil, errors.Wrap(err, "connect error") return nil, errors.Wrap(err, "connect error")
} }
defer conn.Close() defer conn.Close()
offset := 0
reader := binary.NewNetworkReader(conn) reader := binary.NewNetworkReader(conn)
if err = s.sendEcho(conn); err != nil { if err = s.sendEcho(conn); err != nil {
return nil, err return nil, err
} }
var rspExt []byte
const chunkSize = 256 * 1024 const chunkSize = 256 * 1024
var rspExt []byte
offset := 0
chunk := make([]byte, chunkSize) chunk := make([]byte, chunkSize)
w := binary.SelectWriter() w := binary.SelectWriter()
defer binary.PutWriter(w) defer binary.PutWriter(w)
@ -77,10 +78,10 @@ func (s *Session) UploadBDH(input BdhInput) ([]byte, error) {
head, _ := proto.Marshal(&pb.ReqDataHighwayHead{ head, _ := proto.Marshal(&pb.ReqDataHighwayHead{
MsgBasehead: &pb.DataHighwayHead{ MsgBasehead: &pb.DataHighwayHead{
Version: 1, Version: 1,
Uin: s.uin, Uin: s.Uin,
Command: "PicUp.DataUp", Command: "PicUp.DataUp",
Seq: s.nextSeq(), Seq: s.nextSeq(),
Appid: s.appID, Appid: s.AppID,
Dataflag: 4096, Dataflag: 4096,
CommandId: input.CommandID, CommandId: input.CommandID,
LocaleId: 2052, LocaleId: 2052,
@ -227,10 +228,10 @@ func (s *Session) UploadBDHMultiThread(input BdhInput, threadCount int) ([]byte,
head, _ := proto.Marshal(&pb.ReqDataHighwayHead{ head, _ := proto.Marshal(&pb.ReqDataHighwayHead{
MsgBasehead: &pb.DataHighwayHead{ MsgBasehead: &pb.DataHighwayHead{
Version: 1, Version: 1,
Uin: s.uin, Uin: s.Uin,
Command: "PicUp.DataUp", Command: "PicUp.DataUp",
Seq: s.nextSeq(), Seq: s.nextSeq(),
Appid: s.appID, Appid: s.AppID,
Dataflag: 4096, Dataflag: 4096,
CommandId: input.CommandID, CommandId: input.CommandID,
LocaleId: 2052, LocaleId: 2052,

View File

@ -7,7 +7,6 @@ import (
"io" "io"
"net" "net"
"net/http" "net/http"
"strconv"
"sync/atomic" "sync/atomic"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -19,20 +18,13 @@ import (
) )
type Session struct { type Session struct {
Uin string
AppID int32
SigSession []byte SigSession []byte
SessionKey []byte SessionKey []byte
SsoAddr []Addr SsoAddr []Addr
seq int32 seq int32
appID int32
uin string
}
func NewSession(appID int32, uin int64) *Session {
return &Session{
appID: appID,
uin: strconv.FormatInt(uin, 10),
}
} }
func (s *Session) AddrLength() int { func (s *Session) AddrLength() int {
@ -81,10 +73,10 @@ func (s *Session) Upload(addr Addr, input Input) error {
head, _ := proto.Marshal(&pb.ReqDataHighwayHead{ head, _ := proto.Marshal(&pb.ReqDataHighwayHead{
MsgBasehead: &pb.DataHighwayHead{ MsgBasehead: &pb.DataHighwayHead{
Version: 1, Version: 1,
Uin: s.uin, Uin: s.Uin,
Command: "PicUp.DataUp", Command: "PicUp.DataUp",
Seq: s.nextSeq(), Seq: s.nextSeq(),
Appid: s.appID, Appid: s.AppID,
Dataflag: 4096, Dataflag: 4096,
CommandId: input.CommandID, CommandId: input.CommandID,
LocaleId: 2052, LocaleId: 2052,
@ -128,7 +120,7 @@ func (s *Session) UploadExciting(input ExcitingInput) ([]byte, error) {
fileMd5, fileLength := utils.ComputeMd5AndLength(input.Body) fileMd5, fileLength := utils.ComputeMd5AndLength(input.Body)
_, _ = input.Body.Seek(0, io.SeekStart) _, _ = input.Body.Seek(0, io.SeekStart)
addr := s.SsoAddr[0] addr := s.SsoAddr[0]
url := fmt.Sprintf("http://%v/cgi-bin/httpconn?htcmd=0x6FF0087&uin=%v", addr, s.uin) url := fmt.Sprintf("http://%v/cgi-bin/httpconn?htcmd=0x6FF0087&Uin=%v", addr, s.Uin)
var ( var (
rspExt []byte rspExt []byte
offset int64 = 0 offset int64 = 0
@ -151,10 +143,10 @@ func (s *Session) UploadExciting(input ExcitingInput) ([]byte, error) {
head, _ := proto.Marshal(&pb.ReqDataHighwayHead{ head, _ := proto.Marshal(&pb.ReqDataHighwayHead{
MsgBasehead: &pb.DataHighwayHead{ MsgBasehead: &pb.DataHighwayHead{
Version: 1, Version: 1,
Uin: s.uin, Uin: s.Uin,
Command: "PicUp.DataUp", Command: "PicUp.DataUp",
Seq: s.nextSeq(), Seq: s.nextSeq(),
Appid: s.appID, Appid: s.AppID,
Dataflag: 0, Dataflag: 0,
CommandId: input.CommandID, CommandId: input.CommandID,
LocaleId: 0, LocaleId: 0,
@ -211,10 +203,10 @@ func (s *Session) sendHeartbreak(conn net.Conn) error {
head, _ := proto.Marshal(&pb.ReqDataHighwayHead{ head, _ := proto.Marshal(&pb.ReqDataHighwayHead{
MsgBasehead: &pb.DataHighwayHead{ MsgBasehead: &pb.DataHighwayHead{
Version: 1, Version: 1,
Uin: s.uin, Uin: s.Uin,
Command: "PicUp.Echo", Command: "PicUp.Echo",
Seq: s.nextSeq(), Seq: s.nextSeq(),
Appid: s.appID, Appid: s.AppID,
Dataflag: 4096, Dataflag: 4096,
CommandId: 0, CommandId: 0,
LocaleId: 2052, LocaleId: 2052,