Skip to content

Commit

Permalink
[Core]: add websso packet
Browse files Browse the repository at this point in the history
  • Loading branch information
Redmomn committed Nov 19, 2024
1 parent 8216078 commit 11ed2b1
Show file tree
Hide file tree
Showing 8 changed files with 174 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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; }
}
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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; }
}
Original file line number Diff line number Diff line change
@@ -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));
}
27 changes: 27 additions & 0 deletions Lagrange.Core/Internal/Packets/Service/WebSso/STServiceMonitReq.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
15 changes: 15 additions & 0 deletions Lagrange.Core/Internal/Packets/Service/WebSso/WebSsoAttribute.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
19 changes: 19 additions & 0 deletions Lagrange.Core/Internal/Packets/Service/WebSso/WebSsoRequest.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
29 changes: 29 additions & 0 deletions Lagrange.Core/Internal/Packets/Service/WebSso/WebSsoResponse.cs
Original file line number Diff line number Diff line change
@@ -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; }
}

0 comments on commit 11ed2b1

Please sign in to comment.