From 86aae741e0fdcfa8b0fb6317a3ba898d09cb4122 Mon Sep 17 00:00:00 2001 From: Christien Rioux Date: Wed, 13 Sep 2023 17:00:39 -0400 Subject: [PATCH] reverse connect for wasm nodes --- .../src/routing_table/routing_domains.rs | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/veilid-core/src/routing_table/routing_domains.rs b/veilid-core/src/routing_table/routing_domains.rs index 55bcef67..ba120369 100644 --- a/veilid-core/src/routing_table/routing_domains.rs +++ b/veilid-core/src/routing_table/routing_domains.rs @@ -470,7 +470,7 @@ impl RoutingDomainDetail for PublicInternetRoutingDomainDetail { return ContactMethod::Unreachable; }; - // Can we reach the full relay? + // Can we reach the inbound relay? if first_filtered_dial_info_detail_between_nodes( node_a, &node_b_relay, @@ -480,11 +480,30 @@ impl RoutingDomainDetail for PublicInternetRoutingDomainDetail { ) .is_some() { + ///////// Reverse connection + + // Get the best match dial info for an reverse inbound connection from node B to node A + if let Some(reverse_did) = first_filtered_dial_info_detail_between_nodes( + node_b, + node_a, + &dial_info_filter, + sequencing, + dif_sort.clone() + ) { + // Can we receive a direct reverse connection? + if !reverse_did.class.requires_signal() { + return ContactMethod::SignalReverse( + node_b_relay_id, + node_b_id, + ); + } + } + return ContactMethod::InboundRelay(node_b_relay_id); } } - // If node A can't reach the node by other means, it may need to use its own relay + // If node A can't reach the node by other means, it may need to use its outbound relay if peer_a.signed_node_info().node_info().network_class().outbound_wants_relay() { if let Some(node_a_relay_id) = peer_a.signed_node_info().relay_ids().get(best_ck) { // Ensure it's not our relay we're trying to reach