Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
sanity committed Dec 26, 2024
1 parent 29c67e8 commit 6ead963
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
33 changes: 19 additions & 14 deletions crates/core/src/transport/connection_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@ use std::collections::BTreeMap;

type GatewayConnectionFuture = Box<
dyn Future<
Output = Result<
(
RemoteConnection,
InboundRemoteConnection,
PacketData<SymmetricAES>,
),
TransportError,
>,
> + Send
Output = Result<
(
RemoteConnection,
InboundRemoteConnection,
PacketData<SymmetricAES>,
),
TransportError,
>,
> + Send
+ 'static,
>;

type TraverseNatFuture = Box<
dyn Future<
Output = Result<(RemoteConnection, InboundRemoteConnection), TransportError>,
> + Send
dyn Future<Output = Result<(RemoteConnection, InboundRemoteConnection), TransportError>>
+ Send
+ 'static,
>;
use std::net::{IpAddr, SocketAddr};
Expand Down Expand Up @@ -397,7 +396,10 @@ impl<S: Socket> UdpPacketsListener<S> {
&mut self,
remote_intro_packet: PacketData<UnknownEncryption>,
remote_addr: SocketAddr,
) -> (GatewayConnectionFuture, mpsc::Sender<PacketData<UnknownEncryption>>) {
) -> (
GatewayConnectionFuture,
mpsc::Sender<PacketData<UnknownEncryption>>,
) {
let secret = self.this_peer_keypair.secret.clone();
let outbound_packets = self.outbound_packets.clone();

Expand Down Expand Up @@ -516,7 +518,10 @@ impl<S: Socket> UdpPacketsListener<S> {
&mut self,
remote_addr: SocketAddr,
remote_public_key: TransportPublicKey,
) -> (TraverseNatFuture, mpsc::Sender<PacketData<UnknownEncryption>>) {
) -> (
TraverseNatFuture,
mpsc::Sender<PacketData<UnknownEncryption>>,
) {
// Constants for exponential backoff
const INITIAL_TIMEOUT: Duration = Duration::from_millis(15);
const TIMEOUT_MULTIPLIER: f64 = 1.2;
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/transport/rate_limiter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<T: TimeSource> PacketRateLimiter<T> {
while self
.packets
.front()
.map_or(false, |&(_, time)| now - time > self.window_size)
.is_some_and(|&(_, time)| now - time > self.window_size)
{
let expired = self.packets.pop_front();
if let Some((size, _)) = expired {
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/transport/received_packet_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl<T: TimeSource> ReceivedPacketTracker<T> {
while self
.packet_id_time
.front()
.map_or(false, |&(_, time)| time < remove_before)
.is_some_and(|&(_, time)| time < remove_before)
{
let expired = self.packet_id_time.pop_front();
if let Some((packet_id, _)) = expired {
Expand Down

0 comments on commit 6ead963

Please sign in to comment.