fix FORMERR: filter UNKNOWN records and increase buffer to 4096

Root cause: upstream resolvers return EDNS OPT records (type 41) in
the additional section. Our parser reads them as UNKNOWN, but write()
silently skips them — creating a header that claims N additional records
but a body with 0, producing FORMERR on the client side.

Fix: filter out UNKNOWN records before serialization and adjust header
counts to match. Also increase BytePacketBuffer from 512 to 4096 bytes
to handle modern DNS responses with many records.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Razvan Dimescu
2026-03-20 14:11:46 +02:00
parent 7e29f3cb57
commit 5eec8915d4
3 changed files with 24 additions and 13 deletions

View File

@@ -43,6 +43,10 @@ pub enum DnsRecord {
}
impl DnsRecord {
pub fn is_unknown(&self) -> bool {
matches!(self, DnsRecord::UNKNOWN { .. })
}
pub fn ttl(&self) -> u32 {
match self {
DnsRecord::A { ttl, .. }