1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 19:17:38 +08:00
This commit is contained in:
Mrs4s 2021-01-15 02:29:41 +08:00
parent b83dd4cf38
commit c6cb5c7fe2
4 changed files with 1396 additions and 36 deletions

View File

@ -1,8 +1,13 @@
package client package client
import ( import (
"crypto/sha1"
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"github.com/Mrs4s/MiraiGo/utils"
"io"
"os"
"path"
"runtime/debug" "runtime/debug"
"github.com/Mrs4s/MiraiGo/client/pb/oidb" "github.com/Mrs4s/MiraiGo/client/pb/oidb"
@ -49,6 +54,7 @@ type (
func init() { func init() {
decoders["OidbSvc.0x6d8_1"] = decodeOIDB6d81Response decoders["OidbSvc.0x6d8_1"] = decodeOIDB6d81Response
decoders["OidbSvc.0x6d6_0"] = decodeOIDB6d60Response
decoders["OidbSvc.0x6d6_2"] = decodeOIDB6d62Response decoders["OidbSvc.0x6d6_2"] = decodeOIDB6d62Response
decoders["OidbSvc.0x6d6_3"] = decodeOIDB6d63Response decoders["OidbSvc.0x6d6_3"] = decodeOIDB6d63Response
} }
@ -146,6 +152,21 @@ func (fs *GroupFileSystem) GetFilesByFolder(folderId string) ([]*GroupFile, []*G
return files, folders, nil return files, folders, nil
} }
func (fs *GroupFileSystem) UploadFile(p, folderId string) error {
file, err := os.OpenFile(p, os.O_RDONLY, 0666)
if err != nil {
return err
}
defer file.Close()
md5Hash, size := utils.ComputeMd5AndLength(file)
_, _ = file.Seek(0, io.SeekStart)
sha1H := sha1.New()
_, _ = io.Copy(sha1H, file)
sha1Hash := sha1H.Sum(nil)
fs.client.sendAndWait(fs.client.buildGroupFileUploadReqPacket(folderId, path.Ext(p), fs.GroupCode, size, md5Hash, sha1Hash))
return nil
}
func (fs *GroupFileSystem) GetDownloadUrl(file *GroupFile) string { func (fs *GroupFileSystem) GetDownloadUrl(file *GroupFile) string {
return fs.client.GetGroupFileUrl(file.GroupCode, file.FileId, file.BusId) return fs.client.GetGroupFileUrl(file.GroupCode, file.FileId, file.BusId)
} }
@ -160,6 +181,31 @@ func (fs *GroupFileSystem) DeleteFile(parentFolderId, fileId string, busId int32
return i.(string) return i.(string)
} }
func (c *QQClient) buildGroupFileUploadReqPacket(parentFolderId, fileName string, groupCode, fileSize int64, md5, sha1 []byte) (uint16, []byte) {
seq := c.nextSeq()
b, _ := proto.Marshal(&oidb.D6D6ReqBody{UploadFileReq: &oidb.UploadFileReqBody{
GroupCode: groupCode,
AppId: 3,
BusId: 102,
Entrance: 5,
ParentFolderId: parentFolderId,
FileName: fileName,
LocalPath: "/storage/emulated/0/Pictures/files/s/" + fileName,
Int64FileSize: fileSize,
Sha: sha1,
Md5: md5,
}})
req := &oidb.OIDBSSOPkg{
Command: 1750,
ServiceType: 0,
Bodybuffer: b,
ClientVersion: "android 8.4.8",
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x6d6_0", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
return seq, packet
}
// OidbSvc.0x6d8_1 // OidbSvc.0x6d8_1
func (c *QQClient) buildGroupFileListRequestPacket(groupCode int64, folderId string, startIndex uint32) (uint16, []byte) { func (c *QQClient) buildGroupFileListRequestPacket(groupCode int64, folderId string, startIndex uint32) (uint16, []byte) {
seq := c.nextSeq() seq := c.nextSeq()
@ -312,3 +358,15 @@ func decodeOIDB6d63Response(_ *QQClient, _ uint16, payload []byte) (interface{},
} }
return rsp.DeleteFileRsp.ClientWording, nil return rsp.DeleteFileRsp.ClientWording, nil
} }
func decodeOIDB6d60Response(_ *QQClient, _ uint16, payload []byte) (interface{}, error) {
pkg := oidb.OIDBSSOPkg{}
rsp := oidb.D6D6RspBody{}
if err := proto.Unmarshal(payload, &pkg); err != nil {
return nil, errors.Wrap(err, "failed to unmarshal protobuf message")
}
if err := proto.Unmarshal(pkg.Bodybuffer, &rsp); err != nil {
return nil, errors.Wrap(err, "failed to unmarshal protobuf message")
}
return nil, nil
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,93 @@
syntax = "proto2";
option go_package = ".;oidb";
message CopyFromReqBody {
optional uint64 groupCode = 1;
optional uint32 appId = 2;
optional uint32 srcBusId = 3;
optional bytes srcParentFolder = 4;
optional bytes srcFilePath = 5;
optional uint32 dstBusId = 6;
optional bytes dstFolderId = 7;
optional uint64 fileSize = 8;
optional string localPath = 9;
optional string fileName = 10;
optional uint64 srcUin = 11;
optional bytes md5 = 12;
}
message CopyFromRspBody {
optional int32 retCode = 1;
optional string retMsg = 2;
optional string clientWording = 3;
optional bytes saveFilePath = 4;
optional uint32 busId = 5;
}
message CopyToReqBody {
optional uint64 groupCode = 1;
optional uint32 appId = 2;
optional uint32 srcBusId = 3;
optional string srcFileId = 4;
optional uint32 dstBusId = 5;
optional uint64 dstUin = 6;
optional string newFileName = 40;
optional bytes timCloudPdirKey = 100;
optional bytes timCloudPpdirKey = 101;
optional bytes timCloudExtensionInfo = 102;
optional uint32 timFileExistOption = 103;
}
message CopyToRspBody {
optional int32 retCode = 1;
optional string retMsg = 2;
optional string clientWording = 3;
optional string saveFilePath = 4;
optional uint32 busId = 5;
optional string fileName = 40;
}
message FeedsReqBody {
optional uint64 groupCode = 1;
optional uint32 appId = 2;
//repeated C8639group_file_common.FeedsInfo feedsInfoList = 3;
optional uint32 multiSendSeq = 4;
}
message FeedsRspBody {
optional int32 retCode = 1;
optional string retMsg = 2;
optional string clientWording = 3;
//repeated C8639group_file_common.FeedsResult feedsResultList = 4;
optional uint32 svrbusyWaitTime = 5;
}
message D6D9ReqBody {
optional TransFileReqBody transFileReq = 1;
optional CopyFromReqBody copyFromReq = 2;
optional CopyToReqBody copyToReq = 3;
optional FeedsReqBody feedsInfoReq = 5;
}
message D6D9RspBody {
optional TransFileRspBody transFileRsp = 1;
optional CopyFromRspBody copyFromRsp = 2;
optional CopyToRspBody copyToRsp = 3;
optional FeedsRspBody feedsInfoRsp = 5;
}
message TransFileReqBody {
optional uint64 groupCode = 1;
optional uint32 appId = 2;
optional uint32 busId = 3;
optional string fileId = 4;
}
message TransFileRspBody {
optional int32 retCode = 1;
optional string retMsg = 2;
optional string clientWording = 3;
optional uint32 saveBusId = 4;
optional string saveFilePath = 5;
}

View File

@ -2,7 +2,7 @@
// versions: // versions:
// protoc-gen-go v1.25.0 // protoc-gen-go v1.25.0
// protoc v3.11.4 // protoc v3.11.4
// source: oidb0xd79.proto // source: oidb0xD79.proto
package oidb package oidb
@ -42,7 +42,7 @@ type D79ReqBody struct {
func (x *D79ReqBody) Reset() { func (x *D79ReqBody) Reset() {
*x = D79ReqBody{} *x = D79ReqBody{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_oidb0xd79_proto_msgTypes[0] mi := &file_oidb0xD79_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -55,7 +55,7 @@ func (x *D79ReqBody) String() string {
func (*D79ReqBody) ProtoMessage() {} func (*D79ReqBody) ProtoMessage() {}
func (x *D79ReqBody) ProtoReflect() protoreflect.Message { func (x *D79ReqBody) ProtoReflect() protoreflect.Message {
mi := &file_oidb0xd79_proto_msgTypes[0] mi := &file_oidb0xD79_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -68,7 +68,7 @@ func (x *D79ReqBody) ProtoReflect() protoreflect.Message {
// Deprecated: Use D79ReqBody.ProtoReflect.Descriptor instead. // Deprecated: Use D79ReqBody.ProtoReflect.Descriptor instead.
func (*D79ReqBody) Descriptor() ([]byte, []int) { func (*D79ReqBody) Descriptor() ([]byte, []int) {
return file_oidb0xd79_proto_rawDescGZIP(), []int{0} return file_oidb0xD79_proto_rawDescGZIP(), []int{0}
} }
func (x *D79ReqBody) GetSeq() uint64 { func (x *D79ReqBody) GetSeq() uint64 {
@ -135,7 +135,7 @@ type D79RspBody struct {
func (x *D79RspBody) Reset() { func (x *D79RspBody) Reset() {
*x = D79RspBody{} *x = D79RspBody{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_oidb0xd79_proto_msgTypes[1] mi := &file_oidb0xD79_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -148,7 +148,7 @@ func (x *D79RspBody) String() string {
func (*D79RspBody) ProtoMessage() {} func (*D79RspBody) ProtoMessage() {}
func (x *D79RspBody) ProtoReflect() protoreflect.Message { func (x *D79RspBody) ProtoReflect() protoreflect.Message {
mi := &file_oidb0xd79_proto_msgTypes[1] mi := &file_oidb0xD79_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -161,7 +161,7 @@ func (x *D79RspBody) ProtoReflect() protoreflect.Message {
// Deprecated: Use D79RspBody.ProtoReflect.Descriptor instead. // Deprecated: Use D79RspBody.ProtoReflect.Descriptor instead.
func (*D79RspBody) Descriptor() ([]byte, []int) { func (*D79RspBody) Descriptor() ([]byte, []int) {
return file_oidb0xd79_proto_rawDescGZIP(), []int{1} return file_oidb0xD79_proto_rawDescGZIP(), []int{1}
} }
func (x *D79RspBody) GetRet() uint32 { func (x *D79RspBody) GetRet() uint32 {
@ -210,7 +210,7 @@ type D79Content struct {
func (x *D79Content) Reset() { func (x *D79Content) Reset() {
*x = D79Content{} *x = D79Content{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_oidb0xd79_proto_msgTypes[2] mi := &file_oidb0xD79_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -223,7 +223,7 @@ func (x *D79Content) String() string {
func (*D79Content) ProtoMessage() {} func (*D79Content) ProtoMessage() {}
func (x *D79Content) ProtoReflect() protoreflect.Message { func (x *D79Content) ProtoReflect() protoreflect.Message {
mi := &file_oidb0xd79_proto_msgTypes[2] mi := &file_oidb0xD79_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -236,7 +236,7 @@ func (x *D79Content) ProtoReflect() protoreflect.Message {
// Deprecated: Use D79Content.ProtoReflect.Descriptor instead. // Deprecated: Use D79Content.ProtoReflect.Descriptor instead.
func (*D79Content) Descriptor() ([]byte, []int) { func (*D79Content) Descriptor() ([]byte, []int) {
return file_oidb0xd79_proto_rawDescGZIP(), []int{2} return file_oidb0xD79_proto_rawDescGZIP(), []int{2}
} }
func (x *D79Content) GetSliceContent() [][]byte { func (x *D79Content) GetSliceContent() [][]byte {
@ -246,10 +246,10 @@ func (x *D79Content) GetSliceContent() [][]byte {
return nil return nil
} }
var File_oidb0xd79_proto protoreflect.FileDescriptor var File_oidb0xD79_proto protoreflect.FileDescriptor
var file_oidb0xd79_proto_rawDesc = []byte{ var file_oidb0xD79_proto_rawDesc = []byte{
0x0a, 0x0f, 0x6f, 0x69, 0x64, 0x62, 0x30, 0x78, 0x64, 0x37, 0x39, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x0a, 0x0f, 0x6f, 0x69, 0x64, 0x62, 0x30, 0x78, 0x44, 0x37, 0x39, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x22, 0xbb, 0x01, 0x0a, 0x0a, 0x44, 0x37, 0x39, 0x52, 0x65, 0x71, 0x42, 0x6f, 0x64, 0x79, 0x6f, 0x22, 0xbb, 0x01, 0x0a, 0x0a, 0x44, 0x37, 0x39, 0x52, 0x65, 0x71, 0x42, 0x6f, 0x64, 0x79,
0x12, 0x10, 0x0a, 0x03, 0x73, 0x65, 0x71, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x65, 0x71, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x73,
0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52,
@ -279,24 +279,24 @@ var file_oidb0xd79_proto_rawDesc = []byte{
} }
var ( var (
file_oidb0xd79_proto_rawDescOnce sync.Once file_oidb0xD79_proto_rawDescOnce sync.Once
file_oidb0xd79_proto_rawDescData = file_oidb0xd79_proto_rawDesc file_oidb0xD79_proto_rawDescData = file_oidb0xD79_proto_rawDesc
) )
func file_oidb0xd79_proto_rawDescGZIP() []byte { func file_oidb0xD79_proto_rawDescGZIP() []byte {
file_oidb0xd79_proto_rawDescOnce.Do(func() { file_oidb0xD79_proto_rawDescOnce.Do(func() {
file_oidb0xd79_proto_rawDescData = protoimpl.X.CompressGZIP(file_oidb0xd79_proto_rawDescData) file_oidb0xD79_proto_rawDescData = protoimpl.X.CompressGZIP(file_oidb0xD79_proto_rawDescData)
}) })
return file_oidb0xd79_proto_rawDescData return file_oidb0xD79_proto_rawDescData
} }
var file_oidb0xd79_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_oidb0xD79_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_oidb0xd79_proto_goTypes = []interface{}{ var file_oidb0xD79_proto_goTypes = []interface{}{
(*D79ReqBody)(nil), // 0: D79ReqBody (*D79ReqBody)(nil), // 0: D79ReqBody
(*D79RspBody)(nil), // 1: D79RspBody (*D79RspBody)(nil), // 1: D79RspBody
(*D79Content)(nil), // 2: D79Content (*D79Content)(nil), // 2: D79Content
} }
var file_oidb0xd79_proto_depIdxs = []int32{ var file_oidb0xD79_proto_depIdxs = []int32{
2, // 0: D79RspBody.content:type_name -> D79Content 2, // 0: D79RspBody.content:type_name -> D79Content
1, // [1:1] is the sub-list for method output_type 1, // [1:1] is the sub-list for method output_type
1, // [1:1] is the sub-list for method input_type 1, // [1:1] is the sub-list for method input_type
@ -305,13 +305,13 @@ var file_oidb0xd79_proto_depIdxs = []int32{
0, // [0:1] is the sub-list for field type_name 0, // [0:1] is the sub-list for field type_name
} }
func init() { file_oidb0xd79_proto_init() } func init() { file_oidb0xD79_proto_init() }
func file_oidb0xd79_proto_init() { func file_oidb0xD79_proto_init() {
if File_oidb0xd79_proto != nil { if File_oidb0xD79_proto != nil {
return return
} }
if !protoimpl.UnsafeEnabled { if !protoimpl.UnsafeEnabled {
file_oidb0xd79_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { file_oidb0xD79_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*D79ReqBody); i { switch v := v.(*D79ReqBody); i {
case 0: case 0:
return &v.state return &v.state
@ -323,7 +323,7 @@ func file_oidb0xd79_proto_init() {
return nil return nil
} }
} }
file_oidb0xd79_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { file_oidb0xD79_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*D79RspBody); i { switch v := v.(*D79RspBody); i {
case 0: case 0:
return &v.state return &v.state
@ -335,7 +335,7 @@ func file_oidb0xd79_proto_init() {
return nil return nil
} }
} }
file_oidb0xd79_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { file_oidb0xD79_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*D79Content); i { switch v := v.(*D79Content); i {
case 0: case 0:
return &v.state return &v.state
@ -352,18 +352,18 @@ func file_oidb0xd79_proto_init() {
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{ File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_oidb0xd79_proto_rawDesc, RawDescriptor: file_oidb0xD79_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 3, NumMessages: 3,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },
GoTypes: file_oidb0xd79_proto_goTypes, GoTypes: file_oidb0xD79_proto_goTypes,
DependencyIndexes: file_oidb0xd79_proto_depIdxs, DependencyIndexes: file_oidb0xD79_proto_depIdxs,
MessageInfos: file_oidb0xd79_proto_msgTypes, MessageInfos: file_oidb0xD79_proto_msgTypes,
}.Build() }.Build()
File_oidb0xd79_proto = out.File File_oidb0xD79_proto = out.File
file_oidb0xd79_proto_rawDesc = nil file_oidb0xD79_proto_rawDesc = nil
file_oidb0xd79_proto_goTypes = nil file_oidb0xD79_proto_goTypes = nil
file_oidb0xd79_proto_depIdxs = nil file_oidb0xD79_proto_depIdxs = nil
} }