Skip to content

Commit 8c868e7

Browse files
committed
[Core] Modify AppInfo
[Milky] Modify signer implementation
1 parent ead21f7 commit 8c868e7

13 files changed

Lines changed: 176 additions & 578 deletions

File tree

.editorconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ dotnet_remove_unnecessary_suppression_exclusions = none
8282
# LWX like var
8383
# but doesn't like the built-in type
8484
# var preferences
85-
csharp_style_var_elsewhere = true:silent
86-
csharp_style_var_for_built_in_types = false:silent
87-
csharp_style_var_when_type_is_apparent = true:silent
85+
csharp_style_var_elsewhere = true:warning
86+
csharp_style_var_for_built_in_types = false:warning
87+
csharp_style_var_when_type_is_apparent = true:warning
8888

8989
# Expression-bodied members
9090
csharp_style_expression_bodied_accessors = true:silent

Lagrange.Core/Common/BotAppInfo.cs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@ namespace Lagrange.Core.Common;
55
public class BotAppInfo
66
{
77
public string Os { get; init; }
8-
8+
99
public string VendorOs { get; init; }
1010

1111
public string Kernel { get; init; } = "";
1212

1313
public string Qua { get; init; }
14-
14+
1515
public string CurrentVersion { get; init; }
16-
16+
1717
public string PtVersion { get; init; }
18-
18+
1919
public int SsoVersion { get; init; }
20-
20+
2121
public string PackageName { get; init; }
22-
22+
2323
public byte[] ApkSignatureMd5 { get; init; }
24-
24+
2525
public WtLoginSdkInfo SdkInfo { get; init; }
26-
26+
2727
public int AppId { get; init; }
28-
28+
2929
public int SubAppId { get; init; }
3030

3131
public ushort AppClientVersion { get; init; }
@@ -35,7 +35,8 @@ public class BotAppInfo
3535
Os = "Linux",
3636
Kernel = "Linux",
3737
VendorOs = "linux",
38-
CurrentVersion = "3.2.15-30366",
38+
Qua = "V1_LNX_NQ_3.2.26_46494_GW_B",
39+
CurrentVersion = "3.2.26-46494",
3940
PtVersion = "2.0.0",
4041
SsoVersion = 19,
4142
PackageName = "com.tencent.qq",
@@ -44,15 +45,15 @@ public class BotAppInfo
4445
{
4546
SdkBuildTime = 0,
4647
SdkVersion = "nt.wtlogin.0.0.1",
47-
MiscBitMap = 12058620,
48+
MiscBitMap = 32764,
4849
SubSigMap = 0,
49-
MainSigMap = Sig.WLOGIN_STWEB | Sig.WLOGIN_A2 | Sig.WLOGIN_ST | Sig.WLOGIN_SKEY | Sig.WLOGIN_VKEY | Sig.WLOGIN_D2 | Sig.WLOGIN_SID | Sig.WLOGIN_PSKEY | Sig.WLOGIN_DA2 | Sig.WLOGIN_PT4Token
50+
MainSigMap = (Sig)169742560
5051
},
5152
AppId = 1600001615,
52-
SubAppId = 537258424,
53-
AppClientVersion = 30366
53+
SubAppId = 537345891,
54+
AppClientVersion = 46494
5455
};
55-
56+
5657
private static readonly BotAppInfo MacOs = new()
5758
{
5859
Os = "Mac",
@@ -75,7 +76,7 @@ public class BotAppInfo
7576
SubAppId = 537200848,
7677
AppClientVersion = 13172
7778
};
78-
79+
7980
private static readonly BotAppInfo Windows = new()
8081
{
8182
Os = "Windows",
@@ -119,7 +120,7 @@ public class BotAppInfo
119120
},
120121
AppClientVersion = 0
121122
};
122-
123+
123124
private static readonly BotAppInfo AndroidPad = new()
124125
{
125126
Os = "ANDROID",
@@ -162,7 +163,7 @@ public class BotAppInfo
162163
},
163164
AppClientVersion = 0
164165
};
165-
166+
166167
public static readonly Dictionary<Protocols, BotAppInfo> ProtocolToAppInfo = new()
167168
{
168169
{ Protocols.Windows, Windows },
@@ -177,13 +178,13 @@ public class BotAppInfo
177178
public class WtLoginSdkInfo
178179
{
179180
public uint SdkBuildTime { get; init; }
180-
181+
181182
public string SdkVersion { get; init; }
182-
183+
183184
public uint MiscBitMap { get; init; }
184-
185+
185186
public uint SubSigMap { get; init; }
186-
187+
187188
public Sig MainSigMap { get; init; }
188189
}
189190

Lagrange.Milky/Api/Handler/Debug/SendPacketHandler.cs

Lines changed: 0 additions & 49 deletions
This file was deleted.

Lagrange.Milky/Api/Handler/System/GetCookiesHandler.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using Lagrange.Core;
33
using Lagrange.Core.Common.Interface;
44
using Lagrange.Milky.Api.Exception;
5-
using Lagrange.Milky.Utility;
65

76
namespace Lagrange.Milky.Api.Handler.System;
87

Lagrange.Milky/Configuration/SignerConfiguration.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ namespace Lagrange.Milky.Configuration;
22

33
public class SignerConfiguration
44
{
5-
public string? Base { get; set; }
6-
7-
public string? Version { get; set; }
5+
public string? Url { get; set; }
86

97
public string? Token { get; set; }
108

Lagrange.Milky/Entity/Event/FriendRequestEvent.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Text.Json.Serialization;
2-
using Lagrange.Milky.Extension;
32

43
namespace Lagrange.Milky.Entity.Event;
54

Lagrange.Milky/Extension/HostApplicationBuilderExtension.cs

Lines changed: 74 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using Lagrange.Core;
21
using Lagrange.Core.Common;
32
using Lagrange.Core.Common.Interface;
43
using Lagrange.Milky.Api;
@@ -32,95 +31,87 @@ public static HostApplicationBuilder ConfigureServices(this HostApplicationBuild
3231
}
3332

3433
public static HostApplicationBuilder ConfigureCore(this HostApplicationBuilder builder) => builder
34+
#pragma warning disable IL2026, IL3050
35+
// https://github.com/dotnet/runtime/issues/94544
3536
.ConfigureServices(services => services
36-
.Configure<CoreConfiguration>(builder.Configuration.GetSection("Core"))
37-
38-
// Signer
39-
.AddSingleton<Signer>()
40-
// BotConfig
41-
.AddSingleton(services =>
42-
{
43-
var loggerConfiguration = services.GetRequiredService<IOptions<LoggerFilterOptions>>().Value;
44-
var coreConfiguration = services.GetRequiredService<IOptions<CoreConfiguration>>().Value;
45-
var signer = services.GetRequiredService<Signer>();
46-
47-
var platform = signer.GetAppInfo().Result switch
37+
.Configure<CoreConfiguration>(builder.Configuration.GetSection("Core"))
38+
#pragma warning restore IL2026, IL3050
39+
// Signer
40+
.AddSingleton<Signer>()
41+
// BotConfig
42+
.AddSingleton(services =>
4843
{
49-
{ Os: "Linux" } => Protocols.Linux,
50-
{ Os: "Mac" } => Protocols.MacOs,
51-
{ Os: "Windows" } => Protocols.Windows,
52-
{ Os: "Android", PackageName: "com.tencent.mobileqq" } => Protocols.AndroidPhone,
53-
{ Os: "Android", PackageName: "com.tencent.qqlite" } => Protocols.AndroidWatch,
54-
_ => throw new NotSupportedException(),
55-
};
56-
57-
return new BotConfig
58-
{
59-
Protocol = platform,
60-
LogLevel = (CoreLogLevel)loggerConfiguration.GetDefaultLogLevel(),
61-
AutoReconnect = coreConfiguration.Server.AutoReconnect,
62-
UseIPv6Network = coreConfiguration.Server.UseIPv6Network,
63-
GetOptimumServer = coreConfiguration.Server.GetOptimumServer,
64-
AutoReLogin = coreConfiguration.Login.AutoReLogin,
65-
SignProvider = signer,
66-
};
67-
})
68-
// BotKeystore
69-
.AddSingleton(services =>
70-
{
71-
var configuration = services.GetRequiredService<IOptions<CoreConfiguration>>().Value;
72-
73-
if (!configuration.Login.Uin.HasValue) throw new Exception("Core.Login.Uin cannot be null");
74-
var path = $"{configuration.Login.Uin.Value}.keystore";
75-
76-
BotKeystore keystore;
77-
if (File.Exists(path))
44+
var loggerConfiguration = services.GetRequiredService<IOptions<LoggerFilterOptions>>().Value;
45+
var coreConfiguration = services.GetRequiredService<IOptions<CoreConfiguration>>().Value;
46+
var signer = services.GetRequiredService<Signer>();
47+
48+
return new BotConfig
49+
{
50+
Protocol = Protocols.Linux,
51+
LogLevel = (CoreLogLevel)loggerConfiguration.GetDefaultLogLevel(),
52+
AutoReconnect = coreConfiguration.Server.AutoReconnect,
53+
UseIPv6Network = coreConfiguration.Server.UseIPv6Network,
54+
GetOptimumServer = coreConfiguration.Server.GetOptimumServer,
55+
AutoReLogin = coreConfiguration.Login.AutoReLogin,
56+
SignProvider = signer,
57+
};
58+
})
59+
// BotKeystore
60+
.AddSingleton(services =>
7861
{
79-
var keystoreNullable = JsonUtility.Deserialize<BotKeystore>(File.ReadAllBytes(path));
80-
keystore = keystoreNullable ?? throw new Exception(
81-
$"Invalid keystore detected. Please remove the '{path}' file and re-authenticate."
82-
);
83-
}
84-
else
62+
var configuration = services.GetRequiredService<IOptions<CoreConfiguration>>().Value;
63+
64+
if (!configuration.Login.Uin.HasValue) throw new Exception("Core.Login.Uin cannot be null");
65+
string path = $"{configuration.Login.Uin.Value}.keystore";
66+
67+
BotKeystore keystore;
68+
if (File.Exists(path))
69+
{
70+
var keystoreNullable = JsonUtility.Deserialize<BotKeystore>(File.ReadAllBytes(path));
71+
keystore = keystoreNullable ?? throw new Exception(
72+
$"Invalid keystore detected. Please remove the '{path}' file and re-authenticate."
73+
);
74+
}
75+
else
76+
{
77+
keystore = BotKeystore.CreateEmpty();
78+
}
79+
80+
keystore.DeviceName = configuration.Login.DeviceName;
81+
return keystore;
82+
})
83+
// BotContext
84+
.AddSingleton(services =>
8585
{
86-
keystore = BotKeystore.CreateEmpty();
87-
}
88-
89-
keystore.DeviceName = configuration.Login.DeviceName;
90-
return keystore;
91-
})
92-
// BotAppInfo
93-
.AddSingleton(services => services.GetRequiredService<Signer>().GetAppInfo().Result)
94-
// BotContext
95-
.AddSingleton(services =>
96-
{
97-
var config = services.GetRequiredService<BotConfig>();
98-
var keystore = services.GetRequiredService<BotKeystore>();
99-
var info = services.GetRequiredService<BotAppInfo>();
86+
var config = services.GetRequiredService<BotConfig>();
87+
var keystore = services.GetRequiredService<BotKeystore>();
10088

101-
return BotFactory.Create(config, keystore, info);
102-
})
89+
return BotFactory.Create(config, keystore);
90+
})
10391

