]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Exit when requested DoT/DoH support is not compiled in 7915/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 12 Jun 2019 10:06:59 +0000 (12:06 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 12 Jun 2019 10:06:59 +0000 (12:06 +0200)
pdns/dnsdist-lua.cc

index 71421a1862b447503abeab1c4287fb88842a33aa..bf235d557230718bd854a9131e58a37cc5e4baa6 100644 (file)
@@ -541,7 +541,8 @@ void setupLuaConfig(bool client)
         }
       }
       catch(std::exception& e) {
-       g_outputBuffer="Error: "+string(e.what())+"\n";
+        g_outputBuffer="Error: "+string(e.what())+"\n";
+        errlog("Error while trying to listen on %s: %s\n", addr, string(e.what()));
       }
     });
 
@@ -1649,10 +1650,10 @@ void setupLuaConfig(bool client)
   });
 
   g_lua.writeFunction("addDOHLocal", [client](const std::string& addr, boost::variant<std::string, std::vector<std::pair<int,std::string>>> certFiles, boost::variant<std::string, std::vector<std::pair<int,std::string>>> keyFiles, boost::optional<boost::variant<std::string, vector<pair<int, std::string> > > > urls, boost::optional<localbind_t> vars) {
+#ifdef HAVE_DNS_OVER_HTTPS
     if (client) {
       return;
     }
-#ifdef HAVE_DNS_OVER_HTTPS
     setLuaSideEffect();
     if (g_configurationDone) {
       g_outputBuffer="addDOHLocal cannot be used at runtime!\n";
@@ -1708,7 +1709,7 @@ void setupLuaConfig(bool client)
     cs->dohFrontend = frontend;
     g_frontends.push_back(std::move(cs));
 #else
-    g_outputBuffer="DNS over HTTPS support is not present!\n";
+    throw std::runtime_error("addDOHLocal() called but DNS over HTTPS support is not present!");
 #endif
   });
 
@@ -1750,7 +1751,7 @@ void setupLuaConfig(bool client)
         }
         catch(const std::exception& e) {
           g_outputBuffer="Error while trying to get DOH frontend with index " + std::to_string(index) + ": "+string(e.what())+"\n";
-          errlog("Error while trying to get get DOH frontend with index %zu: %s\n", index, string(e.what()));
+          errlog("Error while trying to get DOH frontend with index %zu: %s\n", index, string(e.what()));
         }
 #else
         g_outputBuffer="DNS over HTTPS support is not present!\n";
@@ -1765,9 +1766,9 @@ void setupLuaConfig(bool client)
       });
 
   g_lua.writeFunction("addTLSLocal", [client](const std::string& addr, boost::variant<std::string, std::vector<std::pair<int,std::string>>> certFiles, boost::variant<std::string, std::vector<std::pair<int,std::string>>> keyFiles, boost::optional<localbind_t> vars) {
+#ifdef HAVE_DNS_OVER_TLS
         if (client)
           return;
-#ifdef HAVE_DNS_OVER_TLS
         setLuaSideEffect();
         if (g_configurationDone) {
           g_outputBuffer="addTLSLocal cannot be used at runtime!\n";
@@ -1841,7 +1842,7 @@ void setupLuaConfig(bool client)
           g_outputBuffer="Error: "+string(e.what())+"\n";
         }
 #else
-        g_outputBuffer="DNS over TLS support is not present!\n";
+        throw std::runtime_error("addTLSLocal() called but DNS over TLS support is not present!");
 #endif
       });