mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 19:17:38 +08:00
commit
758c7b8efa
@ -5,6 +5,10 @@ import (
|
|||||||
|
|
||||||
"github.com/Mrs4s/MiraiGo/binary"
|
"github.com/Mrs4s/MiraiGo/binary"
|
||||||
"github.com/Mrs4s/MiraiGo/client/internal/auth"
|
"github.com/Mrs4s/MiraiGo/client/internal/auth"
|
||||||
|
"github.com/Mrs4s/MiraiGo/client/pb"
|
||||||
|
"github.com/Mrs4s/MiraiGo/internal/proto"
|
||||||
|
"github.com/Mrs4s/MiraiGo/wrapper"
|
||||||
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Transport is a network transport.
|
// Transport is a network transport.
|
||||||
@ -41,6 +45,15 @@ func (t *Transport) packBody(req *Request, w *binary.Writer) {
|
|||||||
|
|
||||||
w.WriteUInt16(uint16(len(t.Sig.Ksid)) + 2)
|
w.WriteUInt16(uint16(len(t.Sig.Ksid)) + 2)
|
||||||
w.Write(t.Sig.Ksid)
|
w.Write(t.Sig.Ksid)
|
||||||
|
|
||||||
|
secSign := t.PackSecSign(req)
|
||||||
|
w.WriteUInt32(uint32(len(secSign) + 4))
|
||||||
|
w.Write(secSign)
|
||||||
|
}
|
||||||
|
if wrapper.AllowSignSendMsg() && req.CommandName == "MessageSvc.PbSendMsg" {
|
||||||
|
secSign := t.PackSecSign(req)
|
||||||
|
w.WriteUInt32(uint32(len(secSign) + 4))
|
||||||
|
w.Write(secSign)
|
||||||
}
|
}
|
||||||
|
|
||||||
w.WriteUInt32(0x04 + uint32(len(t.Device.QImei16)))
|
w.WriteUInt32(0x04 + uint32(len(t.Device.QImei16)))
|
||||||
@ -52,6 +65,34 @@ func (t *Transport) packBody(req *Request, w *binary.Writer) {
|
|||||||
w.Write(req.Body)
|
w.Write(req.Body)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *Transport) PackSecSign(req *Request) []byte {
|
||||||
|
if wrapper.FekitGetSign == nil {
|
||||||
|
return []byte{}
|
||||||
|
}
|
||||||
|
sign, extra, token, err := wrapper.FekitGetSign(uint64(req.SequenceID), strconv.FormatInt(req.Uin, 10), req.CommandName, "V1_AND_SQ_8.9.50_3898_YYB_D", req.Body)
|
||||||
|
m := &pb.SSOReserveField{
|
||||||
|
Flag: 0,
|
||||||
|
Qimei: t.Device.QImei16,
|
||||||
|
NewconnFlag: 0,
|
||||||
|
Uid: strconv.FormatInt(req.Uin, 10),
|
||||||
|
Imsi: 0,
|
||||||
|
NetworkType: 1,
|
||||||
|
IpStackType: 1,
|
||||||
|
MessageType: 0,
|
||||||
|
SecInfo: &pb.SsoSecureInfo{
|
||||||
|
SecSig: sign,
|
||||||
|
SecDeviceToken: token,
|
||||||
|
SecExtra: extra,
|
||||||
|
},
|
||||||
|
SsoIpOrigin: 0,
|
||||||
|
}
|
||||||
|
data, err := proto.Marshal(m)
|
||||||
|
if err != nil {
|
||||||
|
panic(errors.Wrap(err, "failed to unmarshal protobuf SSOReserveField"))
|
||||||
|
}
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
// PackPacket packs a packet.
|
// PackPacket packs a packet.
|
||||||
func (t *Transport) PackPacket(req *Request) []byte {
|
func (t *Transport) PackPacket(req *Request) []byte {
|
||||||
// todo(wdvxdr): combine pack packet, send packet and return the response
|
// todo(wdvxdr): combine pack packet, send packet and return the response
|
||||||
|
@ -3,6 +3,25 @@
|
|||||||
|
|
||||||
package pb
|
package pb
|
||||||
|
|
||||||
|
type SSOReserveField struct {
|
||||||
|
Flag int32 `protobuf:"varint,9,opt"`
|
||||||
|
Qimei string `protobuf:"bytes,12,opt"`
|
||||||
|
NewconnFlag int32 `protobuf:"varint,14,opt"`
|
||||||
|
Uid string `protobuf:"bytes,16,opt"`
|
||||||
|
Imsi int32 `protobuf:"varint,18,opt"`
|
||||||
|
NetworkType int32 `protobuf:"varint,19,opt"`
|
||||||
|
IpStackType int32 `protobuf:"varint,20,opt"`
|
||||||
|
MessageType int32 `protobuf:"varint,21,opt"`
|
||||||
|
SecInfo *SsoSecureInfo `protobuf:"bytes,24,opt"`
|
||||||
|
SsoIpOrigin int32 `protobuf:"varint,28,opt"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SsoSecureInfo struct {
|
||||||
|
SecSig []byte `protobuf:"bytes,1,opt"`
|
||||||
|
SecDeviceToken []byte `protobuf:"bytes,2,opt"`
|
||||||
|
SecExtra []byte `protobuf:"bytes,3,opt"`
|
||||||
|
}
|
||||||
|
|
||||||
type DeviceInfo struct {
|
type DeviceInfo struct {
|
||||||
Bootloader string `protobuf:"bytes,1,opt"`
|
Bootloader string `protobuf:"bytes,1,opt"`
|
||||||
ProcVersion string `protobuf:"bytes,2,opt"`
|
ProcVersion string `protobuf:"bytes,2,opt"`
|
||||||
|
@ -2,6 +2,25 @@ syntax = "proto3";
|
|||||||
|
|
||||||
option go_package = "github.com/Mrs4s/MiraiGo/client/pb";
|
option go_package = "github.com/Mrs4s/MiraiGo/client/pb";
|
||||||
|
|
||||||
|
message SSOReserveField {
|
||||||
|
int32 flag = 9;
|
||||||
|
string qimei = 12;
|
||||||
|
int32 newconn_flag = 14;
|
||||||
|
string uid = 16;
|
||||||
|
int32 imsi = 18;
|
||||||
|
int32 network_type = 19;
|
||||||
|
int32 ip_stack_type = 20;
|
||||||
|
int32 message_type = 21;
|
||||||
|
SsoSecureInfo sec_info = 24;
|
||||||
|
int32 sso_ip_origin = 28;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SsoSecureInfo {
|
||||||
|
bytes sec_sig = 1;
|
||||||
|
bytes sec_device_token = 2;
|
||||||
|
bytes sec_extra = 3;
|
||||||
|
}
|
||||||
|
|
||||||
message DeviceInfo {
|
message DeviceInfo {
|
||||||
string bootloader = 1;
|
string bootloader = 1;
|
||||||
string procVersion = 2;
|
string procVersion = 2;
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
package wrapper
|
package wrapper
|
||||||
|
|
||||||
var DandelionEnergy func(uint64, string, string, []byte) ([]byte, error)
|
var DandelionEnergy func(uint64, string, string, []byte) ([]byte, error)
|
||||||
|
|
||||||
|
var FekitGetSign func(uint64, string, string, string, []byte) ([]byte, []byte, []byte, error)
|
||||||
|
|
||||||
|
var AllowSignSendMsg func() bool
|
||||||
|
Loading…
x
Reference in New Issue
Block a user