From: Remi Gacogne Date: Mon, 9 Jan 2023 10:24:42 +0000 (+0100) Subject: dnsdist: Use EDNSOptionViewMap in more places X-Git-Tag: dnsdist-1.8.0-rc1~134^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F12354%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Use EDNSOptionViewMap in more places As suggested by Otto. --- diff --git a/pdns/dnsdist-ecs.cc b/pdns/dnsdist-ecs.cc index 9ef0681413..52b4b57152 100644 --- a/pdns/dnsdist-ecs.cc +++ b/pdns/dnsdist-ecs.cc @@ -263,7 +263,7 @@ bool slowRewriteEDNSOptionInQueryWithRecords(const PacketBuffer& initialPacket, return true; } -static bool slowParseEDNSOptions(const PacketBuffer& packet, std::map& options) +static bool slowParseEDNSOptions(const PacketBuffer& packet, EDNSOptionViewMap& options) { if (packet.size() < sizeof(dnsheader)) { return false; @@ -515,7 +515,8 @@ bool parseEDNSOptions(const DNSQuestion& dq) return true; } - dq.ednsOptions = std::make_unique >(); + // dq.ednsOptions is mutable + dq.ednsOptions = std::make_unique(); if (ntohs(dh->arcount) == 0) { /* nothing in additional so no EDNS */ diff --git a/pdns/dnsdist.hh b/pdns/dnsdist.hh index f7dbac5e90..49901415c0 100644 --- a/pdns/dnsdist.hh +++ b/pdns/dnsdist.hh @@ -146,7 +146,7 @@ public: InternalQueryState& ids; std::unique_ptr ecs{nullptr}; std::string sni; /* Server Name Indication, if any (DoT or DoH) */ - mutable std::unique_ptr > ednsOptions; /* this needs to be mutable because it is parsed just in time, when DNSQuestion is read-only */ + mutable std::unique_ptr ednsOptions; /* this needs to be mutable because it is parsed just in time, when DNSQuestion is read-only */ std::unique_ptr> proxyProtocolValues{nullptr}; uint16_t ecsPrefixLength; uint8_t ednsRCode{0}; diff --git a/pdns/ednsoptions.hh b/pdns/ednsoptions.hh index a26eb230c1..fe6e4bf1dc 100644 --- a/pdns/ednsoptions.hh +++ b/pdns/ednsoptions.hh @@ -44,7 +44,7 @@ struct EDNSOptionView static constexpr size_t EDNSOptionCodeSize = 2; static constexpr size_t EDNSOptionLengthSize = 2; -typedef std::map EDNSOptionViewMap; +using EDNSOptionViewMap = std::map; /* extract all EDNS0 options from a pointer on the beginning rdLen of the OPT RR */ int getEDNSOptions(const char* optRR, size_t len, EDNSOptionViewMap& options);