bug fixes

This commit is contained in:
John Smith
2022-11-10 21:53:45 -05:00
parent 592c83d83a
commit 9c2a7488f1
13 changed files with 166 additions and 146 deletions

View File

@@ -646,15 +646,16 @@ impl NetworkManager {
/// Get our node's capabilities in the PublicInternet routing domain
fn generate_public_internet_node_status(&self) -> PublicInternetNodeStatus {
let node_info = self
let own_peer_info = self
.routing_table()
.get_own_node_info(RoutingDomain::PublicInternet);
.get_own_peer_info(RoutingDomain::PublicInternet);
let own_node_info = own_peer_info.signed_node_info.node_info();
let will_route = node_info.can_inbound_relay(); // xxx: eventually this may have more criteria added
let will_tunnel = node_info.can_inbound_relay(); // xxx: we may want to restrict by battery life and network bandwidth at some point
let will_signal = node_info.can_signal();
let will_relay = node_info.can_inbound_relay();
let will_validate_dial_info = node_info.can_validate_dial_info();
let will_route = own_node_info.can_inbound_relay(); // xxx: eventually this may have more criteria added
let will_tunnel = own_node_info.can_inbound_relay(); // xxx: we may want to restrict by battery life and network bandwidth at some point
let will_signal = own_node_info.can_signal();
let will_relay = own_node_info.can_inbound_relay();
let will_validate_dial_info = own_node_info.can_validate_dial_info();
PublicInternetNodeStatus {
will_route,
@@ -666,12 +667,14 @@ impl NetworkManager {
}
/// Get our node's capabilities in the LocalNetwork routing domain
fn generate_local_network_node_status(&self) -> LocalNetworkNodeStatus {
let node_info = self
let own_peer_info = self
.routing_table()
.get_own_node_info(RoutingDomain::LocalNetwork);
.get_own_peer_info(RoutingDomain::LocalNetwork);
let will_relay = node_info.can_inbound_relay();
let will_validate_dial_info = node_info.can_validate_dial_info();
let own_node_info = own_peer_info.signed_node_info.node_info();
let will_relay = own_node_info.can_inbound_relay();
let will_validate_dial_info = own_node_info.can_validate_dial_info();
LocalNetworkNodeStatus {
will_relay,
@@ -960,17 +963,18 @@ impl NetworkManager {
}
// Get node's min/max version and see if we can send to it
// and if so, get the max version we can use
let version = if let Some((node_min, node_max)) = node_ref.min_max_version() {
let version = if let Some(min_max_version) = node_ref.min_max_version() {
#[allow(clippy::absurd_extreme_comparisons)]
if node_min > MAX_CRYPTO_VERSION || node_max < MIN_CRYPTO_VERSION {
if min_max_version.min > MAX_CRYPTO_VERSION || min_max_version.max < MIN_CRYPTO_VERSION
{
bail!(
"can't talk to this node {} because version is unsupported: ({},{})",
via_node_id,
node_min,
node_max
min_max_version.min,
min_max_version.max
);
}
cmp::min(node_max, MAX_CRYPTO_VERSION)
cmp::min(min_max_version.max, MAX_CRYPTO_VERSION)
} else {
MAX_CRYPTO_VERSION
};

View File

@@ -129,8 +129,8 @@ impl DiscoveryContext {
move |rti: &RoutingTableInner, _k: DHTKey, v: Option<Arc<BucketEntry>>| {
let v = v.unwrap();
v.with(rti, |_rti, e| {
if let Some(n) = e.node_info(RoutingDomain::PublicInternet) {
n.relay_peer_info.is_none()
if let Some(n) = e.signed_node_info(RoutingDomain::PublicInternet) {
n.relay_id().is_none()
} else {
false
}

View File

@@ -295,15 +295,14 @@ impl NetworkManager {
if let Some(nr) = routing_table.register_node_with_signed_node_info(
RoutingDomain::PublicInternet,
k,
SignedDirectNodeInfo::with_no_signature(NodeInfo {
SignedNodeInfo::Direct(SignedDirectNodeInfo::with_no_signature(NodeInfo {
network_class: NetworkClass::InboundCapable, // Bootstraps are always inbound capable
outbound_protocols: ProtocolTypeSet::only(ProtocolType::UDP), // Bootstraps do not participate in relaying and will not make outbound requests, but will have UDP enabled
address_types: AddressTypeSet::all(), // Bootstraps are always IPV4 and IPV6 capable
min_version: v.min_version, // Minimum crypto version specified in txt record
max_version: v.max_version, // Maximum crypto version specified in txt record
dial_info_detail_list: v.dial_info_details, // Dial info is as specified in the bootstrap list
relay_peer_info: None, // Bootstraps never require a relay themselves
}),
})),
true,
) {
// Add this our futures to process in parallel
@@ -524,7 +523,8 @@ impl NetworkManager {
) -> EyreResult<()> {
// Get our node's current node info and network class and do the right thing
let routing_table = self.routing_table();
let node_info = routing_table.get_own_node_info(RoutingDomain::PublicInternet);
let own_peer_info = routing_table.get_own_peer_info(RoutingDomain::PublicInternet);
let own_node_info = own_peer_info.signed_node_info.node_info();
let network_class = routing_table.get_network_class(RoutingDomain::PublicInternet);
// Get routing domain editor
@@ -541,7 +541,7 @@ impl NetworkManager {
info!("Relay node died, dropping relay {}", relay_node);
editor.clear_relay_node();
false
} else if !node_info.requires_relay() {
} else if !own_node_info.requires_relay() {
info!(
"Relay node no longer required, dropping relay {}",
relay_node
@@ -557,7 +557,7 @@ impl NetworkManager {
};
// Do we need a relay?
if !has_relay && node_info.requires_relay() {
if !has_relay && own_node_info.requires_relay() {
// Do we want an outbound relay?
let mut got_outbound_relay = false;
if network_class.outbound_wants_relay() {
@@ -604,7 +604,7 @@ impl NetworkManager {
) -> EyreResult<()> {
// Get our node's current node info and network class and do the right thing
let routing_table = self.routing_table();
let node_info = routing_table.get_own_node_info(RoutingDomain::PublicInternet);
let own_peer_info = routing_table.get_own_peer_info(RoutingDomain::PublicInternet);
let network_class = routing_table.get_network_class(RoutingDomain::PublicInternet);
// Get routing domain editor