From: Remi Gacogne Date: Fri, 18 Aug 2017 09:17:50 +0000 (+0200) Subject: dnsdist: Add an optional `status` parameter to `setAuto()` X-Git-Tag: rec-4.1.0-rc2~29^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d92708edcb5eeaa5806230a8a752eacda236c9d6;p=thirdparty%2Fpdns.git dnsdist: Add an optional `status` parameter to `setAuto()` 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. --- diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index 799c10eb1a..fb44f3a7f8 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -1187,7 +1187,13 @@ vector> 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 newStatus)>("setAuto", [](DownstreamState& s, boost::optional 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); diff --git a/pdns/dnsdistdist/docs/reference/config.rst b/pdns/dnsdistdist/docs/reference/config.rst index dba6b79558..b9250d7362 100644 --- a/pdns/dnsdistdist/docs/reference/config.rst +++ b/pdns/dnsdistdist/docs/reference/config.rst @@ -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)