ran cargo fmt

This commit is contained in:
mamoniot 2023-03-23 12:08:58 -04:00
parent cada04545e
commit 4f064dd389
No known key found for this signature in database
GPG key ID: ADCCDBBE0E3D3B3B

View file

@ -14,7 +14,7 @@ use std::collections::hash_map::RandomState;
use std::collections::HashMap;
use std::hash::{BuildHasher, Hash, Hasher};
use std::num::NonZeroU64;
use std::sync::atomic::{AtomicI64, AtomicU64, AtomicUsize, Ordering, AtomicBool};
use std::sync::atomic::{AtomicBool, AtomicI64, AtomicU64, AtomicUsize, Ordering};
use std::sync::{Arc, Mutex, MutexGuard, RwLock, Weak};
use zerotier_crypto::aes::{Aes, AesGcm};
@ -247,7 +247,6 @@ impl<Application: ApplicationLayer> Context<Application> {
dead_pending.push(*id);
}
}
}
// Only check for expiration if we have a pending packet.
// This check is allowed to have false positives for simplicity's sake.
@ -565,8 +564,12 @@ impl<Application: ApplicationLayer> Context<Application> {
// generated counter value replaying it in time requires extreme amounts of network control.
let mut slot0 = self.defrag[idx0].lock().unwrap();
if slot0.0.counter() == hashed_counter {
assembled = slot0.0.assemble(hashed_counter, incoming_physical_packet_buf, fragment_no, fragment_count);
if assembled.is_some() { slot0.1 = i64::MAX }
assembled = slot0
.0
.assemble(hashed_counter, incoming_physical_packet_buf, fragment_no, fragment_count);
if assembled.is_some() {
slot0.1 = i64::MAX
}
} else {
let mut slot1 = self.defrag[idx1].lock().unwrap();
if slot1.0.counter() == hashed_counter || slot1.0.counter() == 0 {
@ -574,13 +577,19 @@ impl<Application: ApplicationLayer> Context<Application> {
slot1.1 = current_time;
self.defrag_has_pending.store(true, Ordering::Relaxed);
}
assembled = slot1.0.assemble(hashed_counter, incoming_physical_packet_buf, fragment_no, fragment_count);
if assembled.is_some() { slot1.1 = i64::MAX }
assembled = slot1
.0
.assemble(hashed_counter, incoming_physical_packet_buf, fragment_no, fragment_count);
if assembled.is_some() {
slot1.1 = i64::MAX
}
} else {
// slot0 is either occupied or empty so we overwrite whatever is there to make more room.
slot0.1 = current_time;
self.defrag_has_pending.store(true, Ordering::Relaxed);
assembled = slot0.0.assemble(hashed_counter, incoming_physical_packet_buf, fragment_no, fragment_count);
assembled = slot0
.0
.assemble(hashed_counter, incoming_physical_packet_buf, fragment_no, fragment_count);
}
}