Skip to content

Commit

Permalink
Add shuffling of dns services
Browse files Browse the repository at this point in the history
  • Loading branch information
SoraSuegami committed Nov 5, 2024
1 parent 4cf68b0 commit e7751df
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/dns_client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,21 @@ pub async fn get_dkim_public_key(
#[cfg(not(debug_assertions))]
let prefixes = vec![
"https://dns.google/resolve",
"https://dns.nextdns.io/dns-query",
"https://cloudflare-dns.com/dns-query",
"https://dns.nextdns.io/dns-query",
];

#[cfg(debug_assertions)]
let prefixes = vec!["https://dns.google/resolve"];

let seed = (ic_cdk::api::time() % 3) as usize;
let mut shuffled_prefixes = vec![];
for i in 0..3 {
shuffled_prefixes.push(prefixes[(seed + i) % 3]);
}

let mut errors = vec![];
for prefix in prefixes {
for prefix in shuffled_prefixes {
let request = _construct_request(prefix, &selector, &domain);
match http_request(request, cycle as u128).await {
// Decode and return the response.
Expand Down

0 comments on commit e7751df

Please sign in to comment.