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.
This commit is contained in:
Simon Kelley
2021-04-06 23:29:46 +01:00
parent ea6b0b2665
commit 64a16cb376

View File

@@ -366,6 +366,12 @@ static int forward_query(int udpfd, union mysockaddr *udpaddr,
src->log_id = daemon->log_id; src->log_id = daemon->log_id;
src->iface = dst_iface; src->iface = dst_iface;
src->fd = udpfd; 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;
} }
} }