Skip to content

Added extended logging capability with metadata in addition to using …#1827

Open
zbalkan wants to merge 1 commit intoTechnitiumSoftware:masterfrom
zbalkan:feat/extended-logging-with-metadata
Open

Added extended logging capability with metadata in addition to using …#1827
zbalkan wants to merge 1 commit intoTechnitiumSoftware:masterfrom
zbalkan:feat/extended-logging-with-metadata

Conversation

@zbalkan
Copy link
Copy Markdown
Contributor

@zbalkan zbalkan commented Apr 9, 2026

…datagram contents.

Solving the extended logging issue discussed here: #1770

Copilot AI review requested due to automatic review settings April 9, 2026 11:10
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and IDnsQueryLoggerEx to 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.

Comment on lines +29 to +33
public sealed class DnsQueryLogMetadata
{
public DnsQueryLogMetadata(IReadOnlyDictionary<string, string>? values = null)
{
Values = values is null ? new Dictionary<string, string>(0) : new Dictionary<string, string>(values, StringComparer.OrdinalIgnoreCase);
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file introduces nullable reference annotations (e.g., IReadOnlyDictionary<string, string>?, string?, DnsQueryLogMetadata?) but DnsServerCore.ApplicationCommon.csproj does not enable nullable reference types. This will produce CS8632 warnings and the annotations won’t be properly enforced/consumed. Consider enabling <Nullable>enable</Nullable> for the project (or adding #nullable enable), or remove the annotations to keep the project consistent.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It depends on the decision of @ShreyasZare

Comment thread DnsServerCore/Dns/ZoneManagers/BlockListZoneManager.cs
Comment thread DnsServerCore/Dns/DnsServer.cs
Comment thread Apps/AdvancedBlockingApp/App.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants