using System.Net; using DNS.Client.RequestResolver; using DNS.Protocol; using DNS.Protocol.ResourceRecords; public class RequestResolver : IRequestResolver { public RequestResolver(LiteDB.ILiteCollection db) { _db=db; } LiteDB.ILiteCollection _db; public Task Resolve(IRequest request,CancellationToken token) { IResponse response = Response.FromRequest(request); foreach (Question question in response.Questions) { var res= DNSEntry.GetDNSEntry(_db.FindAll(),question); if(res != null) { response.AnswerRecords.Add(res); } } return Task.FromResult(response); } } // All dns requests received will be handled by the localhost request resolver