DnsServer: Updated ProcessUdpRequestAsync() to ensure that buffer size is never less than 512. Updated ProcessDoHRequestAsync() to suppress send timeout error.

This commit is contained in:
Shreyas Zare
2026-10-10 15:05:10 +05:30
parent 8922e650cd
commit e7963cf78f
+14 -6
View File
@@ -2043,7 +2043,7 @@ namespace DnsServerCore.Dns
//send response
int sendBufferSize;
if (request.EDNS is null)
if ((request.EDNS is null) || (request.EDNS.UdpPayloadSize < 512))
sendBufferSize = 512;
else if (request.EDNS.UdpPayloadSize > _udpPayloadSize)
sendBufferSize = _udpPayloadSize;
@@ -2715,13 +2715,21 @@ namespace DnsServerCore.Dns
response.ContentType = "application/dns-message";
response.ContentLength = mS.Length;
await TechnitiumLibrary.TaskExtensions.TimeoutAsync(async delegate (CancellationToken cancellationToken1)
try
{
await using (Stream s = response.Body)
await TechnitiumLibrary.TaskExtensions.TimeoutAsync(async delegate (CancellationToken cancellationToken1)
{
await mS.CopyToAsync(s, 512, cancellationToken1);
}
}, _tcpSendTimeout, cancellationToken);
await using (Stream s = response.Body)
{
await mS.CopyToAsync(s, 512, cancellationToken1);
}
}, _tcpSendTimeout, cancellationToken);
}
catch (OperationCanceledException)
{
//do not log send timeout exception
return;
}
}
_queryLog?.Write(remoteEP, DnsTransportProtocol.Https, dnsRequest, dnsResponse);