mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-10 13:44:22 +00:00
Avoid excessive parental request
We can make use of the one in logged-in, which is superior
This commit is contained in:
@@ -36,6 +36,7 @@
|
|||||||
<PackageReference Include="ConfigureAwaitChecker.Analyzer" Version="4.0.0">
|
<PackageReference Include="ConfigureAwaitChecker.Analyzer" Version="4.0.0">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="SteamKit2" Version="*" />
|
||||||
<PackageReference Include="System.Composition.AttributedModel" Version="*" />
|
<PackageReference Include="System.Composition.AttributedModel" Version="*" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ namespace ArchiSteamFarm {
|
|||||||
private readonly SteamUnifiedMessages.UnifiedService<IClanChatRooms> UnifiedClanChatRoomsService;
|
private readonly SteamUnifiedMessages.UnifiedService<IClanChatRooms> UnifiedClanChatRoomsService;
|
||||||
private readonly SteamUnifiedMessages.UnifiedService<IEcon> UnifiedEconService;
|
private readonly SteamUnifiedMessages.UnifiedService<IEcon> UnifiedEconService;
|
||||||
private readonly SteamUnifiedMessages.UnifiedService<IFriendMessages> UnifiedFriendMessagesService;
|
private readonly SteamUnifiedMessages.UnifiedService<IFriendMessages> UnifiedFriendMessagesService;
|
||||||
private readonly SteamUnifiedMessages.UnifiedService<IParental> UnifiedParentalService;
|
|
||||||
private readonly SteamUnifiedMessages.UnifiedService<IPlayer> UnifiedPlayerService;
|
private readonly SteamUnifiedMessages.UnifiedService<IPlayer> UnifiedPlayerService;
|
||||||
|
|
||||||
internal DateTime LastPacketReceived { get; private set; }
|
internal DateTime LastPacketReceived { get; private set; }
|
||||||
@@ -58,7 +57,6 @@ namespace ArchiSteamFarm {
|
|||||||
UnifiedClanChatRoomsService = steamUnifiedMessages.CreateService<IClanChatRooms>();
|
UnifiedClanChatRoomsService = steamUnifiedMessages.CreateService<IClanChatRooms>();
|
||||||
UnifiedEconService = steamUnifiedMessages.CreateService<IEcon>();
|
UnifiedEconService = steamUnifiedMessages.CreateService<IEcon>();
|
||||||
UnifiedFriendMessagesService = steamUnifiedMessages.CreateService<IFriendMessages>();
|
UnifiedFriendMessagesService = steamUnifiedMessages.CreateService<IFriendMessages>();
|
||||||
UnifiedParentalService = steamUnifiedMessages.CreateService<IParental>();
|
|
||||||
UnifiedPlayerService = steamUnifiedMessages.CreateService<IPlayer>();
|
UnifiedPlayerService = steamUnifiedMessages.CreateService<IPlayer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -631,90 +629,6 @@ namespace ArchiSteamFarm {
|
|||||||
Client.Send(request);
|
Client.Send(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<(bool IsSteamParentalEnabled, string SteamParentalCode)?> ValidateSteamParental(string steamParentalCode = null) {
|
|
||||||
if (!Client.IsConnected) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
CParental_GetParentalSettings_Request request = new CParental_GetParentalSettings_Request { steamid = Client.SteamID };
|
|
||||||
|
|
||||||
SteamUnifiedMessages.ServiceMethodResponse response;
|
|
||||||
|
|
||||||
try {
|
|
||||||
response = await UnifiedParentalService.SendMessage(x => x.GetParentalSettings(request));
|
|
||||||
} catch (Exception e) {
|
|
||||||
ArchiLogger.LogGenericWarningException(e);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (response == null) {
|
|
||||||
ArchiLogger.LogNullError(nameof(response));
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (response.Result != EResult.OK) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
CParental_GetParentalSettings_Response body = response.GetDeserializedResponse<CParental_GetParentalSettings_Response>();
|
|
||||||
|
|
||||||
if (body.settings == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!body.settings.is_enabled) {
|
|
||||||
return (false, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
ArchiCryptoHelper.ESteamParentalAlgorithm steamParentalAlgorithm;
|
|
||||||
|
|
||||||
switch (body.settings.passwordhashtype) {
|
|
||||||
case 4:
|
|
||||||
steamParentalAlgorithm = ArchiCryptoHelper.ESteamParentalAlgorithm.Pbkdf2;
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
steamParentalAlgorithm = ArchiCryptoHelper.ESteamParentalAlgorithm.SCrypt;
|
|
||||||
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ASF.ArchiLogger.LogGenericError(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(body.settings.passwordhashtype), body.settings.passwordhashtype));
|
|
||||||
|
|
||||||
return (false, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((steamParentalCode != null) && (steamParentalCode.Length == BotConfig.SteamParentalCodeLength)) {
|
|
||||||
byte i = 0;
|
|
||||||
byte[] password = new byte[steamParentalCode.Length];
|
|
||||||
|
|
||||||
foreach (char character in steamParentalCode) {
|
|
||||||
if ((character < '0') || (character > '9')) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
password[i++] = (byte) character;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i >= steamParentalCode.Length) {
|
|
||||||
byte[] passwordHash = ArchiCryptoHelper.GenerateSteamParentalHash(password, body.settings.salt, (byte) body.settings.passwordhash.Length, steamParentalAlgorithm);
|
|
||||||
|
|
||||||
if (passwordHash.SequenceEqual(body.settings.passwordhash)) {
|
|
||||||
return (true, steamParentalCode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ArchiLogger.LogGenericInfo(Strings.BotGeneratingSteamParentalCode);
|
|
||||||
|
|
||||||
steamParentalCode = ArchiCryptoHelper.RecoverSteamParentalCode(body.settings.passwordhash, body.settings.salt, steamParentalAlgorithm);
|
|
||||||
|
|
||||||
ArchiLogger.LogGenericInfo(Strings.Done);
|
|
||||||
|
|
||||||
return (true, steamParentalCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void HandleItemAnnouncements(IPacketMsg packetMsg) {
|
private void HandleItemAnnouncements(IPacketMsg packetMsg) {
|
||||||
if (packetMsg == null) {
|
if (packetMsg == null) {
|
||||||
ArchiLogger.LogNullError(nameof(packetMsg));
|
ArchiLogger.LogNullError(nameof(packetMsg));
|
||||||
|
|||||||
@@ -74,13 +74,17 @@
|
|||||||
<PackageReference Include="Microsoft.AspNetCore.WebSockets" Version="2.2.1" />
|
<PackageReference Include="Microsoft.AspNetCore.WebSockets" Version="2.2.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0-preview6.19304.6" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0-preview6.19304.6" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="3.0.0-preview6.19304.6" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="3.0.0-preview6.19304.6" />
|
||||||
|
<PackageReference Include="Microsoft.Win32.Registry" Version="4.6.0-preview6.19303.8" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
|
||||||
<PackageReference Include="NLog" Version="4.6.6" />
|
<PackageReference Include="NLog" Version="4.6.6" />
|
||||||
<PackageReference Include="NLog.Web.AspNetCore" Version="4.8.4" />
|
<PackageReference Include="NLog.Web.AspNetCore" Version="4.8.4" />
|
||||||
<PackageReference Include="SteamKit2" Version="2.2.0" />
|
<PackageReference Include="protobuf-net" Version="3.0.0-alpha.43" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc2" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc2" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.0.0-rc2" />
|
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.0.0-rc2" />
|
||||||
<PackageReference Include="System.Composition" Version="1.3.0-preview6.19303.8" />
|
<PackageReference Include="System.Composition" Version="1.3.0-preview6.19303.8" />
|
||||||
|
<Reference Include="SteamKit2">
|
||||||
|
<HintPath>lib\SteamKit2.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.2'">
|
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.2'">
|
||||||
|
|||||||
@@ -2417,18 +2417,18 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(bool IsSteamParentalEnabled, string SteamParentalCode)? steamParental = await ArchiHandler.ValidateSteamParental(BotConfig.SteamParentalCode).ConfigureAwait(false);
|
if (callback.ParentalSettings != null) {
|
||||||
|
(bool isSteamParentalEnabled, string steamParentalCode) = ValidateSteamParental(callback.ParentalSettings, BotConfig.SteamParentalCode);
|
||||||
|
|
||||||
if (steamParental.HasValue) {
|
if (isSteamParentalEnabled) {
|
||||||
if (steamParental.Value.IsSteamParentalEnabled) {
|
|
||||||
SteamParentalActive = true;
|
SteamParentalActive = true;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(steamParental.Value.SteamParentalCode)) {
|
if (!string.IsNullOrEmpty(steamParentalCode)) {
|
||||||
if (BotConfig.SteamParentalCode != steamParental.Value.SteamParentalCode) {
|
if (BotConfig.SteamParentalCode != steamParentalCode) {
|
||||||
SetUserInput(ASF.EUserInputType.SteamParentalCode, steamParental.Value.SteamParentalCode);
|
SetUserInput(ASF.EUserInputType.SteamParentalCode, steamParentalCode);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
string steamParentalCode = await Logging.GetUserInput(ASF.EUserInputType.SteamParentalCode, BotName).ConfigureAwait(false);
|
steamParentalCode = await Logging.GetUserInput(ASF.EUserInputType.SteamParentalCode, BotName).ConfigureAwait(false);
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(steamParentalCode) || (steamParentalCode.Length != BotConfig.SteamParentalCodeLength)) {
|
if (string.IsNullOrEmpty(steamParentalCode) || (steamParentalCode.Length != BotConfig.SteamParentalCodeLength)) {
|
||||||
Stop();
|
Stop();
|
||||||
@@ -2943,6 +2943,64 @@ namespace ArchiSteamFarm {
|
|||||||
return message.Replace("\\[", "[").Replace("\\\\", "\\");
|
return message.Replace("\\[", "[").Replace("\\\\", "\\");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private (bool IsSteamParentalEnabled, string SteamParentalCode) ValidateSteamParental(ParentalSettings settings, string steamParentalCode = null) {
|
||||||
|
if (settings == null) {
|
||||||
|
ArchiLogger.LogNullError(nameof(settings));
|
||||||
|
|
||||||
|
return (false, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!settings.is_enabled) {
|
||||||
|
return (false, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
ArchiCryptoHelper.ESteamParentalAlgorithm steamParentalAlgorithm;
|
||||||
|
|
||||||
|
switch (settings.passwordhashtype) {
|
||||||
|
case 4:
|
||||||
|
steamParentalAlgorithm = ArchiCryptoHelper.ESteamParentalAlgorithm.Pbkdf2;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
steamParentalAlgorithm = ArchiCryptoHelper.ESteamParentalAlgorithm.SCrypt;
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ArchiLogger.LogGenericError(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(settings.passwordhashtype), settings.passwordhashtype));
|
||||||
|
|
||||||
|
return (true, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((steamParentalCode != null) && (steamParentalCode.Length == BotConfig.SteamParentalCodeLength)) {
|
||||||
|
byte i = 0;
|
||||||
|
byte[] password = new byte[steamParentalCode.Length];
|
||||||
|
|
||||||
|
foreach (char character in steamParentalCode) {
|
||||||
|
if ((character < '0') || (character > '9')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
password[i++] = (byte) character;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i >= steamParentalCode.Length) {
|
||||||
|
byte[] passwordHash = ArchiCryptoHelper.GenerateSteamParentalHash(password, settings.salt, (byte) settings.passwordhash.Length, steamParentalAlgorithm);
|
||||||
|
|
||||||
|
if (passwordHash.SequenceEqual(settings.passwordhash)) {
|
||||||
|
return (true, steamParentalCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ArchiLogger.LogGenericInfo(Strings.BotGeneratingSteamParentalCode);
|
||||||
|
|
||||||
|
steamParentalCode = ArchiCryptoHelper.RecoverSteamParentalCode(settings.passwordhash, settings.salt, steamParentalAlgorithm);
|
||||||
|
|
||||||
|
ArchiLogger.LogGenericInfo(Strings.Done);
|
||||||
|
|
||||||
|
return (true, steamParentalCode);
|
||||||
|
}
|
||||||
|
|
||||||
internal enum EFileType : byte {
|
internal enum EFileType : byte {
|
||||||
Config,
|
Config,
|
||||||
Database,
|
Database,
|
||||||
|
|||||||
BIN
ArchiSteamFarm/lib/SteamKit2.dll
Normal file
BIN
ArchiSteamFarm/lib/SteamKit2.dll
Normal file
Binary file not shown.
8516
ArchiSteamFarm/lib/SteamKit2.xml
Normal file
8516
ArchiSteamFarm/lib/SteamKit2.xml
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user