ResolverPrefetchDnsCache: code refactoring changes done.

This commit is contained in:
Shreyas Zare
2025-01-11 17:37:28 +05:30
parent 87c6c54f46
commit 18b3dda6c8

View File

@@ -1,6 +1,6 @@
/* /*
Technitium DNS Server Technitium DNS Server
Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com) Copyright (C) 2025 Shreyas Zare (shreyas@technitium.com)
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System.Threading.Tasks;
using TechnitiumLibrary.Net.Dns; using TechnitiumLibrary.Net.Dns;
namespace DnsServerCore.Dns namespace DnsServerCore.Dns
@@ -41,20 +42,20 @@ namespace DnsServerCore.Dns
#region public #region public
public override DnsDatagram Query(DnsDatagram request, bool serveStale = false, bool findClosestNameServers = false, bool resetExpiry = false) public override Task<DnsDatagram> QueryAsync(DnsDatagram request, bool serveStale = false, bool findClosestNameServers = false, bool resetExpiry = false)
{ {
if (_prefetchQuestion.Equals(request.Question[0])) if (_prefetchQuestion.Equals(request.Question[0]))
{ {
//request is for prefetch question //request is for prefetch question
if (!findClosestNameServers) if (!findClosestNameServers)
return null; //dont give answer from cache for prefetch question return Task.FromResult<DnsDatagram>(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 closest name servers so that the recursive resolver queries them to refreshes cache instead of returning response from cache
return QueryClosestDelegation(request); return QueryClosestDelegationAsync(request);
} }
return base.Query(request, serveStale, findClosestNameServers, resetExpiry); return base.QueryAsync(request, serveStale, findClosestNameServers, resetExpiry);
} }
#endregion #endregion