mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-27 05:13:25 +01:00
add more updates domains and make the voting generic, not just 2/3
This commit is contained in:
parent
3cbb44a2fd
commit
aaa3289e22
@ -484,36 +484,12 @@ std::string get_account_address_as_str_from_url(const std::string& url, bool& dn
|
|||||||
return dns_confirm(url, addresses, dnssec_valid);
|
return dns_confirm(url, addresses, dnssec_valid);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
bool dns_records_match(const std::vector<std::string>& a, const std::vector<std::string>& b)
|
|
||||||
{
|
|
||||||
if (a.size() != b.size()) return false;
|
|
||||||
|
|
||||||
for (const auto& record_in_a : a)
|
|
||||||
{
|
|
||||||
bool ok = false;
|
|
||||||
for (const auto& record_in_b : b)
|
|
||||||
{
|
|
||||||
if (record_in_a == record_in_b)
|
|
||||||
{
|
|
||||||
ok = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!ok) return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool load_txt_records_from_dns(std::vector<std::string> &good_records, const std::vector<std::string> &dns_urls)
|
bool load_txt_records_from_dns(std::vector<std::string> &good_records, const std::vector<std::string> &dns_urls)
|
||||||
{
|
{
|
||||||
// Prevent infinite recursion when distributing
|
// Prevent infinite recursion when distributing
|
||||||
if (dns_urls.empty()) return false;
|
if (dns_urls.empty()) return false;
|
||||||
|
|
||||||
std::vector<std::vector<std::string> > records;
|
std::vector<std::set<std::string> > records;
|
||||||
records.resize(dns_urls.size());
|
records.resize(dns_urls.size());
|
||||||
|
|
||||||
size_t first_index = crypto::rand_idx(dns_urls.size());
|
size_t first_index = crypto::rand_idx(dns_urls.size());
|
||||||
@ -525,7 +501,9 @@ bool load_txt_records_from_dns(std::vector<std::string> &good_records, const std
|
|||||||
for (size_t n = 0; n < dns_urls.size(); ++n)
|
for (size_t n = 0; n < dns_urls.size(); ++n)
|
||||||
{
|
{
|
||||||
tpool.submit(&waiter,[n, dns_urls, &records, &avail, &valid](){
|
tpool.submit(&waiter,[n, dns_urls, &records, &avail, &valid](){
|
||||||
records[n] = tools::DNSResolver::instance().get_txt_record(dns_urls[n], avail[n], valid[n]);
|
const auto res = tools::DNSResolver::instance().get_txt_record(dns_urls[n], avail[n], valid[n]);
|
||||||
|
for (const auto &s: res)
|
||||||
|
records[n].insert(s);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
waiter.wait();
|
waiter.wait();
|
||||||
@ -568,29 +546,31 @@ bool load_txt_records_from_dns(std::vector<std::string> &good_records, const std
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int good_records_index = -1;
|
typedef std::map<std::set<std::string>, uint32_t> map_t;
|
||||||
for (size_t i = 0; i < records.size() - 1; ++i)
|
map_t record_count;
|
||||||
|
for (const auto &e: records)
|
||||||
{
|
{
|
||||||
if (records[i].size() == 0) continue;
|
if (!e.empty())
|
||||||
|
++record_count[e];
|
||||||
for (size_t j = i + 1; j < records.size(); ++j)
|
|
||||||
{
|
|
||||||
if (dns_records_match(records[i], records[j]))
|
|
||||||
{
|
|
||||||
good_records_index = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (good_records_index >= 0) break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (good_records_index < 0)
|
map_t::const_iterator good_record = record_count.end();
|
||||||
|
for (map_t::const_iterator i = record_count.begin(); i != record_count.end(); ++i)
|
||||||
{
|
{
|
||||||
LOG_PRINT_L0("WARNING: no two DNS TXT records matched");
|
if (good_record == record_count.end() || i->second > good_record->second)
|
||||||
|
good_record = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
MDEBUG("Found " << (good_record == record_count.end() ? 0 : good_record->second) << "/" << dns_urls.size() << " matching records from " << num_valid_records << " valid records");
|
||||||
|
if (good_record == record_count.end() || good_record->second < dns_urls.size() / 2 + 1)
|
||||||
|
{
|
||||||
|
LOG_PRINT_L0("WARNING: no majority of DNS TXT records matched (only " << good_record->second << "/" << dns_urls.size() << ")");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
good_records = records[good_records_index];
|
good_records = {};
|
||||||
|
for (const auto &s: good_record->first)
|
||||||
|
good_records.push_back(s);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,10 @@ namespace tools
|
|||||||
static const std::vector<std::string> dns_urls = {
|
static const std::vector<std::string> dns_urls = {
|
||||||
"updates.moneropulse.org",
|
"updates.moneropulse.org",
|
||||||
"updates.moneropulse.net",
|
"updates.moneropulse.net",
|
||||||
"updates.moneropulse.co",
|
"updates.moneropulse.fr",
|
||||||
|
"updates.moneropulse.de",
|
||||||
|
"updates.moneropulse.no",
|
||||||
|
"updates.moneropulse.ch",
|
||||||
"updates.moneropulse.se"
|
"updates.moneropulse.se"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
lookup(LOOKUP_A, {"seeds.moneroseeds.se", "seeds.moneroseeds.ae.org", "seeds.moneroseeds.ch", "seeds.moneroseeds.li"});
|
lookup(LOOKUP_A, {"seeds.moneroseeds.se", "seeds.moneroseeds.ae.org", "seeds.moneroseeds.ch", "seeds.moneroseeds.li"});
|
||||||
|
|
||||||
lookup(LOOKUP_TXT, {"updates.moneropulse.org", "updates.moneropulse.net", "updates.moneropulse.co", "updates.moneropulse.se"});
|
lookup(LOOKUP_TXT, {"updates.moneropulse.org", "updates.moneropulse.net", "updates.moneropulse.co", "updates.moneropulse.se", "updates.moneropulse.fr", "updates.moneropulse.de", "updates.moneropulse.no", "updates.moneropulse.ch"});
|
||||||
|
|
||||||
lookup(LOOKUP_TXT, {"checkpoints.moneropulse.org", "checkpoints.moneropulse.net", "checkpoints.moneropulse.co", "checkpoints.moneropulse.se"});
|
lookup(LOOKUP_TXT, {"checkpoints.moneropulse.org", "checkpoints.moneropulse.net", "checkpoints.moneropulse.co", "checkpoints.moneropulse.se"});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user