From 248b21a951bc542a3288f26a9ea4812819293fdb Mon Sep 17 00:00:00 2001 From: Christien Rioux Date: Thu, 24 Aug 2023 18:59:33 -0400 Subject: [PATCH] proper relay switch, fix wasm --- .../src/network_manager/types/network_class.rs | 5 +++++ .../src/routing_table/routing_domains.rs | 17 ++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/veilid-core/src/network_manager/types/network_class.rs b/veilid-core/src/network_manager/types/network_class.rs index 0570b9d2..e1389333 100644 --- a/veilid-core/src/network_manager/types/network_class.rs +++ b/veilid-core/src/network_manager/types/network_class.rs @@ -15,6 +15,11 @@ impl Default for NetworkClass { } impl NetworkClass { + // Must an inbound relay be kept available? + // In the case of InboundCapable, it is left up to the class of each DialInfo to determine if an inbound relay is required + pub fn inbound_wants_relay(&self) -> bool { + matches!(self, Self::OutboundOnly | Self::WebApp) + } // Should an outbound relay be kept available? pub fn outbound_wants_relay(&self) -> bool { matches!(self, Self::WebApp) diff --git a/veilid-core/src/routing_table/routing_domains.rs b/veilid-core/src/routing_table/routing_domains.rs index 8cd35df1..6e4bec50 100644 --- a/veilid-core/src/routing_table/routing_domains.rs +++ b/veilid-core/src/routing_table/routing_domains.rs @@ -130,13 +130,16 @@ impl RoutingDomainDetailCommon { // Check if any of our dialinfo require a relay for signaling // FullConeNAT requires a relay but it does not have to be published because it does not require signaling - let mut publish_relay = false; - for did in self.dial_info_details() { - if did.class.requires_signal() { - publish_relay = true; - break; - } - } + let mut publish_relay = node_info.network_class().inbound_wants_relay() || node_info.network_class().outbound_wants_relay(); + if !publish_relay { + // Check the dialinfo to see if they might want to publish a relay for signalling specifically + for did in self.dial_info_details() { + if did.class.requires_signal() { + publish_relay = true; + break; + } + } + } let relay_info = if publish_relay { self