Skip to content

Commit

Permalink
dnsdist: Use EDNSOptionViewMap in more places
Browse files Browse the repository at this point in the history
As suggested by Otto.
  • Loading branch information
rgacogne committed Jan 9, 2023
1 parent 582d5b5 commit 3f18782
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions pdns/dnsdist-ecs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion pdns/dnsdist.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion pdns/ednsoptions.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3f18782

Please sign in to comment.