去除多余校验

This commit is contained in:
lbl8603
2024-04-25 19:44:20 +08:00
parent 7dc4161f2f
commit d2b2dfbf1e
2 changed files with 2 additions and 16 deletions
+2 -15
View File
@@ -2,7 +2,7 @@ use parking_lot::RwLock;
use protobuf::Message; use protobuf::Message;
use std::collections::HashMap; use std::collections::HashMap;
use std::io; use std::io;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; use std::net::{Ipv4Addr, Ipv6Addr};
use std::sync::Arc; use std::sync::Arc;
use packet::icmp::{icmp, Kind}; use packet::icmp::{icmp, Kind};
@@ -13,7 +13,7 @@ use crate::channel::context::Context;
use crate::channel::punch::NatInfo; use crate::channel::punch::NatInfo;
use crate::channel::{Route, RouteKey}; use crate::channel::{Route, RouteKey};
use crate::cipher::Cipher; use crate::cipher::Cipher;
use crate::external_route::{AllowExternalRoute, ExternalRoute}; use crate::external_route::AllowExternalRoute;
use crate::handle::maintain::PunchSender; use crate::handle::maintain::PunchSender;
use crate::handle::recv_data::PacketHandler; use crate::handle::recv_data::PacketHandler;
use crate::handle::CurrentDeviceInfo; use crate::handle::CurrentDeviceInfo;
@@ -38,7 +38,6 @@ pub struct ClientPacketHandler {
peer_nat_info_map: Arc<RwLock<HashMap<Ipv4Addr, NatInfo>>>, peer_nat_info_map: Arc<RwLock<HashMap<Ipv4Addr, NatInfo>>>,
nat_test: NatTest, nat_test: NatTest,
route: AllowExternalRoute, route: AllowExternalRoute,
external_route: ExternalRoute,
#[cfg(feature = "ip_proxy")] #[cfg(feature = "ip_proxy")]
ip_proxy_map: Option<IpProxyMap>, ip_proxy_map: Option<IpProxyMap>,
} }
@@ -51,7 +50,6 @@ impl ClientPacketHandler {
peer_nat_info_map: Arc<RwLock<HashMap<Ipv4Addr, NatInfo>>>, peer_nat_info_map: Arc<RwLock<HashMap<Ipv4Addr, NatInfo>>>,
nat_test: NatTest, nat_test: NatTest,
route: AllowExternalRoute, route: AllowExternalRoute,
external_route: ExternalRoute,
#[cfg(feature = "ip_proxy")] ip_proxy_map: Option<IpProxyMap>, #[cfg(feature = "ip_proxy")] ip_proxy_map: Option<IpProxyMap>,
) -> Self { ) -> Self {
Self { Self {
@@ -61,7 +59,6 @@ impl ClientPacketHandler {
peer_nat_info_map, peer_nat_info_map,
nat_test, nat_test,
route, route,
external_route,
#[cfg(feature = "ip_proxy")] #[cfg(feature = "ip_proxy")]
ip_proxy_map, ip_proxy_map,
} }
@@ -76,16 +73,6 @@ impl PacketHandler for ClientPacketHandler {
context: &Context, context: &Context,
current_device: &CurrentDeviceInfo, current_device: &CurrentDeviceInfo,
) -> io::Result<()> { ) -> io::Result<()> {
let ip = match route_key.addr.ip() {
IpAddr::V4(ip) => Some(ip),
IpAddr::V6(ip) => ip.to_ipv4_mapped(),
};
if let Some(ip) = ip {
if self.external_route.route(&ip).is_some() {
log::warn!("跳过in路由中的目标 {:?},防止环路 ", route_key);
return Ok(());
}
}
self.client_cipher.decrypt_ipv4(&mut net_packet)?; self.client_cipher.decrypt_ipv4(&mut net_packet)?;
context context
.route_table .route_table
-1
View File
@@ -88,7 +88,6 @@ impl<Call: VntCallback> RecvDataHandler<Call> {
peer_nat_info_map, peer_nat_info_map,
nat_test, nat_test,
route, route,
external_route.clone(),
#[cfg(feature = "ip_proxy")] #[cfg(feature = "ip_proxy")]
ip_proxy_map, ip_proxy_map,
); );