diff --git a/clash_lib/src/app/dns/system.rs b/clash_lib/src/app/dns/system.rs index a0f35aa5d..a42a148b6 100644 --- a/clash_lib/src/app/dns/system.rs +++ b/clash_lib/src/app/dns/system.rs @@ -31,6 +31,7 @@ impl ClashResolver for SystemResolver { Ok(response .iter() .map(|x| x.ip()) + .filter(|x| self.ipv6() || x.is_ipv4()) .choose(&mut rand::thread_rng())) } diff --git a/clash_lib/src/proxy/tun/inbound.rs b/clash_lib/src/proxy/tun/inbound.rs index a3583284d..e1b5a7437 100644 --- a/clash_lib/src/proxy/tun/inbound.rs +++ b/clash_lib/src/proxy/tun/inbound.rs @@ -37,7 +37,7 @@ async fn handle_inbound_stream( ..Default::default() }; - debug!("new tun TCP connection: {}", sess); + debug!("new tun TCP session assigned: {}", sess); dispatcher.dispatch_stream(sess, stream).await; } @@ -240,6 +240,8 @@ pub fn get_runner( while let Some((stream, local_addr, remote_addr)) = tcp_listener.next().await { + debug!("new tun TCP connection: {} -> {}", local_addr, remote_addr); + tokio::spawn(handle_inbound_stream( stream, local_addr, diff --git a/clash_lib/src/proxy/utils/socket_helpers.rs b/clash_lib/src/proxy/utils/socket_helpers.rs index 2d33caf01..90e792975 100644 --- a/clash_lib/src/proxy/utils/socket_helpers.rs +++ b/clash_lib/src/proxy/utils/socket_helpers.rs @@ -95,7 +95,7 @@ pub async fn new_tcp_stream<'a>( ))?; debug!( - "dialing {}[{}]:{} via {:?}", + "dialing {}[{}]:{} via iface {:?}", address, dial_addr, port, iface ); @@ -115,6 +115,7 @@ pub async fn new_tcp_stream<'a>( }; if let Some(iface) = iface { + debug!("binding tcp socket to interface: {:?}", iface); must_bind_socket_on_interface(&socket, iface)?; } @@ -175,7 +176,7 @@ pub async fn new_udp_socket( socket.bind(&(*src).into())?; } (None, Some(iface)) => { - debug!("binding socket to interface: {:?}", iface); + debug!("binding udp socket to interface: {:?}", iface); must_bind_socket_on_interface(&socket, iface).inspect_err(|x| { error!("failed to bind socket to interface: {}", x); })?;