STD: Fail on invalid tokens

This commit is contained in:
JustArchi
2020-06-13 15:35:56 +02:00
parent 4d1bca5e51
commit f6c1e217f0
2 changed files with 9 additions and 2 deletions

View File

@@ -22,6 +22,7 @@
namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper {
internal static class SharedInfo {
internal const byte ApiVersion = 1;
internal const string ConfigurationPropertyEnabled = nameof(SteamTokenDumperPlugin) + "Enabled";
internal const ushort ItemsPerSingleRequest = 2048; // Should be synchronized with TimeoutForLongRunningTasksInSeconds
internal const byte MaximumHoursBetweenRefresh = 8; // Per single bot account, makes sense to be 2 or 3 times less than MinimumHoursBetweenUploads
internal const byte MaximumMinutesBeforeFirstUpload = 60; // Must be greater or equal to MinimumMinutesBeforeFirstUpload
@@ -30,5 +31,7 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper {
internal const string ServerURL = "https://asf-token-dumper.xpaw.me";
internal const byte TimeoutForLongRunningTasksInSeconds = 60; // Should be synchronized with ItemsPerSingleRequest
internal const string Token = "STEAM_TOKEN_DUMPER_TOKEN";
internal static bool HasValidToken => Token.Length == 128;
}
}

View File

@@ -52,14 +52,18 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper {
public Task<uint> GetPreferredChangeNumberToStartFrom() => Task.FromResult(IsEnabled ? GlobalCache?.LastChangeNumber ?? 0 : 0);
public void OnASFInit(IReadOnlyDictionary<string, JToken> additionalConfigProperties = null) {
const string enabledProperty = nameof(SteamTokenDumperPlugin) + "Enabled";
if (!SharedInfo.HasValidToken) {
ASF.ArchiLogger.LogGenericError($"{Name} has been disabled due to missing build token.");
return;
}
bool enabled = false;
if (additionalConfigProperties != null) {
foreach ((string configProperty, JToken configValue) in additionalConfigProperties) {
try {
if (configProperty == enabledProperty) {
if (configProperty == SharedInfo.ConfigurationPropertyEnabled) {
enabled = configValue.Value<bool>();
}
} catch (Exception e) {