Skip to content

Commit

Permalink
Add a method to get the scoped subnet (aka Netmask) as suggested by @…
Browse files Browse the repository at this point in the history
  • Loading branch information
omoerbeek committed Jan 17, 2025
1 parent 538c8d3 commit 5dd7b4e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pdns/dnsproxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ void DNSProxy::mainloop()
// update the EDNS options with info from the resolver - issue #5469
// note that this relies on the ECS string encoder to use the source network, and only take the prefix length from scope
iter->second.complete->d_eso.setScopePrefixLength(packet.d_eso.getScopePrefixLength());
DLOG(g_log << "from dnsproxy::mainLoop: updated EDNS options from resolver EDNS source: " << iter->second.complete->d_eso.getSource().toString() << " EDNS scope: " << Netmask(iter->second.complete->d_eso.getSource().getNetwork(), iter->second.complete->d_eso.getScopePrefixLength()).toString() << endl);
DLOG(g_log << "from dnsproxy::mainLoop: updated EDNS options from resolver EDNS source: " << iter->second.complete->d_eso.getSource().toString() << " EDNS scope: " << iter->second.complete->d_eso.getScope().toString() << endl);

if (mdp.d_header.rcode == RCode::NoError) {
for (const auto& answer : mdp.d_answers) {
Expand Down
4 changes: 4 additions & 0 deletions pdns/ednssubnet.hh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public:
{
return scopeBits;
}
[[nodiscard]] Netmask getScope() const
{
return {source.getNetwork(), scopeBits};
}
[[nodiscard]] std::string makeOptString() const;
static bool getFromString(const std::string& options, EDNSSubnetOpts* eso);
static bool getFromString(const char* options, unsigned int len, EDNSSubnetOpts* eso);
Expand Down
2 changes: 1 addition & 1 deletion pdns/sdig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ static void printReply(const string& reply, bool showflags, bool hidesoadetails,
EDNSSubnetOpts reso;
if (EDNSSubnetOpts::getFromString(iter->second, &reso)) {
cerr << "EDNS Subnet response: " << reso.getSource().toString()
<< ", scope: " << Netmask(reso.getSource().getNetwork(), reso.getScopePrefixLength()).toString()
<< ", scope: " << reso.getScope().toString()
<< ", family = " << std::to_string(reso.getFamily())
<< endl;
}
Expand Down

0 comments on commit 5dd7b4e

Please sign in to comment.