From 444fa80c76d84574ecf27a2e9caa52d2c43418e5 Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sat, 21 Dec 2024 15:53:43 +0530 Subject: [PATCH] IDnsQueryLogger: updated DnsLogEntry to support response rtt feature. --- .../IDnsQueryLogger.cs | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/DnsServerCore.ApplicationCommon/IDnsQueryLogger.cs b/DnsServerCore.ApplicationCommon/IDnsQueryLogger.cs index 4665888e..67f72739 100644 --- a/DnsServerCore.ApplicationCommon/IDnsQueryLogger.cs +++ b/DnsServerCore.ApplicationCommon/IDnsQueryLogger.cs @@ -139,6 +139,7 @@ namespace DnsServerCore.ApplicationCommon readonly IPAddress _clientIpAddress; readonly DnsTransportProtocol _protocol; readonly DnsServerResponseType _responseType; + readonly double? _responseRtt; readonly DnsResponseCode _rcode; readonly DnsQuestionRecord _question; readonly string _answer; @@ -147,6 +148,42 @@ namespace DnsServerCore.ApplicationCommon #region constructor + /// + /// Creates a new object initialized with all the log entry parameters. + /// + /// The row number of the entry in the selected data set. + /// The time stamp of the log entry. + /// The client IP address of the request. + /// The DNS transport protocol of the request. + /// The type of response sent by the DNS server. + /// The round trip time taken to resolve the request. + /// The response code sent by the DNS server. + /// The question section in the request. + /// The answer in text format sent by the DNS server. + public DnsLogEntry(long rowNumber, DateTime timestamp, IPAddress clientIpAddress, DnsTransportProtocol protocol, DnsServerResponseType responseType, double? responseRtt, DnsResponseCode rcode, DnsQuestionRecord question, string answer) + { + _rowNumber = rowNumber; + _timestamp = timestamp; + _clientIpAddress = clientIpAddress; + _protocol = protocol; + _responseType = responseType; + _responseRtt = responseRtt; + _rcode = rcode; + _question = question; + _answer = answer; + + switch (_timestamp.Kind) + { + case DateTimeKind.Local: + _timestamp = _timestamp.ToUniversalTime(); + break; + + case DateTimeKind.Unspecified: + _timestamp = DateTime.SpecifyKind(_timestamp, DateTimeKind.Utc); + break; + } + } + /// /// Creates a new object initialized with all the log entry parameters. /// @@ -215,6 +252,12 @@ namespace DnsServerCore.ApplicationCommon public DnsServerResponseType ResponseType { get { return _responseType; } } + /// + /// The round trip time taken to resolve the request. + /// + public double? ResponseRtt + { get { return _responseRtt; } } + /// /// The response code sent by the DNS server. ///