setSyslogFacility(facility);
});
- 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<vector<pair<int, std::string> > > urls, boost::optional<localbind_t> vars) {
+ 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) {
if (client) {
return;
}
}
frontend->d_local = ComboAddress(addr, 443);
- if(urls && !urls->empty()) {
- for(const auto& p : *urls) {
- frontend->d_urls.push_back(p.second);
+ if (urls) {
+ if (urls->type() == typeid(std::string)) {
+ frontend->d_urls.push_back(boost::get<std::string>(*urls));
+ }
+ else if (urls->type() == typeid(std::vector<std::pair<int,std::string>>)) {
+ auto urlsVect = boost::get<std::vector<std::pair<int,std::string>>>(*urls);
+ for(const auto& p : urlsVect) {
+ frontend->d_urls.push_back(p.second);
+ }
}
}
else {
result = g_dohlocals.at(index);
}
else {
- errlog("Error: trying to get DOH frontend with index %zu but we only have %zu\n", index, g_dohlocals.size());
- g_outputBuffer="Error: trying to get DOH frontend with index " + std::to_string(index) + " but we only have " + std::to_string(g_dohlocals.size()) + "\n";
+ errlog("Error: trying to get DOH frontend with index %zu but we only have %zu frontend(s)\n", index, g_dohlocals.size());
+ g_outputBuffer="Error: trying to get DOH frontend with index " + std::to_string(index) + " but we only have " + std::to_string(g_dohlocals.size()) + " frontend(s)\n";
}
}
catch(const std::exception& e) {
- g_outputBuffer="Error: "+string(e.what())+"\n";
- errlog("Error: %s\n", string(e.what()));
+ 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()));
}
#else
g_outputBuffer="DNS over HTTPS support is not present!\n";
result = g_tlslocals.at(index)->getContext();
}
else {
- errlog("Error: trying to get TLS context with index %zu but we only have %zu\n", index, g_tlslocals.size());
- g_outputBuffer="Error: trying to get TLS context with index " + std::to_string(index) + " but we only have " + std::to_string(g_tlslocals.size()) + "\n";
+ errlog("Error: trying to get TLS context with index %zu but we only have %zu context(s)\n", index, g_tlslocals.size());
+ g_outputBuffer="Error: trying to get TLS context with index " + std::to_string(index) + " but we only have " + std::to_string(g_tlslocals.size()) + " context(s)\n";
}
}
catch(const std::exception& e) {
- g_outputBuffer="Error: "+string(e.what())+"\n";
- errlog("Error: %s\n", string(e.what()));
+ g_outputBuffer="Error while trying to get TLS context with index " + std::to_string(index) + ": "+string(e.what())+"\n";
+ errlog("Error while trying to get TLS context with index %zu: %s\n", index, string(e.what()));
}
#else
g_outputBuffer="DNS over TLS support is not present!\n";
result = g_tlslocals.at(index);
}
else {
- errlog("Error: trying to get TLS frontend with index %zu but we only have %zu\n", index, g_tlslocals.size());
- g_outputBuffer="Error: trying to get TLS frontend with index " + std::to_string(index) + " but we only have " + std::to_string(g_tlslocals.size()) + "\n";
+ errlog("Error: trying to get TLS frontend with index %zu but we only have %zu frontends\n", index, g_tlslocals.size());
+ g_outputBuffer="Error: trying to get TLS frontend with index " + std::to_string(index) + " but we only have " + std::to_string(g_tlslocals.size()) + " frontend(s)\n";
}
}
catch(const std::exception& e) {
- g_outputBuffer="Error: "+string(e.what())+"\n";
- errlog("Error: %s\n", string(e.what()));
+ g_outputBuffer="Error while trying to get TLS frontend with index " + std::to_string(index) + ": "+string(e.what())+"\n";
+ errlog("Error while trying to get TLS frontend with index %zu: %s\n", index, string(e.what()));
}
#else
g_outputBuffer="DNS over TLS support is not present!\n";
higher than 0 to enable TCP Fast Open when available.
Default is 0.
-.. function:: addDOHLocal(address, certFile(s), keyFile(s) [, url [, options]])
+.. function:: addDOHLocal(address, certFile(s), keyFile(s) [, urls [, options]])
.. versionadded:: 1.4.0
The default port is 443.
:param str certFile(s): The path to a X.509 certificate file in PEM format, or a list of paths to such files.
:param str keyFile(s): The path to the private key file corresponding to the certificate, or a list of paths to such files, whose order should match the certFile(s) ones.
- :param list url: A list of URLs to accept queries on. The default is /.
+ :param str or list urls: A base URL, or a list of base URLs, to accept queries on. Any query with a path under one of these will be treated as a DoH query. The default is /.
:param table options: A table with key: value pairs with listen options.
Options: