diff --git a/v2rayN/ServiceLib/Handler/CoreHandler.cs b/v2rayN/ServiceLib/Handler/CoreHandler.cs index 0940b14ec9..e181eb30cc 100644 --- a/v2rayN/ServiceLib/Handler/CoreHandler.cs +++ b/v2rayN/ServiceLib/Handler/CoreHandler.cs @@ -99,7 +99,7 @@ public async Task LoadCoreConfigSpeedtest(List selecteds) 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 @@ private bool IsNeedSudo(ECoreType eCoreType) 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 aeb5e57d84..5b8fa6063e 100644 --- a/v2rayN/ServiceLib/Handler/CoreInfoHandler.cs +++ b/v2rayN/ServiceLib/Handler/CoreInfoHandler.cs @@ -165,7 +165,7 @@ private void InitCoreInfo() 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 d8f787e896..885986dac5 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs @@ -1024,18 +1024,17 @@ public async Task GenBoundStreamSettings(ProfileItem node, StreamSettings4R //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;