-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
19bd32d
commit 92da94f
Showing
12 changed files
with
288 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Lagrange.Core.Message.Entity; | ||
|
||
namespace Lagrange.Core.Internal.Event.Message; | ||
|
||
#pragma warning disable CS8618 | ||
|
||
internal class FileUploadEvent : ProtocolEvent | ||
{ | ||
public string TargetUid { get; } | ||
|
||
public FileEntity Entity { get; } | ||
|
||
public string FileId { get; } | ||
|
||
public byte[] UploadKey { get; } | ||
|
||
public string Ip { get; } | ||
|
||
public uint Port { get; } | ||
|
||
public string Addon { get; } | ||
|
||
private FileUploadEvent(string targetUid, FileEntity entity) : base(true) | ||
{ | ||
TargetUid = targetUid; | ||
Entity = entity; | ||
} | ||
|
||
private FileUploadEvent(int resultCode, string fileId, byte[] uploadKey, string ip, uint port, string addon) : base(resultCode) | ||
{ | ||
FileId = fileId; | ||
UploadKey = uploadKey; | ||
Ip = ip; | ||
Port = port; | ||
Addon = addon; | ||
} | ||
|
||
public static FileUploadEvent Create(string targetUid, FileEntity entity) => new(targetUid, entity); | ||
|
||
public static FileUploadEvent Result(int resultCode, string fileId, byte[] uploadKey, string ip, uint port, string addon) | ||
=> new(resultCode, fileId, uploadKey, ip, port, addon); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
Lagrange.Core/Internal/Packets/Service/Oidb/Response/OidbSvcTrpcTcp0xE37Response.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using ProtoBuf; | ||
|
||
namespace Lagrange.Core.Internal.Packets.Service.Oidb.Response; | ||
|
||
// Resharper disable InconsistentNaming | ||
#pragma warning disable CS8618 | ||
|
||
[ProtoContract] | ||
internal class OidbSvcTrpcTcp0xE37Response | ||
{ | ||
[ProtoMember(1)] public uint Command { get; set; } // 1700 | ||
|
||
[ProtoMember(2)] public int Seq { get; set; } // 0 | ||
|
||
[ProtoMember(19)] public ApplyUploadRespV3 Upload { get; set; } | ||
|
||
[ProtoMember(101)] public int BusinessId { get; set; } // 3 | ||
|
||
[ProtoMember(102)] public int ClientType { get; set; } // 1 | ||
|
||
[ProtoMember(200)] public int FlagSupportMediaPlatform { get; set; } // 1 | ||
} | ||
|
||
[ProtoContract] | ||
internal class ApplyUploadRespV3 | ||
{ | ||
[ProtoMember(10)] public int RetCode { get; set; } | ||
|
||
[ProtoMember(20)] public string RetMsg { get; set; } | ||
|
||
[ProtoMember(30)] public long TotalSpace { get; set; } | ||
|
||
[ProtoMember(40)] public long UsedSpace { get; set; } | ||
|
||
[ProtoMember(50)] public long UploadedSize { get; set; } | ||
|
||
[ProtoMember(60)] public string UploadIp { get; set; } | ||
|
||
[ProtoMember(70)] public string UploadDomain { get; set; } | ||
|
||
[ProtoMember(80)] public uint UploadPort { get; set; } | ||
|
||
[ProtoMember(90)] public string Uuid { get; set; } | ||
|
||
[ProtoMember(100)] public byte[] UploadKey { get; set; } | ||
|
||
[ProtoMember(110)] public bool BoolFileExist { get; set; } | ||
|
||
[ProtoMember(120)] public int PackSize { get; set; } | ||
|
||
[ProtoMember(130)] public List<string> UploadIpList { get; set; } | ||
|
||
[ProtoMember(140)] public int UploadHttpsPort { get; set; } | ||
|
||
[ProtoMember(150)] public string UploadHttpsDomain { get; set; } | ||
|
||
[ProtoMember(160)] public string UploadDns { get; set; } | ||
|
||
[ProtoMember(170)] public string UploadLanip { get; set; } | ||
|
||
[ProtoMember(200)] public string FileAddon { get; set; } | ||
|
||
[ProtoMember(220)] public byte[] MediaPlatformUploadKey { get; set; } | ||
} |
58 changes: 58 additions & 0 deletions
58
Lagrange.Core/Internal/Service/Message/FileUploadService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using Lagrange.Core.Common; | ||
using Lagrange.Core.Internal.Event; | ||
using Lagrange.Core.Internal.Event.Message; | ||
using Lagrange.Core.Internal.Packets.Service.Oidb; | ||
using Lagrange.Core.Internal.Packets.Service.Oidb.Request; | ||
using Lagrange.Core.Internal.Packets.Service.Oidb.Response; | ||
using Lagrange.Core.Utility.Binary; | ||
using Lagrange.Core.Utility.Extension; | ||
using ProtoBuf; | ||
|
||
namespace Lagrange.Core.Internal.Service.Message; | ||
|
||
[EventSubscribe(typeof(FileUploadEvent))] | ||
[Service("OidbSvcTrpcTcp.0xe37_1700")] | ||
internal class FileUploadService : BaseService<FileUploadEvent> | ||
{ | ||
protected override bool Build(FileUploadEvent input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device, | ||
out BinaryPacket output, out List<BinaryPacket>? extraPackets) | ||
{ | ||
if (input.Entity.FileStream is null) throw new Exception(); | ||
|
||
var packet = new OidbSvcTrpcTcpBase<OidbSvcTrpcTcp0xE37_1700>(new OidbSvcTrpcTcp0xE37_1700 | ||
{ | ||
Command = 1700, | ||
Seq = 0, | ||
Upload = new ApplyUploadReqV3 | ||
{ | ||
SenderUid = keystore.Uid ?? "", | ||
ReceiverUid = input.TargetUid, | ||
FileSize = (uint)input.Entity.FileStream.Length, | ||
FileName = input.Entity.FileName, | ||
Md510MCheckSum = input.Entity.FileStream.Md5(0, 10 * 1024 * 1024).UnHex(), | ||
Sha1CheckSum = input.Entity.FileSha1, | ||
LocalPath = "/", | ||
Md5CheckSum = input.Entity.FileMd5, | ||
Sha3CheckSum = Array.Empty<byte>() | ||
}, | ||
BusinessId = 3, | ||
ClientType = 1, | ||
FlagSupportMediaPlatform = 1 | ||
}); | ||
|
||
output = packet.Serialize(); | ||
extraPackets = null; | ||
return true; | ||
} | ||
|
||
protected override bool Parse(byte[] input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device, | ||
out FileUploadEvent output, out List<ProtocolEvent>? extraEvents) | ||
{ | ||
var payload = Serializer.Deserialize<OidbSvcTrpcTcpResponse<OidbSvcTrpcTcp0xE37Response>>(input.AsSpan()); | ||
var upload = payload.Body.Upload; | ||
|
||
output = FileUploadEvent.Result((int)payload.ErrorCode, upload.Uuid, upload.MediaPlatformUploadKey, upload.UploadIp, upload.UploadPort, upload.FileAddon); | ||
extraEvents = null; | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.