mirror of
https://github.com/netchx/netch.git
synced 2026-05-07 22:44:03 +08:00
Check whether tun2socks supports fakeDNS
This commit is contained in:
@@ -237,7 +237,7 @@ namespace Netch.Controllers
|
||||
argument.Append(
|
||||
$"-tunAddr {Global.Settings.TUNTAP.Address} -tunMask {Global.Settings.TUNTAP.Netmask} -tunGw {Global.Settings.TUNTAP.Gateway} -tunDns {dns} -tunName \"{adapterName}\" ");
|
||||
|
||||
if (Global.Settings.TUNTAP.UseFakeDNS)
|
||||
if (Global.Settings.TUNTAP.UseFakeDNS && Global.SupportFakeDns)
|
||||
argument.Append("-fakeDns ");
|
||||
|
||||
return StartInstanceAuto(argument.ToString(), ProcessPriorityClass.RealTime);
|
||||
@@ -257,6 +257,40 @@ namespace Netch.Controllers
|
||||
Task.WaitAll(tasks);
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 搜索出口和TUNTAP适配器
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user