public:
struct CacheSettings
{
- std::unordered_set<uint16_t> d_optionsToSkip{EDNSOptionCode::COOKIE};
+ std::unordered_set<uint16_t> d_optionsToSkip{EDNSOptionCode::COOKIE, EDNSOptionCode::PADDING};
std::vector<uint16_t> d_payloadRanks{};
size_t d_maxEntries{0};
size_t d_maximumEntrySize{4096};
.d_keepStaleData = cache.keep_stale_data,
};
std::unordered_set<uint16_t> ranks;
- for (const auto& option : cache.options_to_skip) {
- settings.d_optionsToSkip.insert(pdns::checked_stoi<uint16_t>(std::string(option)));
+ if (!cache.options_to_skip.empty()) {
+ settings.d_optionsToSkip.clear();
+ settings.d_optionsToSkip.insert(EDNSOptionCode::COOKIE);
+ for (const auto& option : cache.options_to_skip) {
+ settings.d_optionsToSkip.insert(pdns::checked_stoi<uint16_t>(std::string(option)));
+ }
}
if (cache.cookie_hashing) {
settings.d_optionsToSkip.erase(EDNSOptionCode::COOKIE);
}
if (getOptionalValue<decltype(skipOptions)>(vars, "skipOptions", skipOptions) > 0) {
+ settings.d_optionsToSkip.clear();
+ settings.d_optionsToSkip.insert(EDNSOptionCode::COOKIE);
for (const auto& option : skipOptions) {
settings.d_optionsToSkip.insert(option.second);
}
description: "The maximum size, in bytes, of a DNS packet that can be inserted into the packet cache"
- name: "options_to_skip"
type: "Vec<String>"
- default: ""
- description: "Extra list of EDNS option codes to skip when hashing the packet (if ``cookie_hashing`` above is false, EDNS cookie option number will be added to this list internally)"
+ default: "10, 12"
+ description: "Extra list of EDNS option codes to skip when hashing the packet (if ``cookie_hashing`` above is true, EDNS cookie option number (10) will be removed from this list internally)"
- name: "payload_ranks"
type: "Vec<u16>"
default: "[]"
.. versionchanged:: 2.0.0
``payloadRanks`` parameter added.
+ .. versionchanged:: 2.0.1
+ ``skipOptions`` now includes 12 (PADDING) by default.
+
Creates a new :class:`PacketCache` with the settings specified.
:param int maxEntries: The maximum number of entries in this cache
* ``temporaryFailureTTL=60``: int - On a SERVFAIL or REFUSED from the backend, cache for this amount of seconds.
* ``truncatedTTL=0``: int - On a truncated (TC=1, no records) response from the backend, cache for this amount of seconds. 0, the default, means that truncated answers are not cached.
* ``cookieHashing=false``: bool - If true, EDNS Cookie values will be hashed, resulting in separate entries for different cookies in the packet cache. This is required if the backend is sending answers with EDNS Cookies; otherwise, a client might receive an answer with the wrong cookie.
- * ``skipOptions={}``: Extra list of EDNS option codes to skip when hashing the packet (if ``cookieHashing`` above is false, EDNS cookie option number will be added to this list internally).
+ * ``skipOptions={12}``: Extra list of EDNS option codes to skip when hashing the packet (if ``cookieHashing`` above is false, EDNS cookie option number will be added to this list internally).
* ``maximumEntrySize=4096``: int - The maximum size, in bytes, of a DNS packet that can be inserted into the packet cache. Default is 4096 bytes, which was the fixed size before 1.9.0, and is also a hard limit for UDP responses.
* ``payloadRanks={}``: List of payload size used when hashing the packet. The list will be sorted in ascending order and searched to find a lower bound value for the payload size in the packet. If found then it will be used for packet hashing. Values less than 512 or greater than ``maximumEntrySize`` above will be discarded. This option is to enable cache entry sharing between clients using different payload sizes when needed.