From: Remi Gacogne Date: Wed, 12 Jun 2019 10:06:59 +0000 (+0200) Subject: dnsdist: Exit when requested DoT/DoH support is not compiled in X-Git-Tag: dnsdist-1.4.0-rc1~142^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F7915%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Exit when requested DoT/DoH support is not compiled in --- diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index 71421a1862..bf235d5572 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 });