From 64cd83a440f28351fec508526d2afa6605c22388 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 9 Jul 2020 21:08:34 +0200 Subject: [PATCH] Don't use the TTL for stale-if-error and stale-while-revalidate Use constant, reasonable values instead --- src/libdoh/src/constants.rs | 2 ++ src/libdoh/src/lib.rs | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libdoh/src/constants.rs b/src/libdoh/src/constants.rs index e2e30b2..69df765 100644 --- a/src/libdoh/src/constants.rs +++ b/src/libdoh/src/constants.rs @@ -2,3 +2,5 @@ pub const DNS_QUERY_PARAM: &str = "dns"; pub const MAX_DNS_QUESTION_LEN: usize = 512; pub const MAX_DNS_RESPONSE_LEN: usize = 4096; pub const MIN_DNS_PACKET_LEN: usize = 17; +pub const STALE_IF_ERROR_SECS: u32 = 3600; +pub const STALE_WHILE_REVALIDATE_SECS: u32 = 60; diff --git a/src/libdoh/src/lib.rs b/src/libdoh/src/lib.rs index 6b4ca0b..44477d4 100644 --- a/src/libdoh/src/lib.rs +++ b/src/libdoh/src/lib.rs @@ -212,7 +212,11 @@ impl DoH { .header(hyper::header::CONTENT_TYPE, "application/dns-message") .header( hyper::header::CACHE_CONTROL, - format!("max-age={}, stale-while-revalidate={}, stale-if-error={}", ttl, ttl, ttl).as_str(), + format!( + "max-age={}, stale-if-error={}, stale-while-revalidate={}", + ttl, STALE_IF_ERROR_SECS, STALE_WHILE_REVALIDATE_SECS + ) + .as_str(), ) .body(Body::from(packet)) .unwrap();