use regex::Regex;
+use crate::bgp_client::BGPClient;
+
#[derive(Clone, Copy, Hash, PartialEq, Eq)]
pub enum AddressState {
Untested,
tokio::fs::rename(nodes_file.clone() + ".tmp", nodes_file)
});
+ settings_future.join(nodes_future).then(|_| { future::ok(()) })
+ }
+
+ pub fn write_dns(&'static self, bgp_client: Arc<BGPClient>) -> impl Future<Item=(), Error=()> {
let dns_file = self.store.clone() + "/nodes.dump";
- let dns_future = File::create(dns_file.clone() + ".tmp").and_then(move |f| {
+ File::create(dns_file.clone() + ".tmp").and_then(move |f| {
let mut dns_buff = String::new();
{
let mut rng = thread_rng();
.filter(|e| e.is_ipv6() && e.port() == 8333).map(|e| e.ip()).collect();
}
}
- for a in v4_set.iter().choose_multiple(&mut rng, 21) {
+ let mut asn_set = HashSet::with_capacity(cmp::max(v4_set.len(), v6_set.len()));
+ for a in v4_set.iter().filter(|a| asn_set.insert(bgp_client.get_asn(**a))).choose_multiple(&mut rng, 21) {
dns_buff += &format!("x{:x}.dnsseed\tIN\tA\t{}\n", i, a);
}
- for a in v6_set.iter().choose_multiple(&mut rng, 12) {
+ asn_set.clear();
+ for a in v6_set.iter().filter(|a| asn_set.insert(bgp_client.get_asn(**a))).choose_multiple(&mut rng, 12) {
dns_buff += &format!("x{:x}.dnsseed\tIN\tAAAA\t{}\n", i, a);
}
}
f.poll_sync_all()
}).and_then(|_| {
tokio::fs::rename(dns_file.clone() + ".tmp", dns_file)
- });
-
- settings_future.join3(nodes_future, dns_future).then(|_| { future::ok(()) })
+ }).then(|_| { future::ok(()) })
}
pub fn get_next_scan_nodes(&self) -> Vec<SocketAddr> {