![]() ![]() Start the server (by default it listens on port 53)ĭepending on the application setup the events might be executed on a different thread than the calling thread. Server.Errored += (sender, e) => Console.WriteLine(e.Exception.Message) Server.Responded += (sender, e) => Console.WriteLine("", e.Request, e.Response) ![]() On every successful request log the request and the response Server.Requested += (sender, e) => Console.WriteLine(e.Request) MasterFile.AddIPAddressResourceRecord("", "127.0.0.1") MasterFile masterFile = new MasterFile() ĭnsServer server = new DnsServer(masterFile, "8.8.8.8") It also emits an event on every request and every successful resolution. You can intercept domain name resolution requests and route them to specified IPs. The DnsServer class exposes a proxy Domain Name Server (UDP only). Get the domain name belonging to the IP () IList ips = await client.Lookup("foo.com") Bind to a Domain Name ServerĭnsClient client = new DnsClient("8.8.8.8") The DnsClient class contains some conveniance methods for creating instances of ClientRequest and resolving domains. Get all the IPs for the foo.com domain (new Question(Domain.FromString("foo.com"), RecordType.AAAA)) ĬlientResponse response = await request.Resolve() Request an IPv6 record for the foo.com domain ClientRequest request = new ClientRequest("8.8.8.8") This behaviour can be changed by supplying an IRequestResolver to the client constructor. The request is first sent using UDP, if that fails (response is truncated), the request is sent again using TCP. ![]() Using the ClientRequest or the DnsClient class it is possible to send a request to a Domain Name Server. The libray also includes a small client and a proxy server. Outputs a human readable representation Response response = Response.FromArray(buffer) UdpReceiveResult result = await udp.ReceiveAsync() IPEndPoint google = new IPEndPoint(IPAddress.Parse("8.8.8.8"), 53) Īwait udp.SendAsync(request.ToArray(), request.Size, google) The library exposes a Request and Response classes for parsing and creating DNS messages. Version two and above use asynchronous operations.Īvailable through NuGet. Versions prior to version two (2.0.0) were written for. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |