From 4909a557d5378c69cb3e27a4202c423d539661e2 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Mon, 9 Jan 2023 19:39:45 +0800 Subject: [PATCH] Revert "Change the way to call the core in the speed test" This reverts commit dd85ccd3f88969e11931f5454ced40d75e8a14fd. --- v2rayN/v2rayN/Handler/CoreHandler.cs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/v2rayN/v2rayN/Handler/CoreHandler.cs b/v2rayN/v2rayN/Handler/CoreHandler.cs index b284a189..f07b39fc 100644 --- a/v2rayN/v2rayN/Handler/CoreHandler.cs +++ b/v2rayN/v2rayN/Handler/CoreHandler.cs @@ -228,21 +228,15 @@ namespace v2rayN.Handler string fileName = CoreFindexe(coreInfo); if (fileName == "") return -1; - var pathTemp = Utils.GetConfigPath($"temp_{Utils.GetGUID(false)}.json"); - File.WriteAllText(pathTemp, configStr); - if (!File.Exists(pathTemp)) - { - return -1; - } - Process p = new Process { StartInfo = new ProcessStartInfo { FileName = fileName, - Arguments = $"-config \"{pathTemp}\"", + Arguments = "-config stdin:", WorkingDirectory = Utils.GetConfigPath(), UseShellExecute = false, + RedirectStandardInput = true, RedirectStandardOutput = true, RedirectStandardError = true, CreateNoWindow = true, @@ -261,16 +255,15 @@ namespace v2rayN.Handler p.Start(); p.BeginOutputReadLine(); + p.StandardInput.Write(configStr); + p.StandardInput.Close(); + if (p.WaitForExit(1000)) { throw new Exception(p.StandardError.ReadToEnd()); } Global.processJob.AddProcess(p.Handle); - - Thread.Sleep(1000); - File.Delete(pathTemp); - return p.Id; } catch (Exception ex)