fix(gateway): route local virtual IP proxy targets to loopback

Avoid proxy loops when the target is this node's virtual IP.

- Normalize local virtual IP destinations to loopback
- Apply the behavior to TCP, KCP, and QUIC proxy paths
- Add macOS utun repro tests and normalization coverage
This commit is contained in:
fanyang
2026-05-28 23:44:56 +08:00
parent 8b1a2b5e80
commit 3b2fd5d471
3 changed files with 141 additions and 16 deletions
+4 -4
View File
@@ -19,7 +19,9 @@ use tokio::task::JoinSet;
use super::{
CidrSet,
tcp_proxy::{NatDstConnector, NatDstTcpConnector, TcpProxy},
tcp_proxy::{
NatDstConnector, NatDstTcpConnector, TcpProxy, normalize_dst_for_local_virtual_ip,
},
};
use crate::utils::task::HedgeExt;
use crate::{
@@ -369,9 +371,7 @@ impl KcpProxyDst {
}
let send_to_self = global_ctx.is_ip_local_virtual_ip(&dst_ip);
if send_to_self && global_ctx.no_tun() {
dst_socket = format!("127.0.0.1:{}", dst_socket.port()).parse().unwrap();
}
dst_socket = normalize_dst_for_local_virtual_ip(&global_ctx, dst_socket);
let acl_handler = ProxyAclHandler {
acl_filter: global_ctx.get_acl_filter().clone(),