From 56d4422649eee773e4dc61a3d0ea7dfdd97660c1 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Wed, 12 Jun 2019 12:06:59 +0200 Subject: [PATCH] dnsdist: Exit when requested DoT/DoH support is not compiled in --- pdns/dnsdist-lua.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index 71421a186..bf235d557 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -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>> certFiles, boost::variant>> keyFiles, boost::optional > > > urls, boost::optional 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>> certFiles, boost::variant>> keyFiles, boost::optional 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 }); -- 2.49.0