This commit is contained in:
lbl
2026-02-24 16:08:44 +08:00
parent 4708ed2b16
commit ecdb359bbd
5 changed files with 11 additions and 7 deletions
+3 -1
View File
@@ -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 {
+1 -1
View File
@@ -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()
}
+4 -1
View File
@@ -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 -2
View File
@@ -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,
+2 -2
View File
@@ -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!("限制打洞频率")
}
}