]> granicus.if.org Git - pdns/commitdiff
dnsdist: Add an optional `status` parameter to `setAuto()`
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 18 Aug 2017 09:17:50 +0000 (11:17 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 18 Aug 2017 09:17:50 +0000 (11:17 +0200)
If the parameter is present, its value is used to set the initial
state of the DownstreamServer until a health check is performed,
instead of using the previous known state.
It's useful if one wants to restore the automatic status detection
but knows that the server is either currently down but was previously
up (queries sent until the health check is performed will be lost);
or currently up but was previously down, so it process queries immediately.

pdns/dnsdist-lua.cc
pdns/dnsdistdist/docs/reference/config.rst

index 799c10eb1acb114a78370b23066c2751298bed08..fb44f3a7f8ad62f7fdd50d5c493a2bf928532585 100644 (file)
@@ -1187,7 +1187,13 @@ vector<std::function<void(void)>> setupLua(bool client, const std::string& confi
   g_lua.registerFunction("isUp", &DownstreamState::isUp);
   g_lua.registerFunction("setDown", &DownstreamState::setDown);
   g_lua.registerFunction("setUp", &DownstreamState::setUp);
-  g_lua.registerFunction("setAuto", &DownstreamState::setAuto);
+  g_lua.registerFunction<void(DownstreamState::*)(boost::optional<bool> newStatus)>("setAuto", [](DownstreamState& s, boost::optional<bool> newStatus) {
+      if (newStatus) {
+        s.upStatus = *newStatus;
+      }
+      s.setAuto();
+    });
+
   g_lua.registerFunction("getName", &DownstreamState::getName);
   g_lua.registerFunction("getNameWithAddr", &DownstreamState::getNameWithAddr);
   g_lua.registerMember("upStatus", &DownstreamState::upStatus);
index dba6b795583ad5867a2a1bc0678cef4173d99ba3..b9250d7362b0bd897b861b3b19739ccaf87c622d 100644 (file)
@@ -303,10 +303,15 @@ A server object returned by :func:`getServer` can be manipulated with these func
 
   :param str pool: The pool to remove the server from
 
-.. classmethod:: Server:setAuto()
+.. classmethod:: Server:setAuto([status])
+
+.. versionchanged:: 1.3.0
+    ``status`` optional parameter added.
 
   Set the server in the default auto state.
-  This will enable health check queries that will set the server ``up`` and ``down`` appropriatly.
+  This will enable health check queries that will set the server ``up`` and ``down`` appropriately.
+
+  :param bool status: Set the initial status of the server to ``up`` (true) or ``down`` (false) instead of using the last known status
 
 .. classmethod:: Server:setQPS(limit)