Browse Source

Fix with AppendQuotes

pull/6093/head
2dust 5 days ago
parent
commit
e335b2c0d6
  1. 5
      v2rayN/ServiceLib/Handler/CoreHandler.cs
  2. 2
      v2rayN/ServiceLib/Handler/CoreInfoHandler.cs
  3. 11
      v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs

5
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 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 configPath = Utils.GetConfigPath(Global.CoreSpeedtestConfigFileName);
var result = await CoreConfigHandler.GenerateClientSpeedtestConfig(_config, configPath, selecteds, coreType); var result = await CoreConfigHandler.GenerateClientSpeedtestConfig(_config, configPath, selecteds, coreType);
ShowMsg(false, result.Msg); ShowMsg(false, result.Msg);
if (result.Success) if (result.Success)
{ {
ShowMsg(false, string.Format(ResUI.StartService, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"))); ShowMsg(false, string.Format(ResUI.StartService, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")));
@ -297,10 +297,11 @@ namespace ServiceLib.Handler
if (isNeedSudo) if (isNeedSudo)
{ {
proc.StartInfo.FileName = $"/bin/sudo"; 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.WorkingDirectory = null;
proc.StartInfo.StandardInputEncoding = Encoding.UTF8; proc.StartInfo.StandardInputEncoding = Encoding.UTF8;
proc.StartInfo.RedirectStandardInput = true; proc.StartInfo.RedirectStandardInput = true;
Logging.SaveLog(proc.StartInfo.Arguments);
} }
var startUpErrorMessage = new StringBuilder(); var startUpErrorMessage = new StringBuilder();

2
v2rayN/ServiceLib/Handler/CoreInfoHandler.cs

@ -165,7 +165,7 @@
private string PortableMode() private string PortableMode()
{ {
return $" -d \"{Utils.GetBinPath("")}\""; return $" -d {Utils.GetBinPath("").AppendQuotes()}";
} }
} }
} }

11
v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs

@ -1024,18 +1024,17 @@ namespace ServiceLib.Services.CoreConfig
//request Host //request Host
string request = Utils.GetEmbedText(Global.V2raySampleHttpRequestFileName); string request = Utils.GetEmbedText(Global.V2raySampleHttpRequestFileName);
string[] arrHost = host.Split(','); string[] arrHost = host.Split(',');
string host2 = string.Join("\",\"", arrHost); string host2 = string.Join(",".AppendQuotes(), arrHost);
request = request.Replace("$requestHost$", $"\"{host2}\""); request = request.Replace("$requestHost$", $"{host2.AppendQuotes()}");
//request = request.Replace("$requestHost$", string.Format("\"{0}\"", config.requestHost())); request = request.Replace("$requestUserAgent$", $"{useragent.AppendQuotes()}");
request = request.Replace("$requestUserAgent$", $"\"{useragent}\"");
//Path //Path
string pathHttp = @"/"; string pathHttp = @"/";
if (Utils.IsNotEmpty(node.Path)) if (Utils.IsNotEmpty(node.Path))
{ {
string[] arrPath = node.Path.Split(','); 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<object>(request); tcpSettings.header.request = JsonUtils.Deserialize<object>(request);
streamSettings.tcpSettings = tcpSettings; streamSettings.tcpSettings = tcpSettings;

Loading…
Cancel
Save