bug fixes

This commit is contained in:
John Smith
2022-12-15 20:52:24 -05:00
parent d089612cbb
commit 10a0e3b629
7 changed files with 58 additions and 27 deletions
+5 -1
View File
@@ -1682,7 +1682,7 @@ impl NetworkManager {
// }
inconsistent
} else {
} else if matches!(public_internet_network_class, NetworkClass::OutboundOnly) {
// If we are currently outbound only, we don't have any public dial info
// but if we are starting to see consistent socket address from multiple reporting peers
// then we may be become inbound capable, so zap the network class so we can re-detect it and any public dial info
@@ -1710,6 +1710,10 @@ impl NetworkManager {
}
}
consistent
} else {
// If we are a webapp we never do this.
// If we have invalid network class, then public address detection is already going to happen via the network_class_discovery task
false
};
if needs_public_address_detection {
@@ -799,12 +799,12 @@ impl RoutingTableInner {
pub fn transform_to_peer_info(
&self,
routing_domain: RoutingDomain,
own_peer_info: PeerInfo,
own_peer_info: &PeerInfo,
k: DHTKey,
v: Option<Arc<BucketEntry>>,
) -> PeerInfo {
match v {
None => own_peer_info,
None => own_peer_info.clone(),
Some(entry) => entry.with(self, |_rti, e| e.make_peer_info(k, routing_domain).unwrap()),
}
}
+6 -13
View File
@@ -92,18 +92,16 @@ impl RPCProcessor {
// add node information for the requesting node to our routing table
let routing_table = self.routing_table();
let own_peer_info = routing_table.get_own_peer_info(RoutingDomain::PublicInternet);
let has_valid_own_node_info = own_peer_info.is_some();
let Some(own_peer_info) = routing_table.get_own_peer_info(RoutingDomain::PublicInternet) else {
// Our own node info is not yet available, drop this request.
return Ok(NetworkResult::service_unavailable());
};
// find N nodes closest to the target node in our routing table
let filter = Box::new(
move |rti: &RoutingTableInner, _k: DHTKey, v: Option<Arc<BucketEntry>>| {
rti.filter_has_valid_signed_node_info(
RoutingDomain::PublicInternet,
has_valid_own_node_info,
v,
)
rti.filter_has_valid_signed_node_info(RoutingDomain::PublicInternet, true, v)
},
) as RoutingTableEntryFilter;
let filters = VecDeque::from([filter]);
@@ -113,12 +111,7 @@ impl RPCProcessor {
filters,
// transform
|rti, k, v| {
rti.transform_to_peer_info(
RoutingDomain::PublicInternet,
own_peer_info.as_ref().unwrap().clone(),
k,
v,
)
rti.transform_to_peer_info(RoutingDomain::PublicInternet, &own_peer_info, k, v)
},
);
+3
View File
@@ -541,6 +541,9 @@ impl VeilidAPI {
NetworkResult::Timeout => {
return Ok("Timeout".to_owned());
}
NetworkResult::ServiceUnavailable => {
return Ok("ServiceUnavailable".to_owned());
}
NetworkResult::NoConnection(e) => {
return Ok(format!("NoConnection({})", e));
}
+13
View File
@@ -8,6 +8,14 @@ macro_rules! apibail_timeout {
};
}
#[allow(unused_macros)]
#[macro_export]
macro_rules! apibail_try_again {
() => {
return Err(VeilidAPIError::try_again())
};
}
#[allow(unused_macros)]
#[macro_export]
macro_rules! apibail_generic {
@@ -95,6 +103,8 @@ pub enum VeilidAPIError {
AlreadyInitialized,
#[error("Timeout")]
Timeout,
#[error("TryAgain")]
TryAgain,
#[error("Shutdown")]
Shutdown,
#[error("Key not found: {key}")]
@@ -131,6 +141,9 @@ impl VeilidAPIError {
pub fn timeout() -> Self {
Self::Timeout
}
pub fn try_again() -> Self {
Self::TryAgain
}
pub fn shutdown() -> Self {
Self::Shutdown
}
@@ -153,6 +153,7 @@ impl RoutingContext {
let answer = match rpc_processor.rpc_call_app_call(dest, request).await {
Ok(NetworkResult::Value(v)) => v,
Ok(NetworkResult::Timeout) => apibail_timeout!(),
Ok(NetworkResult::ServiceUnavailable) => apibail_try_again!(),
Ok(NetworkResult::NoConnection(e)) | Ok(NetworkResult::AlreadyExists(e)) => {
apibail_no_connection!(e);
}
@@ -181,6 +182,7 @@ impl RoutingContext {
match rpc_processor.rpc_call_app_message(dest, message).await {
Ok(NetworkResult::Value(())) => {}
Ok(NetworkResult::Timeout) => apibail_timeout!(),
Ok(NetworkResult::ServiceUnavailable) => apibail_try_again!(),
Ok(NetworkResult::NoConnection(e)) | Ok(NetworkResult::AlreadyExists(e)) => {
apibail_no_connection!(e);
}