]> git.ipfire.org Git - thirdparty/pdns.git/blobdiff - pdns/dnsdist-lua.cc
dnsdist: Add get*BindCount() functions
[thirdparty/pdns.git] / pdns / dnsdist-lua.cc
index fde5fd0ce90673b49598f4516f8d7189d90769d2..83b76a80c3de8e0c56fa42c15fb733a087f64f87 100644 (file)
@@ -565,7 +565,7 @@ static void setupLuaConfig(bool client, bool configCheck)
       try {
        ComboAddress loc(addr, 53);
         for (auto it = g_frontends.begin(); it != g_frontends.end(); ) {
-          /* TLS and DNSCrypt frontends are separate */
+          /* DoH, DoT and DNSCrypt frontends are separate */
           if ((*it)->tlsFrontend == nullptr && (*it)->dnscryptCtx == nullptr) {
             it = g_frontends.erase(it);
           }
@@ -1287,6 +1287,11 @@ static void setupLuaConfig(bool client, bool configCheck)
 #endif
     });
 
+  g_lua.writeFunction("getDNSCryptBindCount", []() {
+      setLuaNoSideEffect();
+      return g_dnsCryptLocals.size();
+    });
+
   g_lua.writeFunction("generateDNSCryptProviderKeys", [client](const std::string& publicKeyFile, const std::string privateKeyFile) {
       setLuaNoSideEffect();
 #ifdef HAVE_DNSCRYPT
@@ -1443,6 +1448,11 @@ static void setupLuaConfig(bool client, bool configCheck)
       return ret;
       });
 
+  g_lua.writeFunction("getBindCount", []() {
+      setLuaNoSideEffect();
+      return g_frontends.size();
+    });
+
   g_lua.writeFunction("help", [](boost::optional<std::string> command) {
       setLuaNoSideEffect();
       g_outputBuffer = "";
@@ -1967,6 +1977,11 @@ static void setupLuaConfig(bool client, bool configCheck)
         return result;
       });
 
+    g_lua.writeFunction("getDOHFrontendCount", []() {
+        setLuaNoSideEffect();
+        return g_dohlocals.size();
+      });
+
     g_lua.registerFunction<void(std::shared_ptr<DOHFrontend>::*)()>("reloadCertificates", [](std::shared_ptr<DOHFrontend> frontend) {
         if (frontend != nullptr) {
           frontend->reloadCertificates();
@@ -2125,6 +2140,11 @@ static void setupLuaConfig(bool client, bool configCheck)
         return result;
       });
 
+    g_lua.writeFunction("getTLSFrontendCount", []() {
+        setLuaNoSideEffect();
+        return g_tlslocals.size();
+      });
+
     g_lua.registerFunction<void(std::shared_ptr<TLSCtx>::*)()>("rotateTicketsKey", [](std::shared_ptr<TLSCtx> ctx) {
         if (ctx != nullptr) {
           ctx->rotateTicketsKey(time(nullptr));