]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: Don't use a boost::optional to store "spoof-nearmiss-max"
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 18 Nov 2020 20:54:28 +0000 (21:54 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 18 Nov 2020 20:54:28 +0000 (21:54 +0100)
pdns/pdns_recursor.cc

index 6b5a7bcaedc91337bb65c7195720962941ff55b3..414666ddcfeb7de4c0b45f8e058f752a36abc3b2 100644 (file)
@@ -693,7 +693,7 @@ LWResult::Result asendto(const char *data, size_t len, int flags,
 LWResult::Result arecvfrom(std::string& packet, int flags, const ComboAddress& fromaddr, size_t *d_len,
                            uint16_t id, const DNSName& domain, uint16_t qtype, int fd, const struct timeval* now)
 {
-  static const boost::optional<unsigned int> nearMissLimit = ::arg().asNum("spoof-nearmiss-max");
+  static const unsigned int nearMissLimit = ::arg().asNum("spoof-nearmiss-max");
 
   PacketID pident;
   pident.fd=fd;
@@ -713,8 +713,8 @@ LWResult::Result arecvfrom(std::string& packet, int flags, const ComboAddress& f
 
     *d_len=packet.size();
 
-    if (*nearMissLimit && pident.nearMisses > *nearMissLimit) {
-      g_log<<Logger::Error<<"Too many ("<<pident.nearMisses<<" > "<<*nearMissLimit<<") bogus answers for '"<<domain<<"' from "<<fromaddr.toString()<<", assuming spoof attempt."<<endl;
+    if (nearMissLimit > 0 && pident.nearMisses > nearMissLimit) {
+      g_log<<Logger::Error<<"Too many ("<<pident.nearMisses<<" > "<<nearMissLimit<<") bogus answers for '"<<domain<<"' from "<<fromaddr.toString()<<", assuming spoof attempt."<<endl;
       g_stats.spoofCount++;
       return LWResult::Result::Spoofed;
     }