hole punch work
This commit is contained in:
parent
48cd02c39d
commit
f8c7dba1cf
@ -718,7 +718,6 @@ impl NetworkManager {
|
|||||||
let routing_table = self.routing_table();
|
let routing_table = self.routing_table();
|
||||||
|
|
||||||
// Get our network class and protocol config and node id
|
// Get our network class and protocol config and node id
|
||||||
let our_node_id = routing_table.node_id();
|
|
||||||
let our_network_class = self.get_network_class().unwrap_or(NetworkClass::Invalid);
|
let our_network_class = self.get_network_class().unwrap_or(NetworkClass::Invalid);
|
||||||
let our_protocol_config = self.get_protocol_config().unwrap();
|
let our_protocol_config = self.get_protocol_config().unwrap();
|
||||||
|
|
||||||
@ -913,18 +912,13 @@ impl NetworkManager {
|
|||||||
data: Vec<u8>,
|
data: Vec<u8>,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
// Ensure we are filtered down to UDP (the only hole punch protocol supported today)
|
// Ensure we are filtered down to UDP (the only hole punch protocol supported today)
|
||||||
assert!(relay_nr
|
|
||||||
.filter_ref()
|
|
||||||
.map(|dif| dif.protocol_set == ProtocolSet::only(ProtocolType::UDP))
|
|
||||||
.unwrap_or_default());
|
|
||||||
assert!(target_nr
|
assert!(target_nr
|
||||||
.filter_ref()
|
.filter_ref()
|
||||||
.map(|dif| dif.protocol_set == ProtocolSet::only(ProtocolType::UDP))
|
.map(|dif| dif.protocol_set == ProtocolSet::only(ProtocolType::UDP))
|
||||||
.unwrap_or_default());
|
.unwrap_or_default());
|
||||||
|
|
||||||
// Build a return receipt for the signal
|
// Build a return receipt for the signal
|
||||||
let receipt_timeout =
|
let receipt_timeout = ms_to_us(self.config.get().network.hole_punch_receipt_time_ms);
|
||||||
ms_to_us(self.config.get().network.reverse_connection_receipt_time_ms);
|
|
||||||
let (receipt, eventual_value) = self
|
let (receipt, eventual_value) = self
|
||||||
.generate_single_shot_receipt(receipt_timeout, [])
|
.generate_single_shot_receipt(receipt_timeout, [])
|
||||||
.map_err(map_to_string)?;
|
.map_err(map_to_string)?;
|
||||||
@ -1131,6 +1125,13 @@ impl NetworkManager {
|
|||||||
// Network accounting
|
// Network accounting
|
||||||
self.stats_packet_rcvd(descriptor.remote_address().to_ip_addr(), data.len() as u64);
|
self.stats_packet_rcvd(descriptor.remote_address().to_ip_addr(), data.len() as u64);
|
||||||
|
|
||||||
|
// If this is a zero length packet, just drop it, because these are used for hole punching
|
||||||
|
// and possibly other low-level network connectivity tasks and will never require
|
||||||
|
// more processing or forwarding
|
||||||
|
if data.len() == 0 {
|
||||||
|
return Ok(true);
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure we can read the magic number
|
// Ensure we can read the magic number
|
||||||
if data.len() < 4 {
|
if data.len() < 4 {
|
||||||
return Err("short packet".to_owned());
|
return Err("short packet".to_owned());
|
||||||
|
Loading…
Reference in New Issue
Block a user