diff --git a/src/ST.Client.Desktop/Serialization/FileSettingsProvider.cs b/src/ST.Client.Desktop/Serialization/FileSettingsProvider.cs index 3395a81a8..fcbc5ba08 100644 --- a/src/ST.Client.Desktop/Serialization/FileSettingsProvider.cs +++ b/src/ST.Client.Desktop/Serialization/FileSettingsProvider.cs @@ -62,7 +62,7 @@ namespace System.Application.Serialization lock (_sync) { - using var stream = new FileStream(_path, FileMode.Create, FileAccess.ReadWrite); + using var stream = new FileStream(_path, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite | FileShare.Delete); if (stream.Position > 0) { stream.Position = 0; @@ -77,7 +77,7 @@ namespace System.Application.Serialization { if (File.Exists(_path)) { - using var stream = new FileStream(_path, FileMode.Open, FileAccess.Read); + using var stream = new FileStream(_path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete); lock (_sync) { if (stream.Position > 0) diff --git a/src/ST.Client.Desktop/Services/Implementation/HostsFileServiceImpl.cs b/src/ST.Client.Desktop/Services/Implementation/HostsFileServiceImpl.cs index e8f304cfe..77e230614 100644 --- a/src/ST.Client.Desktop/Services/Implementation/HostsFileServiceImpl.cs +++ b/src/ST.Client.Desktop/Services/Implementation/HostsFileServiceImpl.cs @@ -84,42 +84,52 @@ namespace System.Application.Services.Implementation bool checkReadOnly = false, bool checkMaxLength = true) { - message = null; - removeReadOnly = false; - fileInfo = new FileInfo(s.HostsFilePath); - if (!fileInfo.Exists) + try { - //message = "hosts file was not found"; - //return false; - try + message = null; + removeReadOnly = false; + fileInfo = new FileInfo(s.HostsFilePath); + if (!fileInfo.Exists) { - fileInfo.Create().Dispose(); - return true; + //message = "hosts file was not found"; + //return false; + try + { + fileInfo.Create().Dispose(); + return true; + } + catch (Exception ex) + { + message = ex.GetAllMessage(); + return false; + } } - catch (Exception ex) + if (checkMaxLength) { - message = ex.GetAllMessage(); - return false; + if (fileInfo.Length > MaxFileLength) + { + message = "hosts file is too large"; + return false; + } } + if (checkReadOnly) + { + var attr = fileInfo.Attributes; + if (attr.HasFlag(FileAttributes.ReadOnly)) + { + fileInfo.Attributes = attr & ~FileAttributes.ReadOnly; + removeReadOnly = true; + } + } + return true; } - if (checkMaxLength) + catch (Exception ex) { - if (fileInfo.Length > MaxFileLength) - { - message = "hosts file is too large"; - return false; - } + removeReadOnly = false; + fileInfo = new FileInfo(s.HostsFilePath); + message = ex.Message; + return false; } - if (checkReadOnly) - { - var attr = fileInfo.Attributes; - if (attr.HasFlag(FileAttributes.ReadOnly)) - { - fileInfo.Attributes = attr & ~FileAttributes.ReadOnly; - removeReadOnly = true; - } - } - return true; } /// diff --git a/src/ST.Client.Desktop/Services/Implementation/SteamServiceImpl.cs b/src/ST.Client.Desktop/Services/Implementation/SteamServiceImpl.cs index 6ca8cca97..35af2d243 100644 --- a/src/ST.Client.Desktop/Services/Implementation/SteamServiceImpl.cs +++ b/src/ST.Client.Desktop/Services/Implementation/SteamServiceImpl.cs @@ -63,7 +63,7 @@ namespace System.Application.Services.Implementation { get { - return Process.GetProcesses().Any(p => steamProcess.Contains(p.ProcessName, StringComparer.OrdinalIgnoreCase)); + return Process.GetProcessesByName(steamProcess[0])?.Length > 0; } } @@ -74,8 +74,11 @@ namespace System.Application.Services.Implementation { if (steamProcess.Contains(p.ProcessName, StringComparer.OrdinalIgnoreCase)) { - p.Kill(); - p.WaitForExit(); + if (p.HasExited == false) + { + p.Kill(); + p.WaitForExit(); + } } } } diff --git a/src/ST.Client.Desktop/Services/Mvvm/AuthService.cs b/src/ST.Client.Desktop/Services/Mvvm/AuthService.cs index 9e649fa3b..787db7961 100644 --- a/src/ST.Client.Desktop/Services/Mvvm/AuthService.cs +++ b/src/ST.Client.Desktop/Services/Mvvm/AuthService.cs @@ -1,4 +1,4 @@ -using DynamicData; +using DynamicData; using DynamicData.Binding; using Newtonsoft.Json.Linq; using ReactiveUI; @@ -487,14 +487,10 @@ namespace System.Application.Services public void SaveEditNameAuthenticators() { - Task.Run(() => - { - var auths = Authenticators.Items.Where(x => x.Name != x.OriginName); - - foreach (var auth in auths) - AddOrUpdateSaveAuthenticators(auth); - }); + var auths = Authenticators.Items.Where(x => x.Name != x.OriginName); + foreach (var auth in auths) + AddOrUpdateSaveAuthenticators(auth); } } } diff --git a/src/ST.Client/Services/Implementation/HttpProxyServiceImpl.cs b/src/ST.Client/Services/Implementation/HttpProxyServiceImpl.cs index bf9dd4288..a85f033d5 100644 --- a/src/ST.Client/Services/Implementation/HttpProxyServiceImpl.cs +++ b/src/ST.Client/Services/Implementation/HttpProxyServiceImpl.cs @@ -169,6 +169,7 @@ namespace System.Application.Services.Implementation { e.HttpClient.UpStreamEndPoint = new IPEndPoint(ip, item.PortId); } + //e.HttpClient.Request.Host = item.ForwardDomainName ?? e.HttpClient.Request.Host; if (e.HttpClient.ConnectRequest?.ClientHelloInfo?.Extensions != null) { //Logger.Info("ClientHelloInfo Info: " + e.HttpClient.ConnectRequest.ClientHelloInfo);