Skip to content

Commit

Permalink
FIX: Servers should drop received DNS response messages, not propagat…
Browse files Browse the repository at this point in the history
…e them for processing. (#381)
  • Loading branch information
ximon18 authored Oct 3, 2024
1 parent 1c7be5d commit 930786e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/net/server/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,7 @@ where

match Message::from_octets(buf) {
Err(err) => {
// TO DO: Count this event?
tracing::warn!(
"Failed while parsing request message: {err}"
);
Expand All @@ -678,6 +679,15 @@ where
));
}

// https://datatracker.ietf.org/doc/html/rfc1035#section-4.1.1
// 4.1.1. Header section format
// "QR A one bit field that specifies whether this
// message is a query (0), or a response (1)."
Ok(msg) if msg.header().qr() => {
// TO DO: Count this event?
trace!("Ignoring received message because it is a reply, not a query.");
}

Ok(msg) => {
let ctx = NonUdpTransportContext::new(Some(
self.config.load().idle_timeout,
Expand Down
13 changes: 12 additions & 1 deletion src/net/server/dgram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,18 @@ where
tokio::spawn(async move {
match Message::from_octets(buf) {
Err(err) => {
tracing::warn!("Failed while parsing request message: {err}");
// TO DO: Count this event?
warn!("Failed while parsing request message: {err}");
}

// https://datatracker.ietf.org/doc/html/rfc1035#section-4.1.1
// 4.1.1. Header section format
// "QR A one bit field that specifies whether
// this message is a query (0), or a
// response (1)."
Ok(msg) if msg.header().qr() => {
// TO DO: Count this event?
trace!("Ignoring received message because it is a reply, not a query.");
}

Ok(msg) => {
Expand Down

0 comments on commit 930786e

Please sign in to comment.