From: Remi Gacogne Date: Fri, 15 Apr 2022 10:57:53 +0000 (+0200) Subject: dnsdist: Add a 'getAddressAndPort()' method to DOHFrontend and TLSFrontend objects X-Git-Tag: auth-4.8.0-alpha0~130^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=59090737335dc8fe412ed00d2e73e3cf056713c9;p=thirdparty%2Fpdns.git dnsdist: Add a 'getAddressAndPort()' method to DOHFrontend and TLSFrontend objects --- diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index 1bdaf55a74..706572e4b0 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -2544,6 +2544,13 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) } }); + luaCtx.registerFunction::*)()const>("getAddressAndPort", [](const std::shared_ptr& frontend) { + if (frontend == nullptr) { + return std::string(); + } + return frontend->d_local.toStringWithPort(); + }); + luaCtx.writeFunction("addTLSLocal", [client](const std::string& addr, boost::variant, LuaArray, LuaArray>> certFiles, LuaTypeOrArrayOf keyFiles, boost::optional vars) { if (client) { return; @@ -2702,6 +2709,13 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) } }); + luaCtx.registerFunction::*)()const>("getAddressAndPort", [](const std::shared_ptr& frontend) { + if (frontend == nullptr) { + return std::string(); + } + return frontend->d_addr.toStringWithPort(); + }); + luaCtx.registerFunction::*)()>("rotateTicketsKey", [](std::shared_ptr& frontend) { if (frontend == nullptr) { return; diff --git a/pdns/dnsdistdist/docs/reference/config.rst b/pdns/dnsdistdist/docs/reference/config.rst index 33987be6b3..d77dfc168a 100644 --- a/pdns/dnsdistdist/docs/reference/config.rst +++ b/pdns/dnsdistdist/docs/reference/config.rst @@ -1720,6 +1720,12 @@ DOHFrontend This object represents an address and port dnsdist is listening on for DNS over HTTPS queries. + .. method:: DOHFrontend:getAddressAndPort() -> string + + .. versionadded:: 1.7.1 + + Return the address and port this frontend is listening on. + .. method:: DOHFrontend:loadNewCertificatesAndKeys(certFile(s), keyFile(s)) .. versionadded:: 1.6.1 @@ -1789,6 +1795,12 @@ TLSFrontend This object represents the configuration of a listening frontend for DNS over TLS queries. To each frontend is associated a TLSContext. + .. method:: TLSFrontend:getAddressAndPort() -> string + + .. versionadded:: 1.7.1 + + Return the address and port this frontend is listening on. + .. method:: TLSFrontend:loadNewCertificatesAndKeys(certFile(s), keyFile(s)) Create and switch to a new TLS context using the same options than were passed to the corresponding `addTLSLocal()` directive, but loading new certificates and keys from the selected files, replacing the existing ones.