This commit is contained in:
Christien Rioux 2023-09-05 09:44:49 -04:00
parent d5a4be8a36
commit dfcdcf2364

View File

@ -375,7 +375,10 @@ impl DiscoveryContext {
// If we know we are not behind NAT, check our firewall status // If we know we are not behind NAT, check our firewall status
#[instrument(level = "trace", skip(self), ret)] #[instrument(level = "trace", skip(self), ret)]
async fn protocol_process_no_nat(&self) -> DetectedDialInfo { async fn protocol_process_no_nat(
&self,
unord: &mut FuturesUnordered<SendPinBoxFuture<Option<DetectedDialInfo>>>,
) -> DetectedDialInfo {
let external_1 = self.inner.lock().external_1.as_ref().unwrap().clone(); let external_1 = self.inner.lock().external_1.as_ref().unwrap().clone();
// Do a validate_dial_info on the external address from a redirected node // Do a validate_dial_info on the external address from a redirected node
@ -399,7 +402,10 @@ impl DiscoveryContext {
// If we know we are behind NAT check what kind // If we know we are behind NAT check what kind
#[instrument(level = "trace", skip(self), ret)] #[instrument(level = "trace", skip(self), ret)]
async fn protocol_process_nat(&self) -> Option<DetectedDialInfo> { async fn protocol_process_nat(
&self,
unord: &mut FuturesUnordered<SendPinBoxFuture<Option<DetectedDialInfo>>>,
) -> Option<DetectedDialInfo> {
// Get the external dial info for our use here // Get the external dial info for our use here
let external_1 = self.inner.lock().external_1.as_ref().unwrap().clone(); let external_1 = self.inner.lock().external_1.as_ref().unwrap().clone();
let external_2 = self.inner.lock().external_2.as_ref().unwrap().clone(); let external_2 = self.inner.lock().external_2.as_ref().unwrap().clone();
@ -553,30 +559,31 @@ impl DiscoveryContext {
let external_1 = self.inner.lock().external_1.as_ref().unwrap().clone(); let external_1 = self.inner.lock().external_1.as_ref().unwrap().clone();
if self.unlocked_inner.intf_addrs.contains(&external_1.address) { if self.unlocked_inner.intf_addrs.contains(&external_1.address) {
this.protocol_process_no_nat(unord).await self.protocol_process_no_nat(unord).await;
xxx continue here
} else { } else {
// Loop for restricted NAT retries self.protocol_process_nat(unord).await;
let this = self.clone();
let do_nat_fut: SendPinBoxFuture<Option<DetectedDialInfo>> = Box::pin(async move { // // Loop for restricted NAT retries
loop { // let this = self.clone();
// There is -some NAT- // let do_nat_fut: SendPinBoxFuture<Option<DetectedDialInfo>> = Box::pin(async move {
if let Some(ddi) = this.protocol_process_nat().await { // loop {
if let DetectedDialInfo::Detected(did) = &ddi { // // There is -some NAT-
// If we got something better than restricted NAT or we're done retrying // if let Some(ddi) = this.protocol_process_nat().await {
if did.class < DialInfoClass::AddressRestrictedNAT || retry_count == 0 { // if let DetectedDialInfo::Detected(did) = &ddi {
return Some(ddi); // // If we got something better than restricted NAT or we're done retrying
} // if did.class < DialInfoClass::AddressRestrictedNAT || retry_count == 0 {
} // return Some(ddi);
} // }
if retry_count == 0 { // }
break; // }
} // if retry_count == 0 {
retry_count -= 1; // break;
} // }
None // retry_count -= 1;
}); // }
unord.push(do_nat_fut); // None
// });
// unord.push(do_nat_fut);
} }
} }
} }