mirror of
https://github.com/netchx/netch.git
synced 2026-05-11 23:45:06 +08:00
replace unbound dns with aiodns
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
namespace Netch.Controllers
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Netch.Controllers
|
||||
{
|
||||
public class DNSController : Controller
|
||||
{
|
||||
public DNSController()
|
||||
{
|
||||
Name = "DNS Service";
|
||||
MainFile = "unbound.exe";
|
||||
// RedirectStd = false;
|
||||
RedirectStd = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -15,12 +18,31 @@
|
||||
/// <returns></returns>
|
||||
public bool Start()
|
||||
{
|
||||
return StartInstanceAuto("-c unbound-service.conf -v");
|
||||
if (!aiodns_dial(Encoding.UTF8.GetBytes(Path.GetFullPath("bin\\china_site_list")),
|
||||
Encoding.UTF8.GetBytes("223.5.5.5:53"),
|
||||
Encoding.UTF8.GetBytes("1.1.1.1:53"))
|
||||
)
|
||||
return false;
|
||||
return
|
||||
aiodns_init();
|
||||
}
|
||||
|
||||
public override void Stop()
|
||||
{
|
||||
StopInstance();
|
||||
aiodns_free();
|
||||
}
|
||||
|
||||
#region NativeMethods
|
||||
|
||||
[DllImport("aiodns.bin", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool aiodns_dial(byte[] chinacon, byte[] chinadns, byte[] otherdns);
|
||||
|
||||
[DllImport("aiodns.bin", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool aiodns_init();
|
||||
|
||||
[DllImport("aiodns.bin", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void aiodns_free();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user