]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Use EDNSOptionViewMap in more places 12354/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 9 Jan 2023 10:24:42 +0000 (11:24 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 9 Jan 2023 10:24:42 +0000 (11:24 +0100)
As suggested by Otto.

pdns/dnsdist-ecs.cc
pdns/dnsdist.hh
pdns/ednsoptions.hh

index 9ef06814138a6fd04467bcae06b646baf46b5821..52b4b571526a810c41bac41d5eefbcaf4565dd46 100644 (file)
@@ -263,7 +263,7 @@ bool slowRewriteEDNSOptionInQueryWithRecords(const PacketBuffer& initialPacket,
   return true;
 }
 
-static bool slowParseEDNSOptions(const PacketBuffer& packet, std::map<uint16_t, EDNSOptionView>& 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<std::map<uint16_t, EDNSOptionView> >();
+  // dq.ednsOptions is mutable
+  dq.ednsOptions = std::make_unique<EDNSOptionViewMap>();
 
   if (ntohs(dh->arcount) == 0) {
     /* nothing in additional so no EDNS */
index f7dbac5e90c530f51d6e0058a37fc0ac1bf41804..49901415c074dc29fece81f55ee51d39541683a1 100644 (file)
@@ -146,7 +146,7 @@ public:
   InternalQueryState& ids;
   std::unique_ptr<Netmask> ecs{nullptr};
   std::string sni; /* Server Name Indication, if any (DoT or DoH) */
-  mutable std::unique_ptr<std::map<uint16_t, EDNSOptionView> > ednsOptions; /* this needs to be mutable because it is parsed just in time, when DNSQuestion is read-only */
+  mutable std::unique_ptr<EDNSOptionViewMap> ednsOptions; /* this needs to be mutable because it is parsed just in time, when DNSQuestion is read-only */
   std::unique_ptr<std::vector<ProxyProtocolValue>> proxyProtocolValues{nullptr};
   uint16_t ecsPrefixLength;
   uint8_t ednsRCode{0};
index a26eb230c1f39e641153d8337f52de3aecbc6984..fe6e4bf1dcd76eff1254d27babb48521e15797bd 100644 (file)
@@ -44,7 +44,7 @@ struct EDNSOptionView
 static constexpr size_t EDNSOptionCodeSize = 2;
 static constexpr size_t EDNSOptionLengthSize = 2;
 
-typedef std::map<uint16_t, EDNSOptionView> EDNSOptionViewMap;
+using EDNSOptionViewMap = std::map<uint16_t, EDNSOptionView>;
 
 /* 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);