104-
// CaptchaResolver
105-
.AddSingleton<ICaptchaResolver>(services =>
106-
{
107-
var configuration = services.GetRequiredService<IOptions<CoreConfiguration>>().Value;
92+
// CaptchaResolver
93+
.AddSingleton<ICaptchaResolver>(services =>
94+
{
95+
var configuration = services.GetRequiredService<IOptions<CoreConfiguration>>().Value;
10896

109-
return configuration.Login.UseOnlineCaptchaResolver
110-
? ActivatorUtilities.CreateInstance<OnlineCaptchaResolver>(services)
111-
: ActivatorUtilities.CreateInstance<ManualCaptchaResolver>(services);
112-
})
97+
return configuration.Login.UseOnlineCaptchaResolver
98+
? ActivatorUtilities.CreateInstance<OnlineCaptchaResolver>(services)
99+
: ActivatorUtilities.CreateInstance<ManualCaptchaResolver>(services);
100+
})
113101

114-
// Logger
115-
.AddHostedService<CoreLoggerService>()
102+
// Logger
103+
.AddHostedService<CoreLoggerService>()
116104

117-
// Login
118-
.AddHostedService<CoreLoginService>()
119-
);
105+
// Login
106+
.AddHostedService<CoreLoginService>()
107+
);
120108

