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] 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;