mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-09-02 17:15:43 +00:00
fix: add loopback to connector bind addresses for localhost connections
set_bind_addr_for_peer_connector collected all local interface IPs as bind addresses but omitted 127.0.0.1. When connecting to localhost, the connector would bind to a non-loopback IP (e.g. 172.17.0.2 in Docker) and fail with connect timeout because routing from non-loopback to loopback doesn't work. Fix: prepend 127.0.0.1:0 to the bind address list. The connector tries all bind addresses, so loopback will be attempted first and succeed for localhost connections. Benchmark results in Docker (4 threads, 1400B, 10s): Ring: 508K pps, MpscTunnelSender::send 138ns UDP: 440K pps, MpscTunnelSender::send 294ns TCP: 440K pps, MpscTunnelSender::send 376ns All three tunnel types now converge and benefit from noop_waker sync send.
This commit is contained in:
@@ -70,6 +70,8 @@ async fn set_bind_addr_for_peer_connector(
|
||||
let ips = global_ctx.get_ip_collector().collect_ip_addrs().await;
|
||||
if is_ipv4 {
|
||||
let mut bind_addrs = vec![];
|
||||
// Always include loopback so localhost connections work
|
||||
bind_addrs.push(std::net::SocketAddr::from(([127, 0, 0, 1], 0)));
|
||||
for ipv4 in ips.interface_ipv4s {
|
||||
let socket_addr = SocketAddrV4::new(ipv4.into(), 0).into();
|
||||
bind_addrs.push(socket_addr);
|
||||
|
||||
Reference in New Issue
Block a user