From: Oliver Chen Date: Mon, 23 Jun 2025 12:00:35 +0000 (+0000) Subject: Address PR comments and add console completion in new file X-Git-Tag: dnsdist-2.1.0-alpha0~8^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bef9d8590a8111944c2e93eb660b501c95964c06;p=thirdparty%2Fpdns.git Address PR comments and add console completion in new file --- diff --git a/pdns/dnsdistdist/dnsdist-console-completion.cc b/pdns/dnsdistdist/dnsdist-console-completion.cc index 458d890533..f3342e8aa2 100644 --- a/pdns/dnsdistdist/dnsdist-console-completion.cc +++ b/pdns/dnsdistdist/dnsdist-console-completion.cc @@ -57,6 +57,7 @@ static std::vector s_consoleKeywor {"addLocal", true, R"(addr [, {doTCP=true, reusePort=false, tcpFastOpenQueueSize=0, interface="", cpus={}}])", "add `addr` to the list of addresses we listen on"}, {"addMaintenanceCallback", true, "callback", "register a function to be called as part of the maintenance hook, every second"}, {"addExitCallback", true, "callback", "register a function to be called when DNSdist exits"}, + {"addServerStateChangeCallback", true, "callback", "register a function to be called when state changed for a given server"}, {"addTLSLocal", true, "addr, certFile(s), keyFile(s) [,params]", "listen to incoming DNS over TLS queries on the specified address using the specified certificate (or list of) and key (or list of). The last parameter is a table"}, {"AllowAction", true, "", "let these packets go through"}, {"AllowResponseAction", true, "", "let these packets go through"}, diff --git a/pdns/dnsdistdist/docs/reference/config.rst b/pdns/dnsdistdist/docs/reference/config.rst index db7315cba9..beccb56e29 100644 --- a/pdns/dnsdistdist/docs/reference/config.rst +++ b/pdns/dnsdistdist/docs/reference/config.rst @@ -2243,7 +2243,7 @@ Other functions Register a Lua function to be called when a server state changed during the health check process. The function should not block for a long period of time, as it would otherwise delay the execution of the other functions registered for this hook, as well as the execution of the health check process. - :param function callback: The function to be called. It returns no value and takes two parameters, first parameter is a string with format as the same as return from :func:`Server:getNameWithAddr()` to identify the server, second parameter is a bool value indicating server state is up if true else down. + :param function callback: The function to be called. It returns no value and takes two parameters: the first parameter is a string identifying the server, formatted as if returned by :func:`Server:getNameWithAddr()`, the second parameter is a boolean value indicating whether the server is up. .. code-block:: lua diff --git a/regression-tests.dnsdist/test_HealthChecks.py b/regression-tests.dnsdist/test_HealthChecks.py index 4348d76b35..50ec51235b 100644 --- a/regression-tests.dnsdist/test_HealthChecks.py +++ b/regression-tests.dnsdist/test_HealthChecks.py @@ -625,14 +625,14 @@ class TestServerStateChange(HealthCheckTest): self.setDrop(True) time.sleep(2.5) - # up count no change, down count increased by 1 + # up count did not change, down count increased by 1 self.assertEqual(self.getBackendStatus(), 'down') self.assertEqual(self.getCount(nameAddr, True), 1) self.assertEqual(self.getCount(nameAddr, False), 1) self.setDrop(False) time.sleep(1.5) - # up count increased again, down count no change + # up count increased again, down count did not change self.assertEqual(self.getBackendStatus(), 'up') self.assertEqual(self.getCount(nameAddr, True), 2) self.assertEqual(self.getCount(nameAddr, False), 1)