From 850393ab7184ca3e588a38ebbd6098d1293a417d Mon Sep 17 00:00:00 2001 From: ChsBuffer <33744752+chsbuffer@users.noreply.github.com> Date: Sun, 15 Nov 2020 00:38:29 +0800 Subject: [PATCH] refactor: TestFakeDNS --- Netch/Controllers/TUNTAPController.cs | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/Netch/Controllers/TUNTAPController.cs b/Netch/Controllers/TUNTAPController.cs index 44aba0c770..63d32c2110 100644 --- a/Netch/Controllers/TUNTAPController.cs +++ b/Netch/Controllers/TUNTAPController.cs @@ -228,33 +228,11 @@ private bool ClearRouteTable() public bool TestFakeDNS() { - var exited = false; - var helpStr = new StringBuilder(); try { - void OnOutputDataReceived(object sender, DataReceivedEventArgs e) - { - if (e.Data == null) - { - exited = true; - return; - } - - helpStr.Append(e.Data); - } - InitInstance("-h"); - // Instance.OutputDataReceived += OnOutputDataReceived; - Instance.ErrorDataReceived += OnOutputDataReceived; Instance.Start(); - Instance.BeginOutputReadLine(); - Instance.BeginErrorReadLine(); - while (!exited) - { - Thread.Sleep(200); - } - - return helpStr.ToString().Contains("-fakeDns"); + return Instance.StandardError.ReadToEnd().Contains("-fakeDns"); } catch {