fix do nothing packets chaos
This commit is contained in:
+1
-1
@@ -287,7 +287,7 @@ fn main() -> std::io::Result<()> {
|
||||
socket.clone(),
|
||||
data_lenght,
|
||||
))
|
||||
.detach();
|
||||
.await;
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!(
|
||||
|
||||
+14
-3
@@ -413,7 +413,7 @@ pub fn P2P_hello(
|
||||
}
|
||||
|
||||
pub async fn handle_incoming_connection(
|
||||
mut buf: [u8; UDP_BUFFER_SIZE],
|
||||
buf: [u8; UDP_BUFFER_SIZE],
|
||||
src: SocketAddr,
|
||||
network: Arc<RwLock<types::Network>>,
|
||||
tun_iface: Arc<tappers::Tun>,
|
||||
@@ -425,7 +425,7 @@ pub async fn handle_incoming_connection(
|
||||
match buf[0] {
|
||||
x if x == P2PMethods::PACKET as u8 => {
|
||||
#[cfg(debug_assertions)]
|
||||
println!("PACKET from difernt peer receved");
|
||||
println!("PACKET from different peer receved");
|
||||
|
||||
if network.read().unwrap().encrypted {
|
||||
match shared::crypto::decrypt(
|
||||
@@ -511,6 +511,11 @@ pub async fn handle_incoming_connection(
|
||||
x if x == P2PMethods::PEER_HELLO as u8 => {
|
||||
println!("{} peer hello receved from: {}", "[LOG]".blue(), src);
|
||||
|
||||
if data_lenght - 1 < P2PStandardDataPositions::DATA as usize {
|
||||
eprintln!("{} peer hello packet too small", "[ERROR]".red());
|
||||
return;
|
||||
}
|
||||
|
||||
let tmp_data: Vec<u8>;
|
||||
{
|
||||
let mut network_write_lock = network.write().unwrap();
|
||||
@@ -677,7 +682,7 @@ pub async fn handle_incoming_connection(
|
||||
}
|
||||
};
|
||||
for _ in 0..MAPPING_SHOT_COUNT {
|
||||
match socket.send_to(&[P2PMethods::PEER_QUERY as u8], peer_addr) {
|
||||
match socket.send_to(&[P2PMethods::DO_NOTHING as u8], peer_addr) {
|
||||
Ok(s) => {
|
||||
#[cfg(debug_assertions)]
|
||||
eprintln!("send {} bytes", s);
|
||||
@@ -686,6 +691,12 @@ pub async fn handle_incoming_connection(
|
||||
}
|
||||
}
|
||||
}
|
||||
x if x == P2PMethods::DO_NOTHING as u8 => {
|
||||
println!(
|
||||
"{} punching succesful DO_NOTHING receved",
|
||||
"[SUCCESS]".green()
|
||||
);
|
||||
}
|
||||
_ => {
|
||||
eprintln!(
|
||||
"{} unknown method ID: 0x{:02x}, Droping!",
|
||||
|
||||
Reference in New Issue
Block a user