Added extended logging capability with metadata in addition to using …#1827
Open
zbalkan wants to merge 1 commit into
Open
Added extended logging capability with metadata in addition to using …#1827zbalkan wants to merge 1 commit into
zbalkan wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds structured “extended logging” metadata for blocked DNS responses, allowing loggers/apps to record blocking context even when it isn’t present in the wire response.
Changes:
- Introduces
DnsQueryLogMetadata,DnsServerResponseMetadata, andIDnsQueryLoggerExto support metadata-aware logging. - Propagates response type + metadata via
DnsDatagram.Tag(including block-list-zone and app blocking responses) and updates stats/logging paths to read the new tag shape. - Extends bundled logging/exporter apps (SQL Server/SQLite/MySQL query logs, syslog exporter) to persist/emit blocking metadata.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| DnsServerCore/Dns/ZoneManagers/BlockListZoneManager.cs | Adds metadata generation for block-list-zone hits and attaches it to responses. |
| DnsServerCore/Dns/StatsManager.cs | Updates stats/log dispatch to derive response type and pass optional metadata to extended loggers. |
| DnsServerCore/Dns/DnsServer.cs | Propagates blocked-query metadata through blocked-query processing (incl. CNAME-cloaking path). |
| DnsServerCore.ApplicationCommon/IDnsQueryLogger.cs | Adds metadata model types + IDnsQueryLoggerEx and helpers for reading response tags. |
| Apps/QueryLogsSqlServerApp/App.cs | Adds blocking_metadata column and stores metadata JSON for blocked queries. |
| Apps/QueryLogsSqliteApp/App.cs | Adds blocking_metadata column and stores metadata JSON for blocked queries. |
| Apps/QueryLogsMySqlApp/App.cs | Adds blocking_metadata column and stores metadata JSON for blocked queries. |
| Apps/MispConnectorApp/App.cs | Attaches blocked-response metadata and includes blocking report text in EDE/TXT. |
| Apps/LogExporterApp/Strategy/SyslogExportStrategy.cs | Exports blocking metadata as structured syslog properties. |
| Apps/LogExporterApp/LogEntry.cs | Captures blocking metadata from logger arg/tag and improves EDE parsing robustness. |
| Apps/LogExporterApp/App.cs | Implements IDnsQueryLoggerEx and forwards metadata into queued log entries. |
| Apps/AdvancedBlockingApp/App.cs | Attaches metadata to blocked responses for advanced-blocking decisions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ac31104 to
aa9044d
Compare
…datagram contents
Contributor
Author
|
Updated to version 15.3 |
Comment on lines
+31
to
+34
| public DnsQueryLogMetadata(IReadOnlyDictionary<string, string>? values = null) | ||
| { | ||
| Values = values is null ? new Dictionary<string, string>(0) : new Dictionary<string, string>(values, StringComparer.OrdinalIgnoreCase); | ||
| } |
Comment on lines
+104
to
+118
| public static class DnsServerResponseTag | ||
| { | ||
| public static DnsServerResponseType GetResponseType(object? tag) | ||
| { | ||
| if (tag is null) | ||
| return DnsServerResponseType.Recursive; | ||
|
|
||
| if (tag is DnsServerResponseType responseType) | ||
| return responseType; | ||
|
|
||
| if (tag is DnsServerResponseMetadata responseMetadata) | ||
| return responseMetadata.ResponseType; | ||
|
|
||
| return DnsServerResponseType.Recursive; | ||
| } |
Comment on lines
+4362
to
+4369
| public BlockedQueryResult(DnsDatagram response, DnsQueryLogMetadata? logMetadata = null) | ||
| { | ||
| Response = response; | ||
| LogMetadata = logMetadata; | ||
| } | ||
|
|
||
| public DnsDatagram Response { get; } | ||
| public DnsQueryLogMetadata? LogMetadata { get; } |
Comment on lines
+849
to
+852
| public DnsDatagram Query(DnsDatagram request, out DnsQueryLogMetadata? logMetadata) | ||
| { | ||
| logMetadata = null; | ||
|
|
| if (blockLists.Count > 0) | ||
| { | ||
| metadataValues["blockListUrl"] = blockLists[0].AbsoluteUri; | ||
| metadataValues["blockListCount"] = blockLists.Count.ToString(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…datagram contents.
Solving the extended logging issue discussed here: #1770