]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: lua monitoring, lock on status change, better report malformed options content
authorCharles-Henri Bruyand <charles-henri.bruyand@open-xchange.com>
Thu, 19 Sep 2019 15:30:24 +0000 (17:30 +0200)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Mon, 9 Dec 2019 08:41:57 +0000 (09:41 +0100)
docs/settings.rst
pdns/common_startup.cc
pdns/lua-record.cc

index 2bf913eb7871d55139afb6239cc8937cf910be55..16e84782ac9f8567592646820251426b2eca0099 100644 (file)
@@ -880,7 +880,7 @@ Script to be used to edit incoming AXFRs, see :ref:`modes-of-operation-axfrfilte
 .. _setting-lua-health-checks-expire-delay:
 
 ``lua-health-checks-expire-delay``
------------------------------
+----------------------------------
 
 -  Integer
 -  Default: 3600
@@ -893,7 +893,7 @@ isn't used any more (either deleted or modified).
 .. _setting-lua-health-checks-interval:
 
 ``lua-health-checks-interval``
------------------------------
+------------------------------
 
 -  Integer
 -  Default: 5
index 37a843634f3613a21dbaaa500099a7c9d0b8c60e..9b97b5e9a8a470f015701b8b05a7793a7be1de27 100644 (file)
@@ -219,9 +219,8 @@ void declareArguments()
 #ifdef HAVE_LUA_RECORDS
   ::arg().setSwitch("enable-lua-records", "Process LUA records for all zones (metadata overrides this)")="no";
   ::arg().set("lua-records-exec-limit", "LUA records scripts execution limit (instructions count). Values <= 0 mean no limit")="1000";
-  ::arg().set("lua-health-checks-expire-delay", "Stops doing health checks after the record hasn't been unused for that delay (in seconds)")="3600";
+  ::arg().set("lua-health-checks-expire-delay", "Stops doing health checks after the record hasn't been used for that delay (in seconds)")="3600";
   ::arg().set("lua-health-checks-interval", "LUA records health checks monitoring interval in seconds")="5";
-  ::arg().set("lua-health-checks-timeout", "Maximum time in milliseconds that you allow the LUA monitoring health checks to take")="500";
 #endif
   ::arg().setSwitch("axfr-lower-serial", "Also AXFR a zone from a master with a lower serial")="no";
 
index 6e1418ff91c446cbcfe4ddd4666ab1431dfe1480..4760a46891086d292e6f1632b033a70049174204 100644 (file)
@@ -111,13 +111,13 @@ private:
         throw std::runtime_error(boost::str(boost::format("unable to match content with `%s`") % cd.opts.at("stringmatch")));
       }
       if(!status) {
-        g_log<<Logger::Warning<<"LUA record monitoring declaring "<<cd.rem.toString()<<" UP for URL "<<cd.url<<"!"<<endl;
+        g_log<<Logger::Info<<"LUA record monitoring declaring "<<cd.rem.toString()<<" UP for URL "<<cd.url<<"!"<<endl;
       }
       setUp(cd);
     }
     catch(std::exception& ne) {
       if(status || first)
-        g_log<<Logger::Warning<<"LUA record monitoring declaring "<<cd.rem.toString()<<" DOWN for URL "<<cd.url<<", error: "<<ne.what()<<endl;
+        g_log<<Logger::Info<<"LUA record monitoring declaring "<<cd.rem.toString()<<" DOWN for URL "<<cd.url<<", error: "<<ne.what()<<endl;
       setDown(cd);
     }
   }
@@ -136,7 +136,7 @@ private:
       }
       s.connect(cd.rem, timeout);
       if (!status) {
-        g_log<<Logger::Warning<<"Lua record monitoring declaring TCP/IP "<<cd.rem.toStringWithPort()<<" ";
+        g_log<<Logger::Info<<"Lua record monitoring declaring TCP/IP "<<cd.rem.toStringWithPort()<<" ";
         if(cd.opts.count("source"))
           g_log<<"(source "<<src.toString()<<") ";
         g_log<<"UP!"<<endl;
@@ -145,7 +145,7 @@ private:
     }
     catch (const NetworkError& ne) {
       if(status || first) {
-        g_log<<Logger::Warning<<"Lua record monitoring declaring TCP/IP "<<cd.rem.toStringWithPort()<<" DOWN: "<<ne.what()<<endl;
+        g_log<<Logger::Info<<"Lua record monitoring declaring TCP/IP "<<cd.rem.toStringWithPort()<<" DOWN: "<<ne.what()<<endl;
       }
       setDown(cd);
     }
@@ -194,6 +194,7 @@ private:
 
   void setStatus(const CheckDesc& cd, bool status)
   {
+    ReadLock lock{&d_lock};
     auto& state = d_statuses[cd];
     state->status = status;
     if (state->first) {
@@ -239,6 +240,13 @@ bool IsUpOracle::isUp(const CheckDesc& cd)
       return iter->second->status;
     }
   }
+  // try to parse options so we don't insert any malformed content
+  if (cd.opts.count("source")) {
+    ComboAddress src(cd.opts.at("source"));
+  }
+  if (cd.opts.count("timeout")) {
+    int timeout = std::atoi(cd.opts.at("timeout").c_str());
+  }
   {
     WriteLock lock{&d_lock};
     // Make sure we don't insert new entry twice now we have the lock
@@ -955,7 +963,7 @@ std::vector<shared_ptr<DNSRecordContent>> luaSynth(const std::string& code, cons
         ret.push_back(DNSRecordContent::mastermake(qtype, QClass::IN, content_it ));
     }
   } catch(std::exception &e) {
-    g_log<<Logger::Error<<"Lua record reported: "<<e.what();
+    g_log << Logger::Info << "Lua record reported: " << e.what();
     try {
       std::rethrow_if_nested(e);
       g_log<<endl;