mirror of
https://gitlab.com/veilid/veilid.git
synced 2024-12-25 07:19:26 -05:00
fixes
This commit is contained in:
parent
75ade4200a
commit
4d65903ee4
@ -348,20 +348,22 @@ impl DiscoveryContext {
|
|||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Attempt a port mapping via all available and enabled mechanisms
|
||||||
|
// Try this before the direct mapping in the event that we are restarting
|
||||||
|
// and may not have recorded a mapping created the last time
|
||||||
|
if let Some(external_mapped_dial_info) = self.try_port_mapping().await {
|
||||||
|
// Got a port mapping, let's use it
|
||||||
|
self.set_detected_public_dial_info(external_mapped_dial_info, DialInfoClass::Mapped);
|
||||||
|
self.set_detected_network_class(NetworkClass::InboundCapable);
|
||||||
|
}
|
||||||
// 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
|
||||||
if self
|
else if self
|
||||||
.validate_dial_info(node_1.clone(), external_1_dial_info.clone(), true)
|
.validate_dial_info(node_1.clone(), external_1_dial_info.clone(), true)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
// Add public dial info with Direct dialinfo class
|
// Add public dial info with Direct dialinfo class
|
||||||
self.set_detected_public_dial_info(external_1_dial_info, DialInfoClass::Direct);
|
self.set_detected_public_dial_info(external_1_dial_info, DialInfoClass::Direct);
|
||||||
self.set_detected_network_class(NetworkClass::InboundCapable);
|
self.set_detected_network_class(NetworkClass::InboundCapable);
|
||||||
}
|
|
||||||
// Attempt a port mapping via all available and enabled mechanisms
|
|
||||||
else if let Some(external_mapped_dial_info) = self.try_port_mapping().await {
|
|
||||||
// Got a port mapping, let's use it
|
|
||||||
self.set_detected_public_dial_info(external_mapped_dial_info, DialInfoClass::Mapped);
|
|
||||||
self.set_detected_network_class(NetworkClass::InboundCapable);
|
|
||||||
} else {
|
} else {
|
||||||
// Add public dial info with Blocked dialinfo class
|
// Add public dial info with Blocked dialinfo class
|
||||||
self.set_detected_public_dial_info(external_1_dial_info, DialInfoClass::Blocked);
|
self.set_detected_public_dial_info(external_1_dial_info, DialInfoClass::Blocked);
|
||||||
@ -384,8 +386,19 @@ impl DiscoveryContext {
|
|||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Attempt a port mapping via all available and enabled mechanisms
|
||||||
|
// Try this before the direct mapping in the event that we are restarting
|
||||||
|
// and may not have recorded a mapping created the last time
|
||||||
|
if let Some(external_mapped_dial_info) = self.try_port_mapping().await {
|
||||||
|
// Got a port mapping, let's use it
|
||||||
|
self.set_detected_public_dial_info(external_mapped_dial_info, DialInfoClass::Mapped);
|
||||||
|
self.set_detected_network_class(NetworkClass::InboundCapable);
|
||||||
|
|
||||||
|
// No more retries
|
||||||
|
return Ok(true);
|
||||||
|
}
|
||||||
// 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
|
||||||
if self
|
else if self
|
||||||
.validate_dial_info(node_1.clone(), external_1_dial_info.clone(), true)
|
.validate_dial_info(node_1.clone(), external_1_dial_info.clone(), true)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
@ -394,17 +407,9 @@ impl DiscoveryContext {
|
|||||||
self.set_detected_network_class(NetworkClass::InboundCapable);
|
self.set_detected_network_class(NetworkClass::InboundCapable);
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
// Attempt a port mapping via all available and enabled mechanisms
|
|
||||||
else if let Some(external_mapped_dial_info) = self.try_port_mapping().await {
|
|
||||||
// Got a port mapping, let's use it
|
|
||||||
self.set_detected_public_dial_info(external_mapped_dial_info, DialInfoClass::Mapped);
|
|
||||||
self.set_detected_network_class(NetworkClass::InboundCapable);
|
|
||||||
|
|
||||||
// No more retries
|
// Port mapping was not possible, and things aren't accessible directly.
|
||||||
return Ok(true);
|
// Let's see what kind of NAT we have
|
||||||
}
|
|
||||||
|
|
||||||
// Port mapping was not possible, let's see what kind of NAT we have
|
|
||||||
|
|
||||||
// Does a redirected dial info validation from a different address and a random port find us?
|
// Does a redirected dial info validation from a different address and a random port find us?
|
||||||
if self
|
if self
|
||||||
|
@ -258,5 +258,11 @@ pub fn ipaddr_apply_netmask(addr: IpAddr, netmask: IpAddr) -> IpAddr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn ipaddr_in_network(addr: IpAddr, netaddr: IpAddr, netmask: IpAddr) -> bool {
|
pub fn ipaddr_in_network(addr: IpAddr, netaddr: IpAddr, netmask: IpAddr) -> bool {
|
||||||
|
if addr.is_ipv4() && !netaddr.is_ipv4() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if addr.is_ipv6() && !netaddr.is_ipv6() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
ipaddr_apply_netmask(netaddr, netmask) == ipaddr_apply_netmask(addr, netmask)
|
ipaddr_apply_netmask(netaddr, netmask) == ipaddr_apply_netmask(addr, netmask)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user