fix errors on no internet

This commit is contained in:
John Smith 2022-08-04 10:35:19 -04:00
parent 54f8676340
commit 44cde7a939
2 changed files with 35 additions and 22 deletions

View File

@ -515,19 +515,27 @@ impl NetworkManager {
} }
pub async fn tick(&self) -> EyreResult<()> { pub async fn tick(&self) -> EyreResult<()> {
let (routing_table, net, receipt_manager) = { let (routing_table, net, receipt_manager, protocol_config) = {
let inner = self.inner.lock(); let inner = self.inner.lock();
let components = inner.components.as_ref().unwrap(); let components = inner.components.as_ref().unwrap();
let protocol_config = inner.protocol_config.as_ref().unwrap();
( (
inner.routing_table.as_ref().unwrap().clone(), inner.routing_table.as_ref().unwrap().clone(),
components.net.clone(), components.net.clone(),
components.receipt_manager.clone(), components.receipt_manager.clone(),
protocol_config.clone(),
) )
}; };
// Run the rolling transfers task // Run the rolling transfers task
self.unlocked_inner.rolling_transfers_task.tick().await?; self.unlocked_inner.rolling_transfers_task.tick().await?;
// Process global peer scope ticks
// These only make sense when connected to the actual internet and not just the local network
// Must have at least one outbound protocol enabled, and one global peer scope address family enabled
let global_peer_scope_enabled =
!protocol_config.outbound.is_empty() && !protocol_config.family_global.is_empty();
if global_peer_scope_enabled {
// Run the relay management task // Run the relay management task
self.unlocked_inner.relay_management_task.tick().await?; self.unlocked_inner.relay_management_task.tick().await?;
@ -548,6 +556,7 @@ impl NetworkManager {
// Ping validate some nodes to groom the table // Ping validate some nodes to groom the table
self.unlocked_inner.ping_validator_task.tick().await?; self.unlocked_inner.ping_validator_task.tick().await?;
}
// Run the routing table tick // Run the routing table tick
routing_table.tick().await?; routing_table.tick().await?;

View File

@ -90,9 +90,9 @@ impl Network {
tcp_port: 0u16, tcp_port: 0u16,
ws_port: 0u16, ws_port: 0u16,
wss_port: 0u16, wss_port: 0u16,
enable_ipv4: true, enable_ipv4: false,
enable_ipv6_global: true, enable_ipv6_global: false,
enable_ipv6_local: true, enable_ipv6_local: false,
bound_first_udp: BTreeMap::new(), bound_first_udp: BTreeMap::new(),
inbound_udp_protocol_handlers: BTreeMap::new(), inbound_udp_protocol_handlers: BTreeMap::new(),
outbound_udpv4_protocol_handler: None, outbound_udpv4_protocol_handler: None,
@ -549,14 +549,18 @@ impl Network {
// determine if we have ipv4/ipv6 addresses // determine if we have ipv4/ipv6 addresses
{ {
let mut inner = self.inner.lock(); let mut inner = self.inner.lock();
inner.enable_ipv4 = false;
for addr in self.unlocked_inner.interfaces.best_addresses() { for addr in self.unlocked_inner.interfaces.best_addresses() {
if addr.is_ipv4() { if addr.is_ipv4() {
log_net!(debug "enable address {:?} as ipv4", addr);
inner.enable_ipv4 = true; inner.enable_ipv4 = true;
} else if addr.is_ipv6() { } else if addr.is_ipv6() {
let address = crate::Address::from_ip_addr(addr); let address = crate::Address::from_ip_addr(addr);
if address.is_global() { if address.is_global() {
log_net!(debug "enable address {:?} as ipv6 global", address);
inner.enable_ipv6_global = true; inner.enable_ipv6_global = true;
} else if address.is_local() { } else if address.is_local() {
log_net!(debug "enable address {:?} as ipv6 local", address);
inner.enable_ipv6_local = true; inner.enable_ipv6_local = true;
} }
} }