public override DnsDatagram Query(DnsDatagram request, bool serveStaleAndResetExpiry = false, bool findClosestNameServers = false)
        {
            if (findClosestNameServers && _prefetchQuery.Equals(request.Question[0]))
            {
                //return closest name servers so that the recursive resolver queries them to refreshes cache instead of returning response from cache
                DnsDatagram authResponse = DnsApplicationQueryClosestDelegation(request);
                if (authResponse is null)
                {
                    authResponse = _authZoneManager.QueryClosestDelegation(request);
                }

                DnsDatagram cacheResponse = _cacheZoneManager.QueryClosestDelegation(request);

                if ((authResponse is not null) && (authResponse.Authority.Count > 0))
                {
                    if ((cacheResponse is not null) && (cacheResponse.Authority.Count > 0))
                    {
                        if (cacheResponse.Authority[0].Name.Length > authResponse.Authority[0].Name.Length)
                        {
                            return(cacheResponse);
                        }
                    }

                    return(authResponse);
                }
                else
                {
                    return(cacheResponse);
                }
            }
        public override DnsDatagram Query(DnsDatagram request, bool serveStale = false)
        {
            if (_prefetchQuery.Equals(request.Question[0]))
            {
                //return closest name servers so that the recursive resolver queries them to refreshes cache instead of returning response from cache
                DnsDatagram authResponse  = _authZoneManager.QueryClosestDelegation(request);
                DnsDatagram cacheResponse = _cacheZoneManager.QueryClosestDelegation(request);

                if ((authResponse.Authority.Count > 0) && (cacheResponse.Authority.Count > 0))
                {
                    if (authResponse.Authority[0].Name.Length >= cacheResponse.Authority[0].Name.Length)
                    {
                        return(authResponse);
                    }

                    return(cacheResponse);
                }
                else if (authResponse.Authority.Count > 0)
                {
                    return(authResponse);
                }
                else
                {
                    return(cacheResponse);
                }
            }

            return(base.Query(request, serveStale));
        }
 public override DnsDatagram Query(DnsDatagram request)
 {
     if (_prefetchQuery.Equals(request.Question[0]))
     {
         return(_cacheZoneRoot.QueryCacheGetClosestNameServers(request)); //return closest name servers so that the recursive resolver queries them to refreshes cache instead of returning response from cache
     }
     return(_cacheZoneRoot.Query(request));
 }
Example #4
0
        public override DnsDatagram Query(DnsDatagram request, bool serveStale = false)
        {
            if (_prefetchQuery.Equals(request.Question[0]))
            {
                //return closest name servers so that the recursive resolver queries them to refreshes cache instead of returning response from cache
                return(_cacheZoneManager.QueryClosestDelegation(request));
            }

            return(base.Query(request, serveStale));
        }
        public override DnsDatagram Query(DnsDatagram request, bool serveStaleAndResetExpiry = false, bool findClosestNameServers = false)
        {
            if (_prefetchQuestion.Equals(request.Question[0]))
            {
                //request is for prefetch question

                if (!findClosestNameServers)
                {
                    return(null); //dont give answer from cache for prefetch question
                }
                //return closest name servers so that the recursive resolver queries them to refreshes cache instead of returning response from cache
                return(QueryClosestDelegation(request));
            }

            return(base.Query(request, serveStaleAndResetExpiry, findClosestNameServers));
        }