fmt
This commit is contained in:
@@ -18,7 +18,9 @@ impl PacketCrypto {
|
||||
|
||||
pub(crate) fn new_from_str(s: Option<&str>) -> Self {
|
||||
Self {
|
||||
crypto: s.map(chacha20_poly1305::PacketCrypto::new_from_str).map(Arc::new),
|
||||
crypto: s
|
||||
.map(chacha20_poly1305::PacketCrypto::new_from_str)
|
||||
.map(Arc::new),
|
||||
}
|
||||
}
|
||||
pub(crate) fn encrypt_reserve(&self) -> usize {
|
||||
|
||||
@@ -225,7 +225,7 @@ impl<B: AsRef<[u8]> + AsMut<[u8]>> NetPacket<B> {
|
||||
self.header_mut().set_msg_type(msg_type.into());
|
||||
}
|
||||
|
||||
pub fn decr_ttl(&mut self){
|
||||
pub fn decr_ttl(&mut self) {
|
||||
self.header_mut().decr_ttl()
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,10 @@ impl P2pOutbound {
|
||||
self.route_table.get_route_by_id(id).ok()
|
||||
}
|
||||
pub fn get_p2p_route_by_id(&self, id: &Ipv4Addr) -> Option<Route> {
|
||||
self.route_table.get_route_by_id(id).ok().filter(|v| v.is_direct())
|
||||
self.route_table
|
||||
.get_route_by_id(id)
|
||||
.ok()
|
||||
.filter(|v| v.is_direct())
|
||||
}
|
||||
pub fn exists_route_by_id(&self, id: &Ipv4Addr) -> bool {
|
||||
self.route_table.exists(id)
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use rust_p2p_core::route::{RouteKey, DEFAULT_RTT};
|
||||
use rust_p2p_core::route::{DEFAULT_RTT, RouteKey};
|
||||
use std::collections::HashMap;
|
||||
use std::net::Ipv4Addr;
|
||||
use std::sync::Arc;
|
||||
use std::time::Instant;
|
||||
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct Route {
|
||||
route_key: RouteKey,
|
||||
|
||||
@@ -76,7 +76,7 @@ impl ServerTurnInboundHandler {
|
||||
}
|
||||
|
||||
pub async fn handle_server_data(
|
||||
& self,
|
||||
&self,
|
||||
transport_client: &mut TransportClient,
|
||||
network_addr: NetworkAddr,
|
||||
data: TransmissionBytes,
|
||||
@@ -254,7 +254,7 @@ impl ServerTurnInboundHandler {
|
||||
net_packet.set_payload(&bytes_mut)?;
|
||||
self.packet_crypto.encrypt_in_place(&mut net_packet)?;
|
||||
transport_client.send_turn(net_packet).await?;
|
||||
}else{
|
||||
} else {
|
||||
log::info!("限制打洞频率")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user