From 795215f202222558b83fb2cffc33d2e1d0423378 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Tue, 10 Nov 2015 16:09:54 +0100 Subject: [PATCH] move recursor specific edns infra to recursor --- pdns/ednssubnet.cc | 29 +---------------------------- pdns/ednssubnet.hh | 2 -- pdns/pdns_recursor.cc | 29 +++++++++++++++++++++++++++++ pdns/syncres.hh | 3 +++ 4 files changed, 33 insertions(+), 30 deletions(-) diff --git a/pdns/ednssubnet.cc b/pdns/ednssubnet.cc index b84be9f2e..92d9d2a17 100644 --- a/pdns/ednssubnet.cc +++ b/pdns/ednssubnet.cc @@ -32,7 +32,7 @@ namespace { uint16_t family; uint8_t sourceMask; uint8_t scopeMask; - } GCCPACKATTRIBUTE; + } GCCPACKATTRIBUTE; // BRRRRR } @@ -92,30 +92,3 @@ string makeEDNSSubnetOptsString(const EDNSSubnetOpts& eso) return ret; } -boost::optional getEDNSSubnetMask(const ComboAddress& local, const DNSName&dn, const ComboAddress& rem) -{ - if(local.sin4.sin_family != AF_INET || local.sin4.sin_addr.s_addr) { // detect unset 'requestor' - if(g_ednsdomains.check(dn) || g_ednssubnets.match(rem)) { - int bits =local.sin4.sin_family == AF_INET ? 24 : 64; - ComboAddress trunc(local); - trunc.truncate(bits); - return boost::optional(Netmask(trunc, bits)); - } - } - return boost::optional(); -} - -void parseEDNSSubnetWhitelist(const std::string& wlist) -{ - vector parts; - stringtok(parts, wlist, ",;"); - for(const auto& a : parts) { - try { - Netmask nm(a); - g_ednssubnets.addMask(nm); - } - catch(...) { - g_ednsdomains.add(DNSName(a)); - } - } -} diff --git a/pdns/ednssubnet.hh b/pdns/ednssubnet.hh index dbdd5c151..a724b4336 100644 --- a/pdns/ednssubnet.hh +++ b/pdns/ednssubnet.hh @@ -38,6 +38,4 @@ struct EDNSSubnetOpts bool getEDNSSubnetOptsFromString(const string& options, EDNSSubnetOpts* eso); string makeEDNSSubnetOptsString(const EDNSSubnetOpts& eso); -boost::optional getEDNSSubnetMask(const ComboAddress& local, const DNSName&dn, const ComboAddress& rem); -void parseEDNSSubnetWhitelist(const std::string& wlist); #endif diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index d4f394287..b9ab0829f 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -2061,6 +2061,35 @@ void parseACLs() l_initialized = true; } +boost::optional getEDNSSubnetMask(const ComboAddress& local, const DNSName&dn, const ComboAddress& rem) +{ + if(local.sin4.sin_family != AF_INET || local.sin4.sin_addr.s_addr) { // detect unset 'requestor' + if(g_ednsdomains.check(dn) || g_ednssubnets.match(rem)) { + int bits =local.sin4.sin_family == AF_INET ? 24 : 64; + ComboAddress trunc(local); + trunc.truncate(bits); + return boost::optional(Netmask(trunc, bits)); + } + } + return boost::optional(); +} + +void parseEDNSSubnetWhitelist(const std::string& wlist) +{ + vector parts; + stringtok(parts, wlist, ",;"); + for(const auto& a : parts) { + try { + Netmask nm(a); + g_ednssubnets.addMask(nm); + } + catch(...) { + g_ednsdomains.add(DNSName(a)); + } + } +} + + int serviceMain(int argc, char*argv[]) { diff --git a/pdns/syncres.hh b/pdns/syncres.hh index 5084e60ce..90326011f 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -655,4 +655,7 @@ uint64_t* pleaseWipeCache(const DNSName& canon, bool subtree=false); uint64_t* pleaseWipePacketCache(const DNSName& canon, bool subtree); uint64_t* pleaseWipeAndCountNegCache(const DNSName& canon, bool subtree=false); void doCarbonDump(void*); +boost::optional getEDNSSubnetMask(const ComboAddress& local, const DNSName&dn, const ComboAddress& rem); +void parseEDNSSubnetWhitelist(const std::string& wlist); + #endif -- 2.40.0