Allow cmdline arg for forbidding Steam parental generation

This commit is contained in:
Archi
2022-04-06 14:16:26 +02:00
parent 1eabe3a5ed
commit 0bbc85527a
2 changed files with 12 additions and 3 deletions

View File

@@ -54,6 +54,7 @@ internal static class Program {
internal static bool RestartAllowed { get; private set; } = true;
internal static bool Service { get; private set; }
internal static bool ShutdownSequenceInitialized { get; private set; }
internal static bool SteamParentalGeneration { get; private set; } = true;
#if !NETFRAMEWORK
private static readonly Dictionary<PosixSignal, PosixSignalRegistration> RegisteredPosixSignals = new();
@@ -529,6 +530,10 @@ internal static class Program {
case "--NO-RESTART" when !cryptKeyNext && !networkGroupNext && !pathNext:
RestartAllowed = false;
break;
case "--NO-STEAM-PARENTAL-GENERATION" when !cryptKeyNext && !networkGroupNext && !pathNext:
SteamParentalGeneration = false;
break;
case "--PROCESS-REQUIRED" when !cryptKeyNext && !networkGroupNext && !pathNext:
ProcessRequired = true;

View File

@@ -2783,7 +2783,7 @@ public sealed class Bot : IAsyncDisposable {
}
if (callback.ParentalSettings != null) {
(bool isSteamParentalEnabled, string? steamParentalCode) = ValidateSteamParental(callback.ParentalSettings, BotConfig.SteamParentalCode);
(bool isSteamParentalEnabled, string? steamParentalCode) = ValidateSteamParental(callback.ParentalSettings, BotConfig.SteamParentalCode, Program.SteamParentalGeneration);
if (isSteamParentalEnabled) {
// Steam parental enabled
@@ -2801,7 +2801,7 @@ public sealed class Bot : IAsyncDisposable {
break;
}
}
} else if (string.IsNullOrEmpty(BotConfig.SteamParentalCode)) {
} else {
// We failed to generate the pin ourselves, ask the user
RequiredInput = ASF.EUserInputType.SteamParentalCode;
@@ -3503,7 +3503,7 @@ public sealed class Bot : IAsyncDisposable {
PlayingWasBlockedTimer = null;
}
private (bool IsSteamParentalEnabled, string? SteamParentalCode) ValidateSteamParental(ParentalSettings settings, string? steamParentalCode = null) {
private (bool IsSteamParentalEnabled, string? SteamParentalCode) ValidateSteamParental(ParentalSettings settings, string? steamParentalCode = null, bool allowGeneration = true) {
ArgumentNullException.ThrowIfNull(settings);
if (!settings.is_enabled) {
@@ -3550,6 +3550,10 @@ public sealed class Bot : IAsyncDisposable {
}
}
if (!allowGeneration) {
return (true, null);
}
ArchiLogger.LogGenericInfo(Strings.BotGeneratingSteamParentalCode);
steamParentalCode = ArchiCryptoHelper.RecoverSteamParentalCode(settings.passwordhash, settings.salt, steamParentalHashingMethod);