-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathProgram.cs
28 lines (21 loc) · 867 Bytes
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using Ae.Dns.Client;
using Ae.Dns.Client.Filters;
using Ae.Dns.Protocol;
using Ae.Dns.Server;
using System.Net;
// Can use the HTTPS, UDP, random or caching clients - any IDnsClient
using IDnsClient dnsClient = new DnsUdpClient(IPAddress.Parse("1.1.1.1"));
// Allow anything that isn't www.google.com
IDnsFilter dnsFilter = new DnsDelegateFilter(x => x.Header.Host != "www.google.com");
using IDnsClient filterClient = new DnsFilterClient(dnsFilter, dnsClient);
// Listen on 127.0.0.1
var serverOptions = new DnsUdpServerOptions
{
Endpoint = new IPEndPoint(IPAddress.Loopback, 53)
};
// Create a "raw" client (efficiently deals with network buffers)
using IDnsRawClient rawClient = new DnsRawClient(filterClient);
// Create the server
using IDnsServer server = new DnsUdpServer(rawClient, serverOptions);
// Listen until cancelled
await server.Listen();