relay fixes
This commit is contained in:
parent
87694f5f4a
commit
714eca1411
@ -119,6 +119,7 @@ impl DiscoveryContext {
|
|||||||
let c = config.get();
|
let c = config.get();
|
||||||
c.network.dht.max_find_node_count as usize
|
c.network.dht.max_find_node_count as usize
|
||||||
};
|
};
|
||||||
|
let routing_domain = RoutingDomain::PublicInternet;
|
||||||
|
|
||||||
// Build an filter that matches our protocol and address type
|
// Build an filter that matches our protocol and address type
|
||||||
// and excludes relayed nodes so we can get an accurate external address
|
// and excludes relayed nodes so we can get an accurate external address
|
||||||
@ -126,14 +127,14 @@ impl DiscoveryContext {
|
|||||||
.with_protocol_type(protocol_type)
|
.with_protocol_type(protocol_type)
|
||||||
.with_address_type(address_type);
|
.with_address_type(address_type);
|
||||||
let inbound_dial_info_entry_filter = RoutingTable::make_inbound_dial_info_entry_filter(
|
let inbound_dial_info_entry_filter = RoutingTable::make_inbound_dial_info_entry_filter(
|
||||||
RoutingDomain::PublicInternet,
|
routing_domain,
|
||||||
dial_info_filter.clone(),
|
dial_info_filter.clone(),
|
||||||
);
|
);
|
||||||
let disallow_relays_filter = Box::new(
|
let disallow_relays_filter = Box::new(
|
||||||
move |rti: &RoutingTableInner, v: Option<Arc<BucketEntry>>| {
|
move |rti: &RoutingTableInner, v: Option<Arc<BucketEntry>>| {
|
||||||
let v = v.unwrap();
|
let v = v.unwrap();
|
||||||
v.with(rti, |_rti, e| {
|
v.with(rti, |_rti, e| {
|
||||||
if let Some(n) = e.signed_node_info(RoutingDomain::PublicInternet) {
|
if let Some(n) = e.signed_node_info(routing_domain) {
|
||||||
n.relay_ids().is_empty()
|
n.relay_ids().is_empty()
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
@ -141,7 +142,33 @@ impl DiscoveryContext {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
) as RoutingTableEntryFilter;
|
) as RoutingTableEntryFilter;
|
||||||
let filters = VecDeque::from([inbound_dial_info_entry_filter, disallow_relays_filter]);
|
let will_validate_dial_info_filter = Box::new(
|
||||||
|
move |rti: &RoutingTableInner, v: Option<Arc<BucketEntry>>| {
|
||||||
|
let entry = v.unwrap();
|
||||||
|
entry.with(rti, move |_rti, e| {
|
||||||
|
e.node_info(routing_domain)
|
||||||
|
.map(|ni| {
|
||||||
|
ni.has_capability(CAP_VALIDATE_DIAL_INFO) && ni.is_signal_capable()
|
||||||
|
})
|
||||||
|
.unwrap_or(false)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
) as RoutingTableEntryFilter;
|
||||||
|
|
||||||
|
let mut filters = VecDeque::from([
|
||||||
|
inbound_dial_info_entry_filter,
|
||||||
|
disallow_relays_filter,
|
||||||
|
will_validate_dial_info_filter,
|
||||||
|
]);
|
||||||
|
if let Some(ignore_node_ids) = ignore_node_ids {
|
||||||
|
let ignore_nodes_filter = Box::new(
|
||||||
|
move |rti: &RoutingTableInner, v: Option<Arc<BucketEntry>>| {
|
||||||
|
let v = v.unwrap();
|
||||||
|
v.with(rti, |_rti, e| !e.node_ids().contains_any(&ignore_node_ids))
|
||||||
|
},
|
||||||
|
) as RoutingTableEntryFilter;
|
||||||
|
filters.push_back(ignore_nodes_filter);
|
||||||
|
}
|
||||||
|
|
||||||
// Find public nodes matching this filter
|
// Find public nodes matching this filter
|
||||||
let peers = self
|
let peers = self
|
||||||
@ -156,16 +183,11 @@ impl DiscoveryContext {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For each peer, if it's not our ignore-node, ask them for our public address, filtering on desired dial info
|
// For each peer, ask them for our public address, filtering on desired dial info
|
||||||
for mut peer in peers {
|
for mut peer in peers {
|
||||||
if let Some(ignore_node_ids) = &ignore_node_ids {
|
|
||||||
if peer.node_ids().contains_any(ignore_node_ids) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
peer.set_filter(Some(
|
peer.set_filter(Some(
|
||||||
NodeRefFilter::new()
|
NodeRefFilter::new()
|
||||||
.with_routing_domain(RoutingDomain::PublicInternet)
|
.with_routing_domain(routing_domain)
|
||||||
.with_dial_info_filter(dial_info_filter.clone()),
|
.with_dial_info_filter(dial_info_filter.clone()),
|
||||||
));
|
));
|
||||||
if let Some(sa) = self.request_public_address(peer.clone()).await {
|
if let Some(sa) = self.request_public_address(peer.clone()).await {
|
||||||
|
@ -369,8 +369,8 @@ impl RouteSpecStore {
|
|||||||
}
|
}
|
||||||
let opt_relay = match node.locked_mut(rti).relay(RoutingDomain::PublicInternet) {
|
let opt_relay = match node.locked_mut(rti).relay(RoutingDomain::PublicInternet) {
|
||||||
Ok(r) => r,
|
Ok(r) => r,
|
||||||
Err(e) => {
|
Err(_) => {
|
||||||
log_rtab!(error "failed to get relay for route node: {}", e);
|
// Not selecting a relay through ourselves
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -15,6 +15,7 @@ impl RoutingTable {
|
|||||||
};
|
};
|
||||||
let own_node_info = own_peer_info.signed_node_info().node_info();
|
let own_node_info = own_peer_info.signed_node_info().node_info();
|
||||||
let network_class = own_node_info.network_class();
|
let network_class = own_node_info.network_class();
|
||||||
|
let relay_node_filter = self.make_public_internet_relay_node_filter();
|
||||||
|
|
||||||
// Get routing domain editor
|
// Get routing domain editor
|
||||||
let mut editor = self.edit_routing_domain(RoutingDomain::PublicInternet);
|
let mut editor = self.edit_routing_domain(RoutingDomain::PublicInternet);
|
||||||
@ -28,7 +29,18 @@ impl RoutingTable {
|
|||||||
info!("Relay node died, dropping relay {}", relay_node);
|
info!("Relay node died, dropping relay {}", relay_node);
|
||||||
editor.clear_relay_node();
|
editor.clear_relay_node();
|
||||||
false
|
false
|
||||||
} else if !own_node_info.requires_relay() {
|
}
|
||||||
|
// Relay node no longer can relay
|
||||||
|
else if relay_node.operate(|_rti, e| !relay_node_filter(e)) {
|
||||||
|
info!(
|
||||||
|
"Relay node can no longer relay, dropping relay {}",
|
||||||
|
relay_node
|
||||||
|
);
|
||||||
|
editor.clear_relay_node();
|
||||||
|
false
|
||||||
|
}
|
||||||
|
// Relay node is no longer required
|
||||||
|
else if !own_node_info.requires_relay() {
|
||||||
info!(
|
info!(
|
||||||
"Relay node no longer required, dropping relay {}",
|
"Relay node no longer required, dropping relay {}",
|
||||||
relay_node
|
relay_node
|
||||||
|
Loading…
Reference in New Issue
Block a user