ipv6 nat
This commit is contained in:
		| @@ -622,37 +622,58 @@ impl Network { | |||||||
|         context: &DiscoveryContext, |         context: &DiscoveryContext, | ||||||
|         protocol_type: ProtocolType, |         protocol_type: ProtocolType, | ||||||
|     ) -> EyreResult<()> { |     ) -> EyreResult<()> { | ||||||
|  |         let mut retry_count = { | ||||||
|  |             let c = self.config.get(); | ||||||
|  |             c.network.restricted_nat_retries | ||||||
|  |         }; | ||||||
|  |  | ||||||
|         // Start doing ipv6 protocol |         // Start doing ipv6 protocol | ||||||
|         context.protocol_begin(protocol_type, AddressType::IPV6); |         context.protocol_begin(protocol_type, AddressType::IPV6); | ||||||
|  |  | ||||||
|         log_net!(debug "=== update_ipv6_protocol_dialinfo {:?} ===", protocol_type); |         // Loop for restricted NAT retries | ||||||
|  |         loop { | ||||||
|  |             log_net!(debug | ||||||
|  |                 "=== update_ipv6_protocol_dialinfo {:?} tries_left={} ===", | ||||||
|  |                 protocol_type, | ||||||
|  |                 retry_count | ||||||
|  |             ); | ||||||
|             // Get our external address from some fast node, call it node 1 |             // Get our external address from some fast node, call it node 1 | ||||||
|             if !context.protocol_get_external_address_1().await { |             if !context.protocol_get_external_address_1().await { | ||||||
|                 // If we couldn't get an external address, then we should just try the whole network class detection again later |                 // If we couldn't get an external address, then we should just try the whole network class detection again later | ||||||
|                 return Ok(()); |                 return Ok(()); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|         // If our local interface list doesn't contain external_1 then there is an Ipv6 NAT in place |             // If our local interface list contains external_1 then there is no NAT in place | ||||||
|             { |             { | ||||||
|  |                 let res = { | ||||||
|                     let inner = context.inner.lock(); |                     let inner = context.inner.lock(); | ||||||
|             if !inner |                     inner | ||||||
|                         .intf_addrs |                         .intf_addrs | ||||||
|                         .as_ref() |                         .as_ref() | ||||||
|                         .unwrap() |                         .unwrap() | ||||||
|                         .contains(inner.external_1_address.as_ref().unwrap()) |                         .contains(inner.external_1_address.as_ref().unwrap()) | ||||||
|             { |                 }; | ||||||
|                 // IPv6 NAT is not supported today |                 if res { | ||||||
|                 log_net!(warn |                     // No NAT | ||||||
|                     "IPv6 NAT is not supported for external address: {}", |                     context.protocol_process_no_nat().await?; | ||||||
|                     inner.external_1_address.unwrap() |  | ||||||
|                 ); |                     // No more retries | ||||||
|                 return Ok(()); |                     break; | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|         // No NAT |             // There is -some NAT- | ||||||
|         context.protocol_process_no_nat().await?; |             if context.protocol_process_nat().await? { | ||||||
|  |                 // We either got dial info or a network class without one | ||||||
|  |                 break; | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             // If we tried everything, break anyway after N attempts | ||||||
|  |             if retry_count == 0 { | ||||||
|  |                 break; | ||||||
|  |             } | ||||||
|  |             retry_count -= 1; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         Ok(()) |         Ok(()) | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
| use super::*; | use super::*; | ||||||
|  |  | ||||||
|  | // Ordering here matters, IPV6 is preferred to IPV4 in dial info sorts | ||||||
|  | // See issue #236 for eventual resolution of this unfortunate implementation | ||||||
| #[derive( | #[derive( | ||||||
|     Copy, |     Copy, | ||||||
|     Clone, |     Clone, | ||||||
| @@ -17,8 +19,8 @@ use super::*; | |||||||
| )] | )] | ||||||
| #[archive_attr(repr(u8), derive(CheckBytes))] | #[archive_attr(repr(u8), derive(CheckBytes))] | ||||||
| pub enum Address { | pub enum Address { | ||||||
|     IPV4(Ipv4Addr), |  | ||||||
|     IPV6(Ipv6Addr), |     IPV6(Ipv6Addr), | ||||||
|  |     IPV4(Ipv4Addr), | ||||||
| } | } | ||||||
|  |  | ||||||
| impl Default for Address { | impl Default for Address { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user