mirror of
https://mirror.suhoan.cn/https://github.com/EasyTier/EasyTier.git
synced 2025-12-13 05:07:23 +08:00
fix kcp not work as expect (#1285)
This commit is contained in:
@@ -266,6 +266,11 @@ impl<C: NatDstConnector, T: TcpProxyForKcpSrcTrait<Connector = C>> NicPacketFilt
|
||||
.check_dst_allow_kcp_input(&ip_packet.get_destination())
|
||||
.await
|
||||
{
|
||||
tracing::warn!(
|
||||
"{:?} proxy src: dst {} not allow kcp input",
|
||||
self.get_tcp_proxy().get_transport_type(),
|
||||
ip_packet.get_destination()
|
||||
);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
@@ -288,6 +293,12 @@ impl<C: NatDstConnector, T: TcpProxyForKcpSrcTrait<Connector = C>> NicPacketFilt
|
||||
if ip_packet.get_source() != my_ipv4.address()
|
||||
&& !self.get_tcp_proxy().is_smoltcp_enabled()
|
||||
{
|
||||
tracing::warn!(
|
||||
"{:?} nat 2 nat packet, src: {} dst: {} not allow kcp input",
|
||||
self.get_tcp_proxy().get_transport_type(),
|
||||
ip_packet.get_source(),
|
||||
ip_packet.get_destination()
|
||||
);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -200,6 +200,11 @@ impl TcpProxyForKcpSrcTrait for TcpProxyForQUICSrc {
|
||||
let Some(peer_info) = peer_map.get_route_peer_info(dst_peer_id).await else {
|
||||
return false;
|
||||
};
|
||||
tracing::debug!(
|
||||
"check dst {} allow quic input, peer info: {:?}",
|
||||
dst_ip,
|
||||
peer_info
|
||||
);
|
||||
let Some(quic_port) = peer_info.quic_port else {
|
||||
return false;
|
||||
};
|
||||
|
||||
@@ -24,6 +24,7 @@ use crate::common::error::Result;
|
||||
use crate::common::global_ctx::{ArcGlobalCtx, GlobalCtx};
|
||||
use crate::common::join_joinset_background;
|
||||
|
||||
use crate::common::stats_manager::{LabelSet, LabelType, MetricName};
|
||||
use crate::peers::peer_manager::PeerManager;
|
||||
use crate::peers::{NicPacketFilter, PeerPacketFilter};
|
||||
use crate::proto::cli::{
|
||||
@@ -722,6 +723,21 @@ impl<C: NatDstConnector> TcpProxy<C> {
|
||||
nat_entry.real_dst
|
||||
};
|
||||
|
||||
global_ctx
|
||||
.stats_manager()
|
||||
.get_counter(
|
||||
MetricName::TcpProxyConnect,
|
||||
LabelSet::new()
|
||||
.with_label_type(LabelType::Protocol(
|
||||
connector.transport_type().as_str_name().to_string(),
|
||||
))
|
||||
.with_label_type(LabelType::DstIp(nat_dst.ip().to_string()))
|
||||
.with_label_type(LabelType::MappedDstIp(
|
||||
nat_entry.mapped_dst.ip().to_string(),
|
||||
)),
|
||||
)
|
||||
.inc();
|
||||
|
||||
let _guard = global_ctx.net_ns.guard();
|
||||
let Ok(dst_tcp_stream) = connector.connect(nat_entry.src, nat_dst).await else {
|
||||
tracing::error!("connect to dst failed: {:?}", nat_entry);
|
||||
|
||||
Reference in New Issue
Block a user