replace unbound dns with aiodns

This commit is contained in:
ChsBuffer
2020-09-18 20:41:21 +08:00
parent 76aa32967f
commit e8c1bcb74b
5 changed files with 58 additions and 31 deletions

View File

@@ -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
}
}