From 8b82058d7a0f1ca942abcdd866e69c090b0f6469 Mon Sep 17 00:00:00 2001 From: Keelah Atom Date: Sun, 23 Apr 2023 09:58:14 +0200 Subject: [PATCH 1/7] Quick fix on login failing --- FASTER/MainWindow.xaml.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/FASTER/MainWindow.xaml.cs b/FASTER/MainWindow.xaml.cs index b2d5f0db..0b24bde7 100644 --- a/FASTER/MainWindow.xaml.cs +++ b/FASTER/MainWindow.xaml.cs @@ -218,6 +218,9 @@ private void ToggleButton_Click(object sender, RoutedEventArgs e) default: if (IServerProfilesMenu.Items.Cast().FirstOrDefault(p => p.Name == nav.Name) != null) { + var profile = new Profile(); + MainContent.Content = profile; + ContentProfile.DataContext = ContentProfileViews.First(p => p.Profile.Id == nav.Name); ContentProfile.Refresh(); MainContent.Content = ContentProfile; From ccd1ed92203c0f8771e9cb08ede1eaa832d88c9b Mon Sep 17 00:00:00 2001 From: Keelah Atom Date: Sun, 23 Apr 2023 09:58:29 +0200 Subject: [PATCH 2/7] Quick fix (maybe) for profile loading --- FASTER/ViewModel/SteamUpdaterViewModel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FASTER/ViewModel/SteamUpdaterViewModel.cs b/FASTER/ViewModel/SteamUpdaterViewModel.cs index 2dcb1e50..b669c301 100644 --- a/FASTER/ViewModel/SteamUpdaterViewModel.cs +++ b/FASTER/ViewModel/SteamUpdaterViewModel.cs @@ -506,8 +506,8 @@ internal async Task SteamLogin() IsLoggingIn = true; var path = Path.Combine(Path.GetDirectoryName(ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath) ?? string.Empty, "sentries"); SteamAuthenticationFilesProvider sentryFileProvider = new DirectorySteamAuthenticationFilesProvider(path); - if (_steamCredentials == null || _steamCredentials.IsAnonymous) - _steamCredentials = new SteamCredentials(Parameters.Username, Encryption.Instance.DecryptData(Parameters.Password), Parameters.ApiKey); + + _steamCredentials = new SteamCredentials(Parameters.Username, Encryption.Instance.DecryptData(Parameters.Password), Parameters.ApiKey); SteamClient ??= new SteamClient(_steamCredentials, new AuthCodeProvider(), sentryFileProvider); From 05aa504bfaa6a0a114db2f2f1c78c8ab147c2041 Mon Sep 17 00:00:00 2001 From: Keelah Date: Wed, 31 May 2023 23:53:30 +0200 Subject: [PATCH 3/7] Fixed Error preventing users from updating the Server Bump Dependencies --- .gitignore | 3 +- .sonarlint/FASTER.slconfig | 15 - .../foxlider_faster/CSharp/SonarLint.xml | 89 ----- .sonarlint/foxlider_fastercsharp.ruleset | 368 ------------------ FASTER/FASTER.csproj | 2 +- FASTER/ViewModel/SteamUpdaterViewModel.cs | 32 +- 6 files changed, 14 insertions(+), 495 deletions(-) delete mode 100644 .sonarlint/FASTER.slconfig delete mode 100644 .sonarlint/foxlider_faster/CSharp/SonarLint.xml delete mode 100644 .sonarlint/foxlider_fastercsharp.ruleset diff --git a/.gitignore b/.gitignore index 584fc7c3..e370b7cc 100644 --- a/.gitignore +++ b/.gitignore @@ -331,4 +331,5 @@ ASALocalRun/ # VS Code User Files -.vscode/ \ No newline at end of file +.vscode/ +.sonarlint/ diff --git a/.sonarlint/FASTER.slconfig b/.sonarlint/FASTER.slconfig deleted file mode 100644 index 12a5d18d..00000000 --- a/.sonarlint/FASTER.slconfig +++ /dev/null @@ -1,15 +0,0 @@ -{ - "ServerUri": "https://sonarcloud.io/", - "Organization": { - "Key": "foxlicorp", - "Name": "Keelah" - }, - "ProjectKey": "Foxlider_FASTER", - "ProjectName": "FASTER", - "Profiles": { - "CSharp": { - "ProfileKey": "AW7Rfkrd6A1-kc3fchk2", - "ProfileTimestamp": "2021-11-28T14:54:48Z" - } - } -} \ No newline at end of file diff --git a/.sonarlint/foxlider_faster/CSharp/SonarLint.xml b/.sonarlint/foxlider_faster/CSharp/SonarLint.xml deleted file mode 100644 index ffa3aa13..00000000 --- a/.sonarlint/foxlider_faster/CSharp/SonarLint.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - sonar.cs.analyzeGeneratedCode - false - - - sonar.cs.file.suffixes - .cs - - - sonar.cs.ignoreHeaderComments - true - - - sonar.cs.roslyn.ignoreIssues - false - - - - - S107 - - - max - 7 - - - - - S110 - - - max - 5 - - - - - S1479 - - - maximum - 30 - - - - - S2342 - - - flagsAttributeFormat - ^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?s$ - - - format - ^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?$ - - - - - S2436 - - - max - 2 - - - maxMethod - 3 - - - - - S3776 - - - propertyThreshold - 3 - - - threshold - 25 - - - - - \ No newline at end of file diff --git a/.sonarlint/foxlider_fastercsharp.ruleset b/.sonarlint/foxlider_fastercsharp.ruleset deleted file mode 100644 index 19d72398..00000000 --- a/.sonarlint/foxlider_fastercsharp.ruleset +++ /dev/null @@ -1,368 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/FASTER/FASTER.csproj b/FASTER/FASTER.csproj index 9e911826..ac9eb728 100644 --- a/FASTER/FASTER.csproj +++ b/FASTER/FASTER.csproj @@ -52,7 +52,7 @@ - + diff --git a/FASTER/ViewModel/SteamUpdaterViewModel.cs b/FASTER/ViewModel/SteamUpdaterViewModel.cs index b669c301..fcdd442c 100644 --- a/FASTER/ViewModel/SteamUpdaterViewModel.cs +++ b/FASTER/ViewModel/SteamUpdaterViewModel.cs @@ -293,20 +293,21 @@ internal async Task RunServerUpdater(string path, uint appId, List<(uint id if (!await SteamLogin()) return UpdateState.LoginFailed; - var _OS = SteamClient?.GetSteamOs().Identifier; + //var _OS = SteamClient?.GetSteamOs().Identifier; Stopwatch sw = Stopwatch.StartNew(); foreach (var depot in depots) { try { - SteamOs steamOs = new(_OS); + SteamOs steamOs = new("win"); ManifestId manifestId; - manifestId = await SteamContentClient.GetDepotDefaultManifestIdAsync(appId, depot.id, depot.branch, depot.pass); + manifestId = await SteamContentClient.GetDepotManifestIdAsync(appId, depot.id, depot.branch, depot.pass); + + Parameters.Output += $"\nFetching infor;ations of app {appId}, depot {depot.id} from Steam ({depots.IndexOf(depot)+1}/{depots.Count})... "; + var downloadHandler = await SteamContentClient.GetAppDataAsync(appId, depot.id, manifestId, tokenSource.Token); - Parameters.Output += $"\nAttempting to start download of app {appId}, depot {depot.id} ({depots.IndexOf(depot)+1}/{depots.Count})... "; - var downloadHandler = await SteamContentClient.GetAppDataAsync(appId, depot.id, manifestId, depot.branch, depot.pass, steamOs); await Download(downloadHandler, path); } catch (Exception ex) @@ -341,12 +342,10 @@ public async Task RunModUpdater(ulong modId, string path) return UpdateState.LoginFailed; } - var _OS = SteamClient.GetSteamOs().Identifier; Stopwatch sw = Stopwatch.StartNew(); try { - SteamOs steamOs = new(_OS); ManifestId manifestId = default; Parameters.Output += $"\nFetching mod {modId} infos... "; @@ -361,12 +360,7 @@ public async Task RunModUpdater(ulong modId, string path) Parameters.Output += $"\nAttempting to start download of item {modId}... "; - var downloadHandler = await SteamContentClient.GetPublishedFileDataAsync( - modId, - manifestId, - null, - null, - steamOs); + var downloadHandler = await SteamContentClient.GetPublishedFileDataAsync(modId, manifestId, tokenSource.Token); await Download(downloadHandler, path); } @@ -404,8 +398,6 @@ public async Task RunModsUpdater(ObservableCollection mods) return UpdateState.LoginFailed; } - var _OS = SteamClient.GetSteamOs().Identifier; - Parameters.Output += "\nAdding mods to download list..."; SemaphoreSlim maxThread = new(1); @@ -432,7 +424,6 @@ public async Task RunModsUpdater(ObservableCollection mods) Stopwatch sw = Stopwatch.StartNew(); try { - SteamOs steamOs = new(_OS); ManifestId manifestId = default; if(mod.LocalLastUpdated > mod.SteamLastUpdated) @@ -453,11 +444,7 @@ public async Task RunModsUpdater(ObservableCollection mods) Parameters.Output += $"\n Attempting to start download of item {mod.WorkshopId}... "; - var downloadHandler = SteamContentClient.GetPublishedFileDataAsync(mod.WorkshopId, - manifestId, - null, - null, - steamOs); + var downloadHandler = SteamContentClient.GetPublishedFileDataAsync(mod.WorkshopId, manifestId, tokenSource.Token); DownloadForMultiple(downloadHandler.Result, mod.Path).Wait(); } catch (TaskCanceledException) @@ -505,6 +492,9 @@ internal async Task SteamLogin() { IsLoggingIn = true; var path = Path.Combine(Path.GetDirectoryName(ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath) ?? string.Empty, "sentries"); + //path = path.Replace("FoxliCorp.\\", "FoxliCorp\\"); + //if(!Directory.Exists(path)) + // Directory.CreateDirectory(path); SteamAuthenticationFilesProvider sentryFileProvider = new DirectorySteamAuthenticationFilesProvider(path); _steamCredentials = new SteamCredentials(Parameters.Username, Encryption.Instance.DecryptData(Parameters.Password), Parameters.ApiKey); From 2f0c50dad4cedb660f66b4cc01591e10f9a9274d Mon Sep 17 00:00:00 2001 From: Keelah Date: Wed, 31 May 2023 23:53:48 +0200 Subject: [PATCH 4/7] Bump Dependencies --- FASTER/FASTER.csproj | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/FASTER/FASTER.csproj b/FASTER/FASTER.csproj index ac9eb728..da30f6a7 100644 --- a/FASTER/FASTER.csproj +++ b/FASTER/FASTER.csproj @@ -51,17 +51,17 @@ - + - - - - + + + + From 54dba864608e9b47006666dc98eee280800d57ee Mon Sep 17 00:00:00 2001 From: Keelah Date: Thu, 1 Jun 2023 01:59:17 +0200 Subject: [PATCH 5/7] Login fixes, basically a new feature And version bump --- FASTER/FASTER.csproj | 4 +- FASTER/Models/SteamWebApi.cs | 100 ++++++++++++++++++++-- FASTER/ViewModel/SteamUpdaterViewModel.cs | 9 +- FASTER_Version.xml | 2 +- 4 files changed, 101 insertions(+), 14 deletions(-) diff --git a/FASTER/FASTER.csproj b/FASTER/FASTER.csproj index da30f6a7..410d5f9c 100644 --- a/FASTER/FASTER.csproj +++ b/FASTER/FASTER.csproj @@ -7,7 +7,7 @@ win-x64 true true - 1.8.6.1 + 1.8.7.1 Keelah Fox FoxliCorp. Fox's Arma Server Tool Extended Rewrite @@ -52,7 +52,7 @@ - + diff --git a/FASTER/Models/SteamWebApi.cs b/FASTER/Models/SteamWebApi.cs index bda808e2..e5172df0 100644 --- a/FASTER/Models/SteamWebApi.cs +++ b/FASTER/Models/SteamWebApi.cs @@ -1,11 +1,16 @@ using BytexDigital.Steam.Core; +using MahApps.Metro.Controls.Dialogs; + using Newtonsoft.Json.Linq; using System; using System.Diagnostics; +using System.IO; using System.Net; using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; using System.Windows; namespace FASTER.Models @@ -94,29 +99,112 @@ private static string GetApiKey() } } - internal class AuthCodeProvider : SteamAuthenticationCodesProvider + internal class AuthCodeProvider : SteamAuthenticator { - public override string GetEmailAuthenticationCode(SteamCredentials steamCredentials) + + private readonly string _persistenceDirectory; + private readonly string _uniqueStorageName; + public string AccessToken { get; protected set; } + public string GuardData { get; protected set; } + + + public AuthCodeProvider(string uniqueStorageName, string persistenceDirectory) + { + _uniqueStorageName = uniqueStorageName; + _persistenceDirectory = persistenceDirectory; + } + + public override Task GetEmailAuthenticationCodeAsync(string account_email, bool previousCodeWasIncorrect, CancellationToken cancellationToken = default) { - MainWindow.Instance.SteamUpdaterViewModel.Parameters.Output += "\nPlease enter your email auth code: "; + if (previousCodeWasIncorrect) + MainWindow.Instance.SteamUpdaterViewModel.Parameters.Output += "\nPreviously entered email code was incorrect!"; + + MainWindow.Instance.SteamUpdaterViewModel.Parameters.Output += "\nPlease enter your 2FA code: "; var input = MainWindow.Instance.SteamUpdaterViewModel.SteamGuardInput().Result; MainWindow.Instance.SteamUpdaterViewModel.Parameters.Output += "\nRetrying... "; - return input; + return Task.FromResult(input); } - public override string GetTwoFactorAuthenticationCode(SteamCredentials steamCredentials) + public override Task GetTwoFactorAuthenticationCodeAsync(bool previousCodeWasIncorrect, CancellationToken cancellationToken = default) { + if (previousCodeWasIncorrect) + MainWindow.Instance.SteamUpdaterViewModel.Parameters.Output += "\nPreviously entered 2FA code was incorrect!"; + + MainWindow.Instance.SteamUpdaterViewModel.Parameters.Output += "\nPlease enter your 2FA code: "; var input = MainWindow.Instance.SteamUpdaterViewModel.SteamGuardInput().Result; MainWindow.Instance.SteamUpdaterViewModel.Parameters.Output += "\nRetrying... "; - return input; + return Task.FromResult(input); + } + + public override Task NotifyMobileNotificationAsync(CancellationToken cancellationToken = default) + { + MainWindow.Instance.SteamUpdaterViewModel.Parameters.Output += "\nMobile notification sent. Answer \"y\" once you've authorized this login. If no notification was received or you'd like to enter a traditional 2FA code, enter \"n\": "; + + MessageDialogResult response; + + do + { + response = MainWindow.Instance.SteamUpdaterViewModel.SteamGuardInputPhone().Result; + } while (response != MessageDialogResult.Affirmative); + + return Task.FromResult(true); + } + + public override Task PersistAccessTokenAsync(string token, CancellationToken cancellationToken = default) + { + AccessToken = token; + + if (string.IsNullOrEmpty(_persistenceDirectory)) return Task.CompletedTask; + + Directory.CreateDirectory(_persistenceDirectory); + File.WriteAllText(Path.Combine(_persistenceDirectory, $"{_uniqueStorageName}_accesstoken"), AccessToken); + + return Task.CompletedTask; + } + + + public override Task GetAccessTokenAsync(CancellationToken cancellationToken = default) + { + if (string.IsNullOrEmpty(_persistenceDirectory)) + { + return Task.FromResult(AccessToken); + } + + var path = Path.Combine(_persistenceDirectory, $"{_uniqueStorageName}_accesstoken"); + + return Task.FromResult(File.Exists(path) ? File.ReadAllText(path) : AccessToken); + } + + public override Task PersistGuardDataAsync(string data, CancellationToken cancellationToken = default) + { + GuardData = data; + + if (string.IsNullOrEmpty(_persistenceDirectory)) return Task.CompletedTask; + + Directory.CreateDirectory(_persistenceDirectory); + File.WriteAllText(Path.Combine(_persistenceDirectory, $"{_uniqueStorageName}_guarddata"), GuardData); + + return Task.CompletedTask; + } + + public override Task GetGuardDataAsync(CancellationToken cancellationToken = default) + { + if (string.IsNullOrEmpty(_persistenceDirectory)) + { + return Task.FromResult(GuardData); + } + + var path = Path.Combine(_persistenceDirectory, $"{_uniqueStorageName}_guarddata"); + + return Task.FromResult(File.Exists(path) ? File.ReadAllText(path) : GuardData); } } diff --git a/FASTER/ViewModel/SteamUpdaterViewModel.cs b/FASTER/ViewModel/SteamUpdaterViewModel.cs index fcdd442c..0c195188 100644 --- a/FASTER/ViewModel/SteamUpdaterViewModel.cs +++ b/FASTER/ViewModel/SteamUpdaterViewModel.cs @@ -492,14 +492,10 @@ internal async Task SteamLogin() { IsLoggingIn = true; var path = Path.Combine(Path.GetDirectoryName(ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath) ?? string.Empty, "sentries"); - //path = path.Replace("FoxliCorp.\\", "FoxliCorp\\"); - //if(!Directory.Exists(path)) - // Directory.CreateDirectory(path); - SteamAuthenticationFilesProvider sentryFileProvider = new DirectorySteamAuthenticationFilesProvider(path); _steamCredentials = new SteamCredentials(Parameters.Username, Encryption.Instance.DecryptData(Parameters.Password), Parameters.ApiKey); - SteamClient ??= new SteamClient(_steamCredentials, new AuthCodeProvider(), sentryFileProvider); + SteamClient ??= new SteamClient(_steamCredentials, new AuthCodeProvider(_steamCredentials.Username, path)); if (!SteamClient.IsConnected || SteamClient.IsFaulted) { @@ -684,6 +680,9 @@ private async Task DownloadForMultiple(IDownloadHandler downloadHandler, string public async Task SteamGuardInput() { return await DialogCoordinator.ShowInputAsync(this, "Steam Guard", "Please enter your 2FA code"); } + public async Task SteamGuardInputPhone() + { return await DialogCoordinator.ShowMessageAsync(this, "Steam Guard", "Press OK after accepting authentification on mobile", MessageDialogStyle.Affirmative); } + public event PropertyChangedEventHandler PropertyChanged; private void RaisePropertyChanged(string property) diff --git a/FASTER_Version.xml b/FASTER_Version.xml index ed1c7076..82ee33d4 100644 --- a/FASTER_Version.xml +++ b/FASTER_Version.xml @@ -1,6 +1,6 @@  - 1.8.6.1 + 1.8.7.1 https://github.com/Foxlider/FASTER/releases/latest/download/Release_x64.zip https://github.com/Foxlider/FASTER/releases true From 86a8b5fff20007033ac4e72197119159bd624b44 Mon Sep 17 00:00:00 2001 From: Keelah Date: Thu, 1 Jun 2023 02:06:39 +0200 Subject: [PATCH 6/7] Sonar fixes --- FASTER/ViewModel/SteamUpdaterViewModel.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/FASTER/ViewModel/SteamUpdaterViewModel.cs b/FASTER/ViewModel/SteamUpdaterViewModel.cs index 0c195188..85d649b7 100644 --- a/FASTER/ViewModel/SteamUpdaterViewModel.cs +++ b/FASTER/ViewModel/SteamUpdaterViewModel.cs @@ -113,7 +113,6 @@ public bool IsDlOverride internal SteamClient SteamClient; internal SteamContentClient SteamContentClient; - private SteamCredentials _steamCredentials; public void PasswordChanged(string password) { @@ -293,16 +292,13 @@ internal async Task RunServerUpdater(string path, uint appId, List<(uint id if (!await SteamLogin()) return UpdateState.LoginFailed; - //var _OS = SteamClient?.GetSteamOs().Identifier; Stopwatch sw = Stopwatch.StartNew(); foreach (var depot in depots) { try { - SteamOs steamOs = new("win"); ManifestId manifestId; - manifestId = await SteamContentClient.GetDepotManifestIdAsync(appId, depot.id, depot.branch, depot.pass); Parameters.Output += $"\nFetching infor;ations of app {appId}, depot {depot.id} from Steam ({depots.IndexOf(depot)+1}/{depots.Count})... "; @@ -493,7 +489,7 @@ internal async Task SteamLogin() IsLoggingIn = true; var path = Path.Combine(Path.GetDirectoryName(ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath) ?? string.Empty, "sentries"); - _steamCredentials = new SteamCredentials(Parameters.Username, Encryption.Instance.DecryptData(Parameters.Password), Parameters.ApiKey); + SteamCredentials _steamCredentials = new SteamCredentials(Parameters.Username, Encryption.Instance.DecryptData(Parameters.Password), Parameters.ApiKey); SteamClient ??= new SteamClient(_steamCredentials, new AuthCodeProvider(_steamCredentials.Username, path)); From bc6f54883613b892c5cd1cb9dd062fe4f35e1bda Mon Sep 17 00:00:00 2001 From: Keelah Date: Thu, 1 Jun 2023 02:13:30 +0200 Subject: [PATCH 7/7] Sonar fixes AGAIN --- FASTER/Models/SteamWebApi.cs | 2 +- FASTER/ViewModel/SteamUpdaterViewModel.cs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/FASTER/Models/SteamWebApi.cs b/FASTER/Models/SteamWebApi.cs index e5172df0..330fb915 100644 --- a/FASTER/Models/SteamWebApi.cs +++ b/FASTER/Models/SteamWebApi.cs @@ -114,7 +114,7 @@ public AuthCodeProvider(string uniqueStorageName, string persistenceDirectory) _persistenceDirectory = persistenceDirectory; } - public override Task GetEmailAuthenticationCodeAsync(string account_email, bool previousCodeWasIncorrect, CancellationToken cancellationToken = default) + public override Task GetEmailAuthenticationCodeAsync(string accountEmail, bool previousCodeWasIncorrect, CancellationToken cancellationToken = default) { if (previousCodeWasIncorrect) MainWindow.Instance.SteamUpdaterViewModel.Parameters.Output += "\nPreviously entered email code was incorrect!"; diff --git a/FASTER/ViewModel/SteamUpdaterViewModel.cs b/FASTER/ViewModel/SteamUpdaterViewModel.cs index 85d649b7..f64ea72f 100644 --- a/FASTER/ViewModel/SteamUpdaterViewModel.cs +++ b/FASTER/ViewModel/SteamUpdaterViewModel.cs @@ -3,7 +3,6 @@ using BytexDigital.Steam.ContentDelivery.Models; using BytexDigital.Steam.ContentDelivery.Models.Downloading; using BytexDigital.Steam.Core; -using BytexDigital.Steam.Core.Enumerations; using BytexDigital.Steam.Core.Structs; using FASTER.Models;