Skip to content

Commit

Permalink
Adds warning log to DnsZoneUpdateClient.
Browse files Browse the repository at this point in the history
  • Loading branch information
alanedwardes committed Feb 16, 2024
1 parent 96dfb5d commit 6af0a87
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Ae.Dns.Client/DnsZoneUpdateClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public async Task<DnsMessage> Query(DnsMessage query, CancellationToken token =
var firstPreReqsCheckResponseCode = _dnsZone.TestZoneUpdatePreRequisites(query);
if (firstPreReqsCheckResponseCode != DnsResponseCode.NoError)
{
_logger.LogWarning("Returning response {ResponseCode} for query {Bytes}", firstPreReqsCheckResponseCode, DnsByteExtensions.ToDebugString(query.ToBytes()));
return query.CreateAnswerMessage(firstPreReqsCheckResponseCode, ToString());
}

Expand Down
14 changes: 14 additions & 0 deletions src/Ae.Dns.Protocol/DnsByteExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,5 +226,19 @@ public static void ToBytes(ushort value, Memory<byte> buffer, ref int offset)
buffer.Span[offset++] = (byte)(value >> 8);
buffer.Span[offset++] = (byte)(value >> 0);
}

public static byte[] ToBytes(this IDnsByteArrayWriter writer)
{
var buffer = AllocatePinnedNetworkBuffer();

var offset = 0;
writer.WriteBytes(buffer, ref offset);

#if NET6_0_OR_GREATER
return buffer.Slice(0, offset).ToArray();
#else
return buffer.Slice(0, offset).Array;
#endif
}
}
}

0 comments on commit 6af0a87

Please sign in to comment.