From 2e27f7c082e18fe1ac1981a97a070aab8d84bad8 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 26 Aug 2019 15:55:45 -0400 Subject: [PATCH] Always return two tor addresses --- src/datastore.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/datastore.rs b/src/datastore.rs index b4982b3..2dbe370 100644 --- a/src/datastore.rs +++ b/src/datastore.rs @@ -446,11 +446,13 @@ impl Store { { let mut rng = thread_rng(); for i in &[1u64, 4, 5, 8, 9, 12, 13, 1024, 1025, 1028, 1029, 1032, 1033, 1036, 1037] { + let mut tor_set: Vec = Vec::new(); let mut v6_set: Vec = Vec::new(); let mut v4_set: Vec = Vec::new(); macro_rules! add_addr { ($addr: expr) => { match $addr.ip() { IpAddr::V4(v4addr) => v4_set.push(v4addr), + IpAddr::V6(v6addr) if v6addr.octets()[..6] == [0xFD,0x87,0xD8,0x7E,0xEB,0x43][..] => tor_set.push(v6addr), IpAddr::V6(v6addr) => v6_set.push(v6addr), } } } @@ -510,15 +512,10 @@ impl Store { } asn_set.clear(); asn_set.insert(0); - let mut tor_count = 0; - for a in v6_set.iter().filter(|a| { - if a.octets()[..6] != [0xFD,0x87,0xD8,0x7E,0xEB,0x43][..] { - asn_set.insert(bgp_client.get_asn(IpAddr::V6(**a))) - } else { - tor_count += 1; - tor_count <= 2 - } - }).choose_multiple(&mut rng, 12) { + for a in v6_set.iter().filter(|a| asn_set.insert(bgp_client.get_asn(IpAddr::V6(**a)))).choose_multiple(&mut rng, 10) { + dns_buff += &format!("x{:x}.dnsseed\tIN\tAAAA\t{}\n", i, a); + } + for a in tor_set.iter().choose_multiple(&mut rng, 2) { dns_buff += &format!("x{:x}.dnsseed\tIN\tAAAA\t{}\n", i, a); } } -- 2.39.5