From 96ae5517f6b209e18fca639d3af2f47388b8d6ec Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sun, 17 Nov 2024 09:58:57 +0800 Subject: [PATCH 1/4] Improve core msg --- v2rayN/ServiceLib/Handler/CoreHandler.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/v2rayN/ServiceLib/Handler/CoreHandler.cs b/v2rayN/ServiceLib/Handler/CoreHandler.cs index 6ebb80e8..0940b14e 100644 --- a/v2rayN/ServiceLib/Handler/CoreHandler.cs +++ b/v2rayN/ServiceLib/Handler/CoreHandler.cs @@ -59,14 +59,16 @@ namespace ServiceLib.Handler var fileName = Utils.GetConfigPath(Global.CoreConfigFileName); var result = await CoreConfigHandler.GenerateClientConfig(node, fileName); - ShowMsg(true, result.Msg); if (result.Success != true) { + ShowMsg(true, result.Msg); return; } else { ShowMsg(true, $"{node.GetSummary()}"); + ShowMsg(false, $"{Environment.OSVersion} - {(Environment.Is64BitOperatingSystem ? 64 : 32)}"); + ShowMsg(false, string.Format(ResUI.StartService, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"))); await CoreStop(); await Task.Delay(100); await CoreStart(node); @@ -97,9 +99,11 @@ namespace ServiceLib.Handler var coreType = selecteds.Exists(t => t.ConfigType is EConfigType.Hysteria2 or EConfigType.TUIC or EConfigType.WireGuard) ? ECoreType.sing_box : ECoreType.Xray; var configPath = Utils.GetConfigPath(Global.CoreSpeedtestConfigFileName); var result = await CoreConfigHandler.GenerateClientSpeedtestConfig(_config, configPath, selecteds, coreType); - ShowMsg(false, result.Msg); + ShowMsg(false, result.Msg); if (result.Success) { + ShowMsg(false, string.Format(ResUI.StartService, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"))); + ShowMsg(false, configPath); pid = await CoreStartSpeedtest(configPath, coreType); } return pid; @@ -167,9 +171,6 @@ namespace ServiceLib.Handler private async Task CoreStart(ProfileItem node) { - ShowMsg(false, $"{Environment.OSVersion} - {(Environment.Is64BitOperatingSystem ? 64 : 32)}"); - ShowMsg(false, string.Format(ResUI.StartService, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"))); - var coreType = AppHandler.Instance.GetCoreType(node, node.ConfigType); _config.RunningCoreType = coreType; var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(coreType); @@ -229,9 +230,6 @@ namespace ServiceLib.Handler private async Task CoreStartSpeedtest(string configPath, ECoreType coreType) { - ShowMsg(false, string.Format(ResUI.StartService, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"))); - - ShowMsg(false, configPath); try { var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(coreType); From e335b2c0d642d7d9515669a9d35df3b56c075a9b Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sun, 17 Nov 2024 14:11:17 +0800 Subject: [PATCH 2/4] Fix with AppendQuotes --- v2rayN/ServiceLib/Handler/CoreHandler.cs | 5 +++-- v2rayN/ServiceLib/Handler/CoreInfoHandler.cs | 2 +- .../Services/CoreConfig/CoreConfigV2rayService.cs | 11 +++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/v2rayN/ServiceLib/Handler/CoreHandler.cs b/v2rayN/ServiceLib/Handler/CoreHandler.cs index 0940b14e..e181eb30 100644 --- a/v2rayN/ServiceLib/Handler/CoreHandler.cs +++ b/v2rayN/ServiceLib/Handler/CoreHandler.cs @@ -99,7 +99,7 @@ namespace ServiceLib.Handler var coreType = selecteds.Exists(t => t.ConfigType is EConfigType.Hysteria2 or EConfigType.TUIC or EConfigType.WireGuard) ? ECoreType.sing_box : ECoreType.Xray; var configPath = Utils.GetConfigPath(Global.CoreSpeedtestConfigFileName); var result = await CoreConfigHandler.GenerateClientSpeedtestConfig(_config, configPath, selecteds, coreType); - ShowMsg(false, result.Msg); + ShowMsg(false, result.Msg); if (result.Success) { ShowMsg(false, string.Format(ResUI.StartService, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"))); @@ -297,10 +297,11 @@ namespace ServiceLib.Handler if (isNeedSudo) { proc.StartInfo.FileName = $"/bin/sudo"; - proc.StartInfo.Arguments = $"-S {fileName} {string.Format(coreInfo.Arguments, Utils.GetConfigPath(configPath))}"; + proc.StartInfo.Arguments = $"-S {fileName.AppendQuotes()} {string.Format(coreInfo.Arguments, Utils.GetConfigPath(configPath).AppendQuotes())}"; proc.StartInfo.WorkingDirectory = null; proc.StartInfo.StandardInputEncoding = Encoding.UTF8; proc.StartInfo.RedirectStandardInput = true; + Logging.SaveLog(proc.StartInfo.Arguments); } var startUpErrorMessage = new StringBuilder(); diff --git a/v2rayN/ServiceLib/Handler/CoreInfoHandler.cs b/v2rayN/ServiceLib/Handler/CoreInfoHandler.cs index aeb5e57d..5b8fa606 100644 --- a/v2rayN/ServiceLib/Handler/CoreInfoHandler.cs +++ b/v2rayN/ServiceLib/Handler/CoreInfoHandler.cs @@ -165,7 +165,7 @@ private string PortableMode() { - return $" -d \"{Utils.GetBinPath("")}\""; + return $" -d {Utils.GetBinPath("").AppendQuotes()}"; } } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs index d8f787e8..885986da 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs @@ -1024,18 +1024,17 @@ namespace ServiceLib.Services.CoreConfig //request Host string request = Utils.GetEmbedText(Global.V2raySampleHttpRequestFileName); string[] arrHost = host.Split(','); - string host2 = string.Join("\",\"", arrHost); - request = request.Replace("$requestHost$", $"\"{host2}\""); - //request = request.Replace("$requestHost$", string.Format("\"{0}\"", config.requestHost())); - request = request.Replace("$requestUserAgent$", $"\"{useragent}\""); + string host2 = string.Join(",".AppendQuotes(), arrHost); + request = request.Replace("$requestHost$", $"{host2.AppendQuotes()}"); + request = request.Replace("$requestUserAgent$", $"{useragent.AppendQuotes()}"); //Path string pathHttp = @"/"; if (Utils.IsNotEmpty(node.Path)) { string[] arrPath = node.Path.Split(','); - pathHttp = string.Join("\",\"", arrPath); + pathHttp = string.Join(",".AppendQuotes(), arrPath); } - request = request.Replace("$requestPath$", $"\"{pathHttp}\""); + request = request.Replace("$requestPath$", $"{pathHttp.AppendQuotes()}"); tcpSettings.header.request = JsonUtils.Deserialize(request); streamSettings.tcpSettings = tcpSettings; From 736d995d4c6ccdacebdebbfbab76bd25789be7ec Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sun, 17 Nov 2024 14:11:51 +0800 Subject: [PATCH 3/4] up PackageReference --- .../v2rayN.Desktop/Views/CheckUpdateView.axaml | 2 +- v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml | 1 + v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj | 16 ++++++++-------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/v2rayN/v2rayN.Desktop/Views/CheckUpdateView.axaml b/v2rayN/v2rayN.Desktop/Views/CheckUpdateView.axaml index 8ccd0f07..0138fe7a 100644 --- a/v2rayN/v2rayN.Desktop/Views/CheckUpdateView.axaml +++ b/v2rayN/v2rayN.Desktop/Views/CheckUpdateView.axaml @@ -50,7 +50,7 @@ diff --git a/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml b/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml index 73265c92..de532782 100644 --- a/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml +++ b/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml @@ -61,6 +61,7 @@ Width="54" Height="30" Margin="20,0" + Padding="2" Classes="Tertiary" Theme="{DynamicResource BorderlessSplitButton}" ToolTip.Tip="{x:Static resx:ResUI.menuProfileAutofitColumnWidth}"> diff --git a/v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj b/v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj index 8ab9c55f..fc743189 100644 --- a/v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj +++ b/v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj @@ -20,16 +20,16 @@ - - - - - - + + + + + + - - + + From 7cf9b9f57e2bd68eb62fda04294019d9bbb19779 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sun, 17 Nov 2024 14:15:37 +0800 Subject: [PATCH 4/4] up 7.1.2 --- v2rayN/ServiceLib/ServiceLib.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v2rayN/ServiceLib/ServiceLib.csproj b/v2rayN/ServiceLib/ServiceLib.csproj index ecd130e6..d2f0c939 100644 --- a/v2rayN/ServiceLib/ServiceLib.csproj +++ b/v2rayN/ServiceLib/ServiceLib.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 7.1.1 + 7.1.2