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

View File

@ -10,7 +10,6 @@ import (
"sync"
"time"
"github.com/Mrs4s/MiraiGo/internal/packets"
"github.com/pkg/errors"
"github.com/Mrs4s/MiraiGo/binary"
@ -22,6 +21,7 @@ import (
"github.com/Mrs4s/MiraiGo/client/pb/oidb"
"github.com/Mrs4s/MiraiGo/client/pb/profilecard"
"github.com/Mrs4s/MiraiGo/client/pb/structmsg"
"github.com/Mrs4s/MiraiGo/internal/packets"
"github.com/Mrs4s/MiraiGo/internal/proto"
"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)
}
c.Uin = body.ReadInt64()
c.highwaySession.Uin = strconv.FormatInt(c.Uin, 10)
body.ReadInt32() // sig create time
body.ReadUInt16()
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")
}
defer conn.Close()
offset := 0
reader := binary.NewNetworkReader(conn)
if err = s.sendEcho(conn); err != nil {
return nil, err
}
var rspExt []byte
const chunkSize = 256 * 1024
var rspExt []byte
offset := 0
chunk := make([]byte, chunkSize)
w := binary.SelectWriter()
defer binary.PutWriter(w)
@ -77,10 +78,10 @@ func (s *Session) UploadBDH(input BdhInput) ([]byte, error) {
head, _ := proto.Marshal(&pb.ReqDataHighwayHead{
MsgBasehead: &pb.DataHighwayHead{
Version: 1,
Uin: s.uin,
Uin: s.Uin,
Command: "PicUp.DataUp",
Seq: s.nextSeq(),
Appid: s.appID,
Appid: s.AppID,
Dataflag: 4096,
CommandId: input.CommandID,
LocaleId: 2052,
@ -227,10 +228,10 @@ func (s *Session) UploadBDHMultiThread(input BdhInput, threadCount int) ([]byte,
head, _ := proto.Marshal(&pb.ReqDataHighwayHead{
MsgBasehead: &pb.DataHighwayHead{
Version: 1,
Uin: s.uin,
Uin: s.Uin,
Command: "PicUp.DataUp",
Seq: s.nextSeq(),
Appid: s.appID,
Appid: s.AppID,
Dataflag: 4096,
CommandId: input.CommandID,
LocaleId: 2052,

View File

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