StatsManager: updated code to support new response types.

This commit is contained in:
Shreyas Zare
2023-02-12 13:01:39 +05:30
parent a154173bcc
commit dffda22867

View File

@@ -1537,10 +1537,21 @@ namespace DnsServerCore.Dns
switch (responseCode)
{
case DnsResponseCode.NoError:
if ((query is not null) && (responseType != DnsServerResponseType.Blocked)) //skip blocked domains
if (query is not null)
{
_queryDomains.GetOrAdd(query.Name.ToLower(), GetNewCounter).Increment();
_queries.GetOrAdd(query, GetNewCounter).Increment();
switch (responseType)
{
case DnsServerResponseType.Blocked:
case DnsServerResponseType.UpstreamBlocked:
case DnsServerResponseType.CacheBlocked:
//skip blocked domains
break;
default:
_queryDomains.GetOrAdd(query.Name.ToLower(), GetNewCounter).Increment();
_queries.GetOrAdd(query, GetNewCounter).Increment();
break;
}
}
Interlocked.Increment(ref _totalNoError);
@@ -1585,6 +1596,24 @@ namespace DnsServerCore.Dns
Interlocked.Increment(ref _totalBlocked);
break;
case DnsServerResponseType.UpstreamBlocked:
Interlocked.Increment(ref _totalRecursive);
if (query is not null)
_queryBlockedDomains.GetOrAdd(query.Name.ToLower(), GetNewCounter).Increment();
Interlocked.Increment(ref _totalBlocked);
break;
case DnsServerResponseType.CacheBlocked:
Interlocked.Increment(ref _totalCached);
if (query is not null)
_queryBlockedDomains.GetOrAdd(query.Name.ToLower(), GetNewCounter).Increment();
Interlocked.Increment(ref _totalBlocked);
break;
}
if (query is not null)