mirror of
https://github.com/netchx/netch.git
synced 2026-03-28 18:59:46 +08:00
:ambulance:恢复本地DNS服务
This commit is contained in:
37
Netch/Controllers/DNSController.cs
Normal file
37
Netch/Controllers/DNSController.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
|
||||
namespace Netch.Controllers
|
||||
{
|
||||
public class DNSController
|
||||
{
|
||||
public static DNS.Server.DnsServer Server = new DNS.Server.DnsServer(new Resolver());
|
||||
|
||||
public bool Start()
|
||||
{
|
||||
try
|
||||
{
|
||||
_ = Server.Listen(new IPEndPoint(IPAddress.IPv6Any, 53));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.Logging.Info(e.ToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
try
|
||||
{
|
||||
Server.Dispose();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.Logging.Info(e.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,11 @@ namespace Netch.Controllers
|
||||
public Models.Server SavedServer = new Models.Server();
|
||||
public Models.Mode SavedMode = new Models.Mode();
|
||||
|
||||
/// <summary>
|
||||
/// 本地 DNS 服务控制器
|
||||
/// </summary>
|
||||
public DNSController pDNSController = new DNSController();
|
||||
|
||||
/// <summary>
|
||||
/// 配置 TUNTAP 适配器
|
||||
/// </summary>
|
||||
@@ -292,7 +297,9 @@ namespace Netch.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
dns = "1.1.1.1,1.0.0.1";
|
||||
pDNSController.Start();
|
||||
dns = "127.0.0.1";
|
||||
//dns = "1.1.1.1,1.0.0.1";
|
||||
}
|
||||
|
||||
if (server.Type == "Socks5")
|
||||
|
||||
Reference in New Issue
Block a user