mirror of
https://github.com/achiez/NebulaAuth-Steam-Desktop-Authenticator-by-Achies.git
synced 2026-07-25 06:14:31 +00:00
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:
@@ -5,7 +5,6 @@ using NebulaAuth.Model.Entities;
|
||||
using NebulaAuth.View;
|
||||
using NebulaAuth.View.Dialogs;
|
||||
using NebulaAuth.ViewModel.Other;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
|
||||
|
||||
namespace NebulaAuth.Core;
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ using SteamLib.Utility.MaFiles;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.DirectoryServices.ActiveDirectory;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
|
||||
@@ -19,17 +19,17 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Autoupdater.NET.Official" Version="1.8.5" />
|
||||
<PackageReference Include="CodingSeb.Localization.JsonFileLoader" Version="1.3.0" />
|
||||
<PackageReference Include="CodingSeb.Localization.WPF" Version="1.3.0" />
|
||||
<PackageReference Include="CodingSebLocalization.Fody" Version="1.3.0" />
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
||||
<PackageReference Include="Autoupdater.NET.Official" Version="1.9.2" />
|
||||
<PackageReference Include="CodingSeb.Localization.JsonFileLoader" Version="1.3.1" />
|
||||
<PackageReference Include="CodingSeb.Localization.WPF" Version="1.3.3" />
|
||||
<PackageReference Include="CodingSebLocalization.Fody" Version="1.3.1" />
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.0" />
|
||||
<PackageReference Include="MaterialDesignColors" Version="2.1.4" />
|
||||
<PackageReference Include="MaterialDesignExtensions" Version="4.0.0-a02" />
|
||||
<PackageReference Include="MaterialDesignThemes" Version="4.9.0" />
|
||||
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.77" />
|
||||
<PackageReference Include="NLog" Version="5.2.8" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
|
||||
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.122" />
|
||||
<PackageReference Include="NLog" Version="5.3.3" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.12" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace NebulaAuth.View.Dialogs
|
||||
namespace NebulaAuth.View.Dialogs
|
||||
{
|
||||
/// <summary>
|
||||
/// Логика взаимодействия для LoginAgainDialog.xaml
|
||||
|
||||
@@ -1,17 +1,4 @@
|
||||
using System;
|
||||
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;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace NebulaAuth.View
|
||||
{
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using SteamLib.SteamMobile;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace NebulaAuth.ViewModel;
|
||||
|
||||
@@ -14,30 +16,32 @@ public partial class MainVM
|
||||
|
||||
|
||||
[MemberNotNull(nameof(_codeTimer))]
|
||||
[MemberNotNull(nameof(_code))]
|
||||
private void CreateCodeTimer()
|
||||
{
|
||||
var currentTime = TimeAligner.GetSteamTime();
|
||||
_codeTimer = new Timer(UpdateCode, null, 0, 1000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void UpdateCode(object? state = null)
|
||||
{
|
||||
var currentTime = TimeAligner.GetSteamTime();
|
||||
var untilChange = currentTime - currentTime / 30L * 30L;
|
||||
var codeProgress = untilChange / 30D * 100;
|
||||
|
||||
|
||||
string? code = null;
|
||||
if (untilChange == 0 && SelectedMafile != null)
|
||||
{
|
||||
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;
|
||||
if (code != null) Code = code;
|
||||
});
|
||||
if (c != null) Code = c;
|
||||
}, DispatcherPriority.Background, code);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ using NebulaAuth.Model.Entities;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NebulaAuth.ViewModel;
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ using MaterialDesignThemes.Wpf;
|
||||
using NebulaAuth.Model;
|
||||
using NebulaAuth.Model.Entities;
|
||||
using NebulaAuth.Utility;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using SteamLib;
|
||||
using SteamLib.Account;
|
||||
@@ -26,7 +25,6 @@ using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using NebulaAuth.Core;
|
||||
using SteamLib.Utility.MaFiles;
|
||||
|
||||
namespace NebulaAuth.ViewModel.Other;
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using NebulaAuth.Model.Entities;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows.Forms;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
namespace NebulaAuth.ViewModel.Other;
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using NebulaAuth.Model;
|
||||
using NebulaAuth.Model.Entities;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace NebulaAuth.ViewModel.Other;
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public partial class ProxyManagerVM : ObservableObject
|
||||
[ObservableProperty] private KeyValuePair<int, ProxyData>? _defaultProxy;
|
||||
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()
|
||||
@@ -77,7 +77,7 @@ public partial class ProxyManagerVM : ObservableObject
|
||||
SnackbarController.SendSnackbar(string.Format(GetLocalizationOrDefault("DuplicateId"), id));
|
||||
return;
|
||||
}
|
||||
proxies.Add(new KeyValuePair<int?, ProxyData>(id, proxy));
|
||||
proxies.Add(KeyValuePair.Create(id, proxy));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using AutoUpdaterDotNET;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Microsoft.VisualBasic.FileIO;
|
||||
|
||||
namespace NebulaAuth.ViewModel.Other;
|
||||
|
||||
|
||||
@@ -44,10 +44,8 @@ public class SteamGuardCodeGenerator : ISteamGuardProvider
|
||||
time >>= 8;
|
||||
}
|
||||
|
||||
HMACSHA1 hmacGenerator = new()
|
||||
{
|
||||
Key = sharedSecret
|
||||
};
|
||||
using HMACSHA1 hmacGenerator = new();
|
||||
hmacGenerator.Key = sharedSecret;
|
||||
var hashedData = hmacGenerator.ComputeHash(timeArray);
|
||||
var codeArray = new byte[5];
|
||||
|
||||
|
||||
@@ -46,9 +46,8 @@ public static class TimeAligner
|
||||
var req = new HttpRequestMessage(HttpMethod.Post, SteamConstants.STEAM_API + TIME_ALIGN_ENDPOINT);
|
||||
var response = client.Send(req).EnsureSuccessStatusCode();
|
||||
sw.Stop();
|
||||
var stream = new StreamReader(response.Content.ReadAsStream());
|
||||
using var stream = new StreamReader(response.Content.ReadAsStream());
|
||||
var respStr = stream.ReadToEnd();
|
||||
stream.Dispose();
|
||||
var j = JObject.Parse(respStr);
|
||||
var time = j["response"]!["server_time"]!.Value<long>();
|
||||
var now = UtcNow - sw.Elapsed;
|
||||
@@ -80,7 +79,6 @@ public static class TimeAligner
|
||||
}
|
||||
finally
|
||||
{
|
||||
sw.Stop();
|
||||
client.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user