From 11ed2b1e1766af30ab412efe57dd1d48d635a153 Mon Sep 17 00:00:00 2001 From: Redmomn <109732988+Redmomn@users.noreply.github.com> Date: Tue, 19 Nov 2024 19:34:04 +0800 Subject: [PATCH] [Core]: add websso packet --- .../Service/WebSso/Request/OidbSvc0x5d4_0.cs | 14 +++++++ .../Service/WebSso/Request/OidbSvc0xe17_0.cs | 20 +++++++++ .../Service/WebSso/Response/OidbSvc0x5d4_0.cs | 9 ++++ .../Service/WebSso/Response/OidbSvc0xe17_0.cs | 41 +++++++++++++++++++ .../Service/WebSso/STServiceMonitReq.cs | 27 ++++++++++++ .../Packets/Service/WebSso/WebSsoAttribute.cs | 15 +++++++ .../Packets/Service/WebSso/WebSsoRequest.cs | 19 +++++++++ .../Packets/Service/WebSso/WebSsoResponse.cs | 29 +++++++++++++ 8 files changed, 174 insertions(+) create mode 100644 Lagrange.Core/Internal/Packets/Service/WebSso/Request/OidbSvc0x5d4_0.cs create mode 100644 Lagrange.Core/Internal/Packets/Service/WebSso/Request/OidbSvc0xe17_0.cs create mode 100644 Lagrange.Core/Internal/Packets/Service/WebSso/Response/OidbSvc0x5d4_0.cs create mode 100644 Lagrange.Core/Internal/Packets/Service/WebSso/Response/OidbSvc0xe17_0.cs create mode 100644 Lagrange.Core/Internal/Packets/Service/WebSso/STServiceMonitReq.cs create mode 100644 Lagrange.Core/Internal/Packets/Service/WebSso/WebSsoAttribute.cs create mode 100644 Lagrange.Core/Internal/Packets/Service/WebSso/WebSsoRequest.cs create mode 100644 Lagrange.Core/Internal/Packets/Service/WebSso/WebSsoResponse.cs diff --git a/Lagrange.Core/Internal/Packets/Service/WebSso/Request/OidbSvc0x5d4_0.cs b/Lagrange.Core/Internal/Packets/Service/WebSso/Request/OidbSvc0x5d4_0.cs new file mode 100644 index 000000000..8ba1608f6 --- /dev/null +++ b/Lagrange.Core/Internal/Packets/Service/WebSso/Request/OidbSvc0x5d4_0.cs @@ -0,0 +1,14 @@ +using System.Text.Json.Serialization; + +#pragma warning disable CS8618 +// ReSharper disable InconsistentNaming + +namespace Lagrange.Core.Internal.Packets.Service.WebSso.Request; + +// ref https://github.com/Mrs4s/MiraiGo/blob/54bdd873e3fed9fe1c944918924674dacec5ac76/client/web.go#L23 +[Serializable] +[WebSso("ti.qq.com", "OidbSvc.0x5d4_0")] +internal class OidbSvc0x5d4_0 +{ + [JsonPropertyName("uin_list")] public uint[] UinList { get; set; } +} \ No newline at end of file diff --git a/Lagrange.Core/Internal/Packets/Service/WebSso/Request/OidbSvc0xe17_0.cs b/Lagrange.Core/Internal/Packets/Service/WebSso/Request/OidbSvc0xe17_0.cs new file mode 100644 index 000000000..8cff3039b --- /dev/null +++ b/Lagrange.Core/Internal/Packets/Service/WebSso/Request/OidbSvc0xe17_0.cs @@ -0,0 +1,20 @@ +using System.Text.Json.Serialization; + +#pragma warning disable CS8618 +// ReSharper disable InconsistentNaming + +namespace Lagrange.Core.Internal.Packets.Service.WebSso.Request; + +// ref https://github.com/Mrs4s/MiraiGo/blob/54bdd873e3fed9fe1c944918924674dacec5ac76/client/web.go#L23 +[Serializable] +[WebSso("ti.qq.com", "OidbSvc.0xe17_0")] +internal class OidbSvc0xe17_0 +{ + [JsonPropertyName("uint64_uin")] public uint Uin { get; set; } + + [JsonPropertyName("uint64_top")] public uint Top { get; set; } = 0; + + [JsonPropertyName("uint32_req_num")] public uint ReqNum { get; set; } = 99; + + [JsonPropertyName("bytes_cookies")] public string Cookies { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/Lagrange.Core/Internal/Packets/Service/WebSso/Response/OidbSvc0x5d4_0.cs b/Lagrange.Core/Internal/Packets/Service/WebSso/Response/OidbSvc0x5d4_0.cs new file mode 100644 index 000000000..f18696cfa --- /dev/null +++ b/Lagrange.Core/Internal/Packets/Service/WebSso/Response/OidbSvc0x5d4_0.cs @@ -0,0 +1,9 @@ +using System.Text.Json.Serialization; + +namespace Lagrange.Core.Internal.Packets.Service.WebSso.Response; + +[Serializable] +internal class OidbSvc0x5d4_0 +{ + [JsonPropertyName("ErrorCode")] public int ErrorCode { get; set; } +} \ No newline at end of file diff --git a/Lagrange.Core/Internal/Packets/Service/WebSso/Response/OidbSvc0xe17_0.cs b/Lagrange.Core/Internal/Packets/Service/WebSso/Response/OidbSvc0xe17_0.cs new file mode 100644 index 000000000..6f46ecb46 --- /dev/null +++ b/Lagrange.Core/Internal/Packets/Service/WebSso/Response/OidbSvc0xe17_0.cs @@ -0,0 +1,41 @@ +using System.Text; +using System.Text.Json.Serialization; + +#pragma warning disable CS8618 +// ReSharper disable InconsistentNaming + +namespace Lagrange.Core.Internal.Packets.Service.WebSso.Response; + +// ref https://github.com/Mrs4s/MiraiGo/blob/54bdd873e3fed9fe1c944918924674dacec5ac76/client/web.go +[Serializable] +internal class OidbSvc0xe17_0 +{ + [JsonPropertyName("rpt_block_list")] public BlockList BlockList { get; set; } + + [JsonPropertyName("ErrorCode")] public int ErrorCode { get; set; } +} + +[Serializable] +internal class BlockList +{ + [JsonPropertyName("uint64_uin")] public uint Uin { get; set; } + + [JsonPropertyName("str_uid")] public string Uid { get; set; } + + [JsonPropertyName("bytes_nick")] public string _nickname { get; set; } + + public string Nickname => + string.IsNullOrEmpty(_nickname) + ? string.Empty + : Encoding.UTF8.GetString(Convert.FromBase64String(_nickname)); + + [JsonPropertyName("uint32_age")] public uint Age { get; set; } + + [JsonPropertyName("uint32_sex")] public uint Sex { get; set; } + + [JsonPropertyName("bytes_source")] public string _source { get; set; } + + public string Source => string.IsNullOrEmpty(_source) + ? string.Empty + : Encoding.UTF8.GetString(Convert.FromBase64String(_source)); +} \ No newline at end of file diff --git a/Lagrange.Core/Internal/Packets/Service/WebSso/STServiceMonitReq.cs b/Lagrange.Core/Internal/Packets/Service/WebSso/STServiceMonitReq.cs new file mode 100644 index 000000000..69889a14b --- /dev/null +++ b/Lagrange.Core/Internal/Packets/Service/WebSso/STServiceMonitReq.cs @@ -0,0 +1,27 @@ +using ProtoBuf; + +namespace Lagrange.Core.Internal.Packets.Service.WebSso; + +// Resharper disable InconsistentNaming +#pragma warning disable CS8618 + +// ref https://github.com/Mrs4s/MiraiGo/blob/54bdd873e3fed9fe1c944918924674dacec5ac76/client/pb/web/WebSsoBody.proto +[ProtoContract] +internal class STServiceMonitItem +{ + [ProtoMember(1)] public string? Cmd { get; set; } + + [ProtoMember(2)] public string? URL { get; set; } + + [ProtoMember(3)] public int? ErrCode { get; set; } + + [ProtoMember(4)] public uint? Cost { get; set; } + + [ProtoMember(5)] public uint? Src { get; set; } +} + +[ProtoContract] +internal class STServiceMonitReq +{ + [ProtoMember(1)] public STServiceMonitItem[] list { get; set; } +} \ No newline at end of file diff --git a/Lagrange.Core/Internal/Packets/Service/WebSso/WebSsoAttribute.cs b/Lagrange.Core/Internal/Packets/Service/WebSso/WebSsoAttribute.cs new file mode 100644 index 000000000..38bdd8e15 --- /dev/null +++ b/Lagrange.Core/Internal/Packets/Service/WebSso/WebSsoAttribute.cs @@ -0,0 +1,15 @@ +namespace Lagrange.Core.Internal.Packets.Service.WebSso; + +[AttributeUsage(AttributeTargets.Class)] +internal class WebSsoAttribute : Attribute +{ + public string Host { get; set; } + + public string Cmd { get; set; } + + public WebSsoAttribute(string host, string cmd) + { + Host = host; + Cmd = cmd; + } +} \ No newline at end of file diff --git a/Lagrange.Core/Internal/Packets/Service/WebSso/WebSsoRequest.cs b/Lagrange.Core/Internal/Packets/Service/WebSso/WebSsoRequest.cs new file mode 100644 index 000000000..83ebfe3f9 --- /dev/null +++ b/Lagrange.Core/Internal/Packets/Service/WebSso/WebSsoRequest.cs @@ -0,0 +1,19 @@ +using ProtoBuf; + +namespace Lagrange.Core.Internal.Packets.Service.WebSso; + +// Resharper disable InconsistentNaming +#pragma warning disable CS8618 + +// ref https://github.com/Mrs4s/MiraiGo/blob/54bdd873e3fed9fe1c944918924674dacec5ac76/client/pb/web/WebSsoBody.proto +[ProtoContract] +internal class WebSsoRequest +{ + [ProtoMember(1)] public string? Version { get; set; } + + [ProtoMember(2)] public uint? Type { get; set; } + + [ProtoMember(3)] public string? Data { get; set; } + + [ProtoMember(4)] public string? WebData { get; set; } +} \ No newline at end of file diff --git a/Lagrange.Core/Internal/Packets/Service/WebSso/WebSsoResponse.cs b/Lagrange.Core/Internal/Packets/Service/WebSso/WebSsoResponse.cs new file mode 100644 index 000000000..82e31447e --- /dev/null +++ b/Lagrange.Core/Internal/Packets/Service/WebSso/WebSsoResponse.cs @@ -0,0 +1,29 @@ +using ProtoBuf; + +namespace Lagrange.Core.Internal.Packets.Service.WebSso; + +// Resharper disable InconsistentNaming +#pragma warning disable CS8618 + +// ref https://github.com/Mrs4s/MiraiGo/blob/54bdd873e3fed9fe1c944918924674dacec5ac76/client/pb/web/WebSsoBody.proto +[ProtoContract] +internal class WebSsoResponse +{ + [ProtoMember(1)] public uint? Version { get; set; } + + [ProtoMember(2)] public uint? Type { get; set; } + + [ProtoMember(3)] public uint? Ret { get; set; } + + [ProtoMember(4)] public string? Data { get; set; } + + [ProtoMember(5)] public WebSsoControlData? ControlData { get; set; } +} + +[ProtoContract] +internal class WebSsoControlData +{ + [ProtoMember(1)] public uint? Frequency { get; set; } + + [ProtoMember(2)] public uint? PackageSize { get; set; } +} \ No newline at end of file