proper relay switch, fix wasm

This commit is contained in:
Christien Rioux 2023-08-24 18:59:33 -04:00
parent a9c173e52f
commit 248b21a951
2 changed files with 15 additions and 7 deletions

View File

@ -15,6 +15,11 @@ impl Default for NetworkClass {
} }
impl 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? // Should an outbound relay be kept available?
pub fn outbound_wants_relay(&self) -> bool { pub fn outbound_wants_relay(&self) -> bool {
matches!(self, Self::WebApp) matches!(self, Self::WebApp)

View File

@ -130,11 +130,14 @@ impl RoutingDomainDetailCommon {
// Check if any of our dialinfo require a relay for signaling // 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 // FullConeNAT requires a relay but it does not have to be published because it does not require signaling
let mut publish_relay = false; let mut publish_relay = node_info.network_class().inbound_wants_relay() || node_info.network_class().outbound_wants_relay();
for did in self.dial_info_details() { if !publish_relay {
if did.class.requires_signal() { // Check the dialinfo to see if they might want to publish a relay for signalling specifically
publish_relay = true; for did in self.dial_info_details() {
break; if did.class.requires_signal() {
publish_relay = true;
break;
}
} }
} }