refactoring, more config, packaging

This commit is contained in:
John Smith
2022-05-16 11:52:48 -04:00
parent 444f65d76d
commit ef1f5d7b52
42 changed files with 1329 additions and 368 deletions

View File

@@ -22,20 +22,36 @@ impl RoutingTable {
out
}
pub fn debug_info_dialinfo(&self) -> String {
let ldis = self.dial_info_details(RoutingDomain::LocalNetwork);
let gdis = self.dial_info_details(RoutingDomain::PublicInternet);
let mut out = String::new();
pub fn debug_info_dialinfo(&self, txt_format: bool) -> String {
if txt_format {
let mut out = String::new();
out += "Local Network Dial Info Details:\n";
for (n, ldi) in ldis.iter().enumerate() {
out += &format!(" {:>2}: {:?}\n", n, ldi);
let gdis = self.dial_info_details(RoutingDomain::PublicInternet);
if gdis.is_empty() {
out += "No TXT Record DialInfo\n";
} else {
out += "TXT Record DialInfo:\n";
out += &format!("{}\n", self.node_id().encode());
for gdi in gdis {
out += &format!("{}\n", gdi.dial_info);
}
}
out
} else {
let ldis = self.dial_info_details(RoutingDomain::LocalNetwork);
let gdis = self.dial_info_details(RoutingDomain::PublicInternet);
let mut out = String::new();
out += "Local Network Dial Info Details:\n";
for (n, ldi) in ldis.iter().enumerate() {
out += &format!(" {:>2}: {:?}\n", n, ldi);
}
out += "Public Internet Dial Info Details:\n";
for (n, gdi) in gdis.iter().enumerate() {
out += &format!(" {:>2}: {:?}\n", n, gdi);
}
out
}
out += "Public Internet Dial Info Details:\n";
for (n, gdi) in gdis.iter().enumerate() {
out += &format!(" {:>2}: {:?}\n", n, gdi);
}
out
}
pub fn debug_info_entries(&self, limit: usize, min_state: BucketEntryState) -> String {
let inner = self.inner.lock();

View File

@@ -771,17 +771,36 @@ impl RoutingTable {
}
}
async fn resolve_bootstrap(&self, bootstrap: Vec<String>) -> Result<Vec<String>, String> {
let mut out = Vec::<String>::new();
for bh in bootstrap {
//
}
Ok(out)
}
async fn bootstrap_task_routine(self) -> Result<(), String> {
let bootstrap = {
let (bootstrap, bootstrap_nodes) = {
let c = self.config.get();
c.network.bootstrap.clone()
(
c.network.bootstrap.clone(),
c.network.bootstrap_nodes.clone(),
)
};
log_rtab!("--- bootstrap_task");
// If we aren't specifying a bootstrap node list explicitly, then pull from the bootstrap server(s)
let bootstrap_nodes = if !bootstrap_nodes.is_empty() {
bootstrap_nodes
} else {
// Resolve bootstrap servers and recurse their TXT entries
self.resolve_bootstrap(bootstrap).await?
};
// Map all bootstrap entries to a single key with multiple dialinfo
let mut bsmap: BTreeMap<DHTKey, Vec<DialInfoDetail>> = BTreeMap::new();
for b in bootstrap {
for b in bootstrap_nodes {
let ndis = NodeDialInfo::from_str(b.as_str())
.map_err(map_to_string)
.map_err(logthru_rtab!("Invalid dial info in bootstrap entry: {}", b))?;
@@ -794,7 +813,7 @@ impl RoutingTable {
class: DialInfoClass::Direct, // Bootstraps are always directly reachable
});
}
log_rtab!(" bootstrap list: {:?}", bsmap);
log_rtab!(" bootstrap node dialinfo: {:?}", bsmap);
// Run all bootstrap operations concurrently
let mut unord = FuturesUnordered::new();