mirror of
https://github.com/netchx/netch.git
synced 2026-03-18 18:13:21 +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>
|
||||
|
||||
1
Netch/Forms/SettingForm.Designer.cs
generated
1
Netch/Forms/SettingForm.Designer.cs
generated
@@ -184,6 +184,7 @@
|
||||
this.UseFakeDNSCheckBox.Size = new System.Drawing.Size(110, 21);
|
||||
this.UseFakeDNSCheckBox.TabIndex = 11;
|
||||
this.UseFakeDNSCheckBox.Text = "Use Fake DNS";
|
||||
this.UseFakeDNSCheckBox.Visible = false;
|
||||
this.UseFakeDNSCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// ProxyDNSCheckBox
|
||||
|
||||
@@ -122,6 +122,7 @@ namespace Netch.Forms
|
||||
|
||||
private void SettingForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
UseFakeDNSCheckBox.Visible = Global.SupportFakeDns;
|
||||
InitText();
|
||||
InitValue();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ namespace Netch
|
||||
/// </summary>
|
||||
public static MainForm MainForm;
|
||||
|
||||
public static bool SupportFakeDns = false;
|
||||
|
||||
/// <summary>
|
||||
/// SS/SSR 加密方式
|
||||
/// </summary>
|
||||
|
||||
@@ -67,9 +67,16 @@ namespace Netch
|
||||
}
|
||||
|
||||
Logging.Info($"版本: {UpdateChecker.Owner}/{UpdateChecker.Repo}@{UpdateChecker.Version}");
|
||||
Task.Run(() => { Logging.Info($"主程序 SHA256: {Utils.Utils.SHA256CheckSum(Application.ExecutablePath)}"); });
|
||||
Logging.Info("启动单实例");
|
||||
Task.Run(OnlyInstance.Server);
|
||||
Task.Run(() =>
|
||||
{
|
||||
Logging.Info($"主程序 SHA256: {Utils.Utils.SHA256CheckSum(Application.ExecutablePath)}");
|
||||
});
|
||||
Task.Run(() =>
|
||||
{
|
||||
Logging.Info("启动单实例");
|
||||
OnlyInstance.Server();
|
||||
});
|
||||
Task.Run(() => { Global.SupportFakeDns = new TUNTAPController().TestFakeDNS(); });
|
||||
|
||||
// 绑定错误捕获
|
||||
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
|
||||
|
||||
Reference in New Issue
Block a user