From 64a16cb376a5248a53fb55e81a8df4d61630d120 Mon Sep 17 00:00:00 2001 From: Simon Kelley Date: Tue, 6 Apr 2021 23:29:46 +0100 Subject: [PATCH] Combine queries for the same DNS name if close in time. If two queries arrive a second or so apart, they cannot be a try and a retry from the same client (retries are at least three seconds apart.) It's therefore safe not to forward the second query, but answer them both when the reply arrives for the first. --- src/forward.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/forward.c b/src/forward.c index ab9df26..5ff4e86 100644 --- a/src/forward.c +++ b/src/forward.c @@ -366,6 +366,12 @@ static int forward_query(int udpfd, union mysockaddr *udpaddr, src->log_id = daemon->log_id; src->iface = dst_iface; src->fd = udpfd; + + /* closely spaced identical queries cannot be a try and a retry, so + it's safe to wait for the reply from the first without + forwarding the second. */ + if (difftime(now, forward->time) < 2) + return 0; } }