2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

DoH: Set the "max-age" "Cache-Control" HTTP header value

This commit makes BIND set the "max-age" value of the "Cache-Control"
HTTP header to the minimal TTL from the Answer section for positive
answers, as RFC 8484 advises in section 5.1.

We calculate the minimal TTL as a side effect of rendering the
response DNS message, so it does not change the code flow much, nor
should it have any measurable negative impact on the performance.

For negative answers, the "max-age" value is set using the TTL and
SOA-minimum values from an SOA record in the Authority section.
This commit is contained in:
Artem Boldariev
2021-10-12 16:58:45 +03:00
parent 80482f8d3e
commit 51a2c7aed3
3 changed files with 164 additions and 0 deletions

View File

@@ -324,12 +324,21 @@ client_allocsendbuf(ns_client_t *client, isc_buffer_t *buffer,
static void
client_sendpkg(ns_client_t *client, isc_buffer_t *buffer) {
isc_result_t result;
isc_region_t r;
dns_ttl_t min_ttl = 0;
REQUIRE(client->sendhandle == NULL);
isc_buffer_usedregion(buffer, &r);
isc_nmhandle_attach(client->handle, &client->sendhandle);
if (isc_nm_is_http_handle(client->handle)) {
result = dns_message_response_minttl(client->message, &min_ttl);
if (result == ISC_R_SUCCESS) {
isc_nm_set_maxage(client->handle, min_ttl);
}
}
isc_nm_send(client->handle, &r, client_senddone, client);
}