Skip to content

Commit

Permalink
feat: when tracing, pretty print the DNS response
Browse files Browse the repository at this point in the history
  • Loading branch information
richardschneider committed Apr 24, 2019
1 parent 8def23c commit f873a70
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/DnsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ public override async Task<Message> QueryAsync(
}
}

log.Debug($"Got response #{response.Id}");
if (log.IsDebugEnabled)
log.Debug($"Got response #{response.Id}");
if (log.IsTraceEnabled)
log.Trace(response);
return response;
}

Expand Down
4 changes: 3 additions & 1 deletion src/DohClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class DohClient : DnsClientBase
public string ServerUrl { get; set; } = "https://cloudflare-dns.com/dns-query";

HttpClient httpClient;
object httpClientLock = new object();
readonly object httpClientLock = new object();
readonly AsyncLock dnsServerLock = new AsyncLock();

/// <summary>
Expand Down Expand Up @@ -159,6 +159,8 @@ public override async Task<Message> QueryAsync(

if (log.IsDebugEnabled)
log.Debug($"Got response #{dnsResponse.Id}");
if (log.IsTraceEnabled)
log.Trace(dnsResponse);
return dnsResponse;
}

Expand Down
2 changes: 2 additions & 0 deletions src/DotClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,8 @@ void ReadResponses(Stream stream)
// Find matching request.
if (log.IsDebugEnabled)
log.Debug($"Got response #{response.Id} {response.Status}");
if (log.IsTraceEnabled)
log.Trace(response);
if (!OutstandingRequests.TryGetValue(response.Id, out var task))
{
log.Warn("DNS response is missing a matching request ID.");
Expand Down
2 changes: 1 addition & 1 deletion src/Udns.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<ItemGroup>
<PackageReference Include="Common.Logging" Version="3.4.1" />
<PackageReference Include="Makaretu.Dns" Version="1.2.0" />
<PackageReference Include="Makaretu.Dns" Version="1.3.0" />
<PackageReference Include="Nito.AsyncEx" Version="5.0.0" />
</ItemGroup>

Expand Down

0 comments on commit f873a70

Please sign in to comment.