121109
public static HostApplicationBuilder ConfigureMilky(this HostApplicationBuilder builder) => builder
110+
#pragma warning disable IL2026, IL3050
111+
// https://github.com/dotnet/runtime/issues/94544
122112
.ConfigureServices(services => services
123113
.Configure<MilkyConfiguration>(builder.Configuration.GetSection("Milky"))
114+
#pragma warning restore IL2026, IL3050
124115
// MessageCache
125116
.AddSingleton<MessageCache>()
126117
.AddHostedService(ServiceProviderServiceExtensions.GetRequiredService<MessageCache>)
@@ -131,8 +122,11 @@ public static HostApplicationBuilder ConfigureMilky(this HostApplicationBuilder
131122
)
132123
.ConfigureServices(services =>
133124
{
125+
#pragma warning disable IL2026, IL3050
126+
// https://github.com/dotnet/runtime/issues/94544
134127
var configuration = builder.Configuration.GetSection("Milky").Get<MilkyConfiguration>()
135128
?? throw new Exception("Milky cannot be null");
129+
#pragma warning restore IL2026, IL3050
136130

137131
// Api Handlers
138132
services.AddApiHandlers(configuration.Debug);
@@ -141,8 +135,11 @@ public static HostApplicationBuilder ConfigureMilky(this HostApplicationBuilder
141135
{
142136
services.AddHostedService<MilkyHttpApiService>();
143137

138+
#pragma warning disable IL2026, IL3050
139+
// https://github.com/dotnet/runtime/issues/94544
144140
var configuration = builder.Configuration.GetSection("Milky").Get<MilkyConfiguration>()
145141
?? throw new Exception("Milky cannot be null");
142+
#pragma warning restore IL2026, IL3050
146143

147144
if (configuration.EnabledWebSocket || configuration.WebHook != null)
148145
{

0 commit comments

Comments
 (0)