Skip to content

Commit

Permalink
Fix with AppendQuotes
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Nov 17, 2024
1 parent 96ae551 commit e335b2c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
5 changes: 3 additions & 2 deletions v2rayN/ServiceLib/Handler/CoreHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public async Task<int> LoadCoreConfigSpeedtest(List<ServerTestItem> 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")));
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion v2rayN/ServiceLib/Handler/CoreInfoHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private void InitCoreInfo()

private string PortableMode()
{
return $" -d \"{Utils.GetBinPath("")}\"";
return $" -d {Utils.GetBinPath("").AppendQuotes()}";
}
}
}
11 changes: 5 additions & 6 deletions v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1024,18 +1024,17 @@ public async Task<int> 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<object>(request);

streamSettings.tcpSettings = tcpSettings;
Expand Down

0 comments on commit e335b2c

Please sign in to comment.