Pre-release performance update.

- Potentially fixed memory leak in code progress bar
- Added using statement in SteamGuardCodeGenerator on disposable HMACSHA1
- Most of packages updated to the last version
This commit is contained in:
Давид Чернопятов
2024-09-01 02:51:35 +03:00
parent e401bcccfd
commit 89ca08f6cf
14 changed files with 28 additions and 55 deletions
-1
View File
@@ -5,7 +5,6 @@ using NebulaAuth.Model.Entities;
using NebulaAuth.View; using NebulaAuth.View;
using NebulaAuth.View.Dialogs; using NebulaAuth.View.Dialogs;
using NebulaAuth.ViewModel.Other; using NebulaAuth.ViewModel.Other;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
namespace NebulaAuth.Core; namespace NebulaAuth.Core;
-1
View File
@@ -9,7 +9,6 @@ using SteamLib.Utility.MaFiles;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.DirectoryServices.ActiveDirectory;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
+8 -8
View File
@@ -19,17 +19,17 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Autoupdater.NET.Official" Version="1.8.5" /> <PackageReference Include="Autoupdater.NET.Official" Version="1.9.2" />
<PackageReference Include="CodingSeb.Localization.JsonFileLoader" Version="1.3.0" /> <PackageReference Include="CodingSeb.Localization.JsonFileLoader" Version="1.3.1" />
<PackageReference Include="CodingSeb.Localization.WPF" Version="1.3.0" /> <PackageReference Include="CodingSeb.Localization.WPF" Version="1.3.3" />
<PackageReference Include="CodingSebLocalization.Fody" Version="1.3.0" /> <PackageReference Include="CodingSebLocalization.Fody" Version="1.3.1" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" /> <PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.0" />
<PackageReference Include="MaterialDesignColors" Version="2.1.4" /> <PackageReference Include="MaterialDesignColors" Version="2.1.4" />
<PackageReference Include="MaterialDesignExtensions" Version="4.0.0-a02" /> <PackageReference Include="MaterialDesignExtensions" Version="4.0.0-a02" />
<PackageReference Include="MaterialDesignThemes" Version="4.9.0" /> <PackageReference Include="MaterialDesignThemes" Version="4.9.0" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.77" /> <PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.122" />
<PackageReference Include="NLog" Version="5.2.8" /> <PackageReference Include="NLog" Version="5.3.3" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" /> <PackageReference Include="NLog.Extensions.Logging" Version="5.3.12" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@@ -1,6 +1,4 @@
using System.Windows.Controls; namespace NebulaAuth.View.Dialogs
namespace NebulaAuth.View.Dialogs
{ {
/// <summary> /// <summary>
/// Логика взаимодействия для LoginAgainDialog.xaml /// Логика взаимодействия для LoginAgainDialog.xaml
+1 -14
View File
@@ -1,17 +1,4 @@
using System; using System.Windows.Controls;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace NebulaAuth.View namespace NebulaAuth.View
{ {
+12 -8
View File
@@ -1,8 +1,10 @@
using CommunityToolkit.Mvvm.ComponentModel; using System;
using CommunityToolkit.Mvvm.ComponentModel;
using SteamLib.SteamMobile; using SteamLib.SteamMobile;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Threading; using System.Threading;
using System.Windows; using System.Windows;
using System.Windows.Threading;
namespace NebulaAuth.ViewModel; namespace NebulaAuth.ViewModel;
@@ -14,30 +16,32 @@ public partial class MainVM
[MemberNotNull(nameof(_codeTimer))] [MemberNotNull(nameof(_codeTimer))]
[MemberNotNull(nameof(_code))]
private void CreateCodeTimer() private void CreateCodeTimer()
{ {
var currentTime = TimeAligner.GetSteamTime();
_codeTimer = new Timer(UpdateCode, null, 0, 1000); _codeTimer = new Timer(UpdateCode, null, 0, 1000);
} }
private void UpdateCode(object? state = null) private void UpdateCode(object? state = null)
{ {
var currentTime = TimeAligner.GetSteamTime(); var currentTime = TimeAligner.GetSteamTime();
var untilChange = currentTime - currentTime / 30L * 30L; var untilChange = currentTime - currentTime / 30L * 30L;
var codeProgress = untilChange / 30D * 100; var codeProgress = untilChange / 30D * 100;
string? code = null; string? code = null;
if (untilChange == 0 && SelectedMafile != null) if (untilChange == 0 && SelectedMafile != null)
{ {
code = SteamGuardCodeGenerator.GenerateCode(SelectedMafile!.SharedSecret); code = SteamGuardCodeGenerator.GenerateCode(SelectedMafile!.SharedSecret);
} }
if(Application.Current == null) return;
Application.Current.Dispatcher.BeginInvoke(() => if (Application.Current == null) return;
Application.Current.Dispatcher.Invoke((string? c) =>
{ {
if (Application.Current.MainWindow?.WindowState == WindowState.Minimized) return;
CodeProgress = codeProgress; CodeProgress = codeProgress;
if (code != null) Code = code; if (c != null) Code = c;
}); }, DispatcherPriority.Background, code);
} }
} }
-1
View File
@@ -5,7 +5,6 @@ using NebulaAuth.Model.Entities;
using System; using System;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
namespace NebulaAuth.ViewModel; namespace NebulaAuth.ViewModel;
@@ -6,7 +6,6 @@ using MaterialDesignThemes.Wpf;
using NebulaAuth.Model; using NebulaAuth.Model;
using NebulaAuth.Model.Entities; using NebulaAuth.Model.Entities;
using NebulaAuth.Utility; using NebulaAuth.Utility;
using Newtonsoft.Json;
using NLog; using NLog;
using SteamLib; using SteamLib;
using SteamLib.Account; using SteamLib.Account;
@@ -26,7 +25,6 @@ using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using NebulaAuth.Core; using NebulaAuth.Core;
using SteamLib.Utility.MaFiles;
namespace NebulaAuth.ViewModel.Other; namespace NebulaAuth.ViewModel.Other;
@@ -2,7 +2,6 @@
using NebulaAuth.Model.Entities; using NebulaAuth.Model.Entities;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Windows.Forms;
using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Input;
namespace NebulaAuth.ViewModel.Other; namespace NebulaAuth.ViewModel.Other;
+1 -6
View File
@@ -1,9 +1,4 @@
using System.Collections.Generic; using CommunityToolkit.Mvvm.ComponentModel;
using System.Collections.ObjectModel;
using System.Linq;
using CommunityToolkit.Mvvm.ComponentModel;
using NebulaAuth.Model;
using NebulaAuth.Model.Entities;
namespace NebulaAuth.ViewModel.Other; namespace NebulaAuth.ViewModel.Other;
+2 -2
View File
@@ -21,7 +21,7 @@ public partial class ProxyManagerVM : ObservableObject
[ObservableProperty] private KeyValuePair<int, ProxyData>? _defaultProxy; [ObservableProperty] private KeyValuePair<int, ProxyData>? _defaultProxy;
public ObservableDictionary<int, ProxyData> Proxies => ProxyStorage.Proxies; public ObservableDictionary<int, ProxyData> Proxies => ProxyStorage.Proxies;
private static readonly Regex IdRegex = new(@"\{(\d+)\}$"); private static readonly Regex IdRegex = new(@"\{(\d+)\}$", RegexOptions.Compiled);
public ProxyManagerVM() public ProxyManagerVM()
@@ -77,7 +77,7 @@ public partial class ProxyManagerVM : ObservableObject
SnackbarController.SendSnackbar(string.Format(GetLocalizationOrDefault("DuplicateId"), id)); SnackbarController.SendSnackbar(string.Format(GetLocalizationOrDefault("DuplicateId"), id));
return; return;
} }
proxies.Add(new KeyValuePair<int?, ProxyData>(id, proxy)); proxies.Add(KeyValuePair.Create(id, proxy));
} }
else else
{ {
-1
View File
@@ -1,6 +1,5 @@
using AutoUpdaterDotNET; using AutoUpdaterDotNET;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using Microsoft.VisualBasic.FileIO;
namespace NebulaAuth.ViewModel.Other; namespace NebulaAuth.ViewModel.Other;
@@ -44,10 +44,8 @@ public class SteamGuardCodeGenerator : ISteamGuardProvider
time >>= 8; time >>= 8;
} }
HMACSHA1 hmacGenerator = new() using HMACSHA1 hmacGenerator = new();
{ hmacGenerator.Key = sharedSecret;
Key = sharedSecret
};
var hashedData = hmacGenerator.ComputeHash(timeArray); var hashedData = hmacGenerator.ComputeHash(timeArray);
var codeArray = new byte[5]; var codeArray = new byte[5];
+1 -3
View File
@@ -46,9 +46,8 @@ public static class TimeAligner
var req = new HttpRequestMessage(HttpMethod.Post, SteamConstants.STEAM_API + TIME_ALIGN_ENDPOINT); var req = new HttpRequestMessage(HttpMethod.Post, SteamConstants.STEAM_API + TIME_ALIGN_ENDPOINT);
var response = client.Send(req).EnsureSuccessStatusCode(); var response = client.Send(req).EnsureSuccessStatusCode();
sw.Stop(); sw.Stop();
var stream = new StreamReader(response.Content.ReadAsStream()); using var stream = new StreamReader(response.Content.ReadAsStream());
var respStr = stream.ReadToEnd(); var respStr = stream.ReadToEnd();
stream.Dispose();
var j = JObject.Parse(respStr); var j = JObject.Parse(respStr);
var time = j["response"]!["server_time"]!.Value<long>(); var time = j["response"]!["server_time"]!.Value<long>();
var now = UtcNow - sw.Elapsed; var now = UtcNow - sw.Elapsed;
@@ -80,7 +79,6 @@ public static class TimeAligner
} }
finally finally
{ {
sw.Stop();
client.Dispose(); client.Dispose();
} }
} }