aboutsummaryrefslogtreecommitdiff
path: root/src/common/dns_utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/dns_utils.cpp')
-rw-r--r--src/common/dns_utils.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/common/dns_utils.cpp b/src/common/dns_utils.cpp
index e7ff11c5c..1310b8bfd 100644
--- a/src/common/dns_utils.cpp
+++ b/src/common/dns_utils.cpp
@@ -27,8 +27,6 @@
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "common/dns_utils.h"
-#include "common/i18n.h"
-#include "cryptonote_basic/cryptonote_basic_impl.h"
// check local first (in the event of static or in-source compilation of libunbound)
#include "unbound.h"
@@ -326,8 +324,6 @@ bool DNSResolver::check_address_syntax(const char *addr) const
namespace dns_utils
{
-const char *tr(const char *str) { return i18n_translate(str, "tools::dns_utils"); }
-
//-----------------------------------------------------------------------
// TODO: parse the string in a less stupid way, probably with regex
std::string address_from_txt_record(const std::string& s)
@@ -447,19 +443,28 @@ bool load_txt_records_from_dns(std::vector<std::string> &good_records, const std
std::uniform_int_distribution<int> dis(0, dns_urls.size() - 1);
size_t first_index = dis(gen);
- bool avail, valid;
+ // send all requests in parallel
+ std::vector<boost::thread> threads(dns_urls.size());
+ std::deque<bool> avail(dns_urls.size(), false), valid(dns_urls.size(), false);
+ for (size_t n = 0; n < dns_urls.size(); ++n)
+ {
+ threads[n] = boost::thread([n, dns_urls, &records, &avail, &valid](){
+ records[n] = tools::DNSResolver::instance().get_txt_record(dns_urls[n], avail[n], valid[n]);
+ });
+ }
+ for (size_t n = 0; n < dns_urls.size(); ++n)
+ threads[n].join();
+
size_t cur_index = first_index;
do
{
- std::string url = dns_urls[cur_index];
-
- records[cur_index] = tools::DNSResolver::instance().get_txt_record(url, avail, valid);
- if (!avail)
+ const std::string &url = dns_urls[cur_index];
+ if (!avail[cur_index])
{
records[cur_index].clear();
LOG_PRINT_L2("DNSSEC not available for checkpoint update at URL: " << url << ", skipping.");
}
- if (!valid)
+ if (!valid[cur_index])
{
records[cur_index].clear();
LOG_PRINT_L2("DNSSEC validation failed for checkpoint update at URL: " << url << ", skipping.");