518 if (dns_urls.empty())
return false;
520 std::vector<std::vector<std::string> > records;
521 records.resize(dns_urls.size());
526 std::deque<bool> avail(dns_urls.size(),
false), valid(dns_urls.size(),
false);
529 for (
size_t n = 0; n < dns_urls.size(); ++n)
531 tpool.submit(&waiter,[n, dns_urls, &records, &avail, &valid](){
537 size_t cur_index = first_index;
541 if (!avail[cur_index])
543 records[cur_index].clear();
544 LOG_PRINT_L2(
"DNSSEC not available for " << type <<
" at URL: " << url <<
", skipping.");
546 if (!valid[cur_index])
548 records[cur_index].clear();
549 LOG_PRINT_L2(
"DNSSEC validation failed for " << type <<
" at URL: " << url <<
", skipping.");
553 if (cur_index == dns_urls.size())
557 }
while (cur_index != first_index);
559 size_t num_valid_records = 0;
561 for(
const auto& record_set : records)
563 if (record_set.size() != 0)
569 if (num_valid_records < 2)
571 LOG_PRINT_L1(
"WARNING: no two valid ElectroneumPulse DNS " << type <<
" records were received, only " << num_valid_records);
575 int good_records_index = -1;
576 for (
size_t i = 0; i < records.size() - 1; ++i)
578 if (records[i].size() == 0)
continue;
580 for (
size_t j = i + 1; j < records.size(); ++j)
582 if (dns_records_match(records[i], records[j]))
584 good_records_index = i;
588 if (good_records_index >= 0)
break;
591 if (good_records_index < 0)
593 LOG_PRINT_L1(
"WARNING: no two ElectroneumPulse DNS " << type <<
" records matched");
597 good_records = records[good_records_index];
std::enable_if< std::is_unsigned< T >::value, T >::type rand_idx(T sz)