]> git.ipfire.org Git - thirdparty/pdns.git/blobdiff - pdns/dnsdist-lua.cc
dnsdist: add ability to update webserver credentials
[thirdparty/pdns.git] / pdns / dnsdist-lua.cc
index 40abb4bce865c5b91f718a57f4042fb3fc55dd82..cae1df01812c1c933c1dcbcb3bdfd2de614a5ca0 100644 (file)
@@ -631,7 +631,8 @@ void setupLuaConfig(bool client)
        SBind(sock, local);
        SListen(sock, 5);
        auto launch=[sock, local, password, apiKey, customHeaders]() {
-         thread t(dnsdistWebserverThread, sock, local, password, apiKey ? *apiKey : "", customHeaders);
+          setWebserverConfig(password, apiKey, customHeaders);
+          thread t(dnsdistWebserverThread, sock, local);
          t.detach();
        };
        if(g_launchWork)
@@ -646,6 +647,11 @@ void setupLuaConfig(bool client)
 
     });
 
+  g_lua.writeFunction("setWebserverConfig", [](const std::string& password, const boost::optional<std::string> apiKey, const boost::optional<std::map<std::string, std::string> > customHeaders) {
+      setLuaSideEffect();
+      setWebserverConfig(password, apiKey, customHeaders);
+    });
+
   g_lua.writeFunction("controlSocket", [client](const std::string& str) {
       setLuaSideEffect();
       ComboAddress local(str, 5199);