dap: Support IPv6 addresses in TCP transport (#52244)

The DAP TCP transport layer was hardcoded to `Ipv4Addr`, so IPv6
addresses like `fd00::a` in a debug config's `connect.host` always
failed with `hostname must be IPv4: invalid IPv4 address syntax`.

Replaced `Ipv4Addr` with `IpAddr` and `SocketAddrV4` with `SocketAddr`
across the `task`, `dap`, `dap_adapters`, and `project` crates. The WASM
extension API still uses `u32` for the host field to avoid a breaking
WIT interface change; IPv4 round-trips through extensions as before.

Fixes #52237

Release Notes:

- Fixed DAP TCP transport rejecting IPv6 addresses when connecting to
remote debug adapters.

---------

Co-authored-by: moktamd <moktamd@users.noreply.github.com>
This commit is contained in:
moktamdandmoktamd authored and GitHub committed 2026-04-27 08:42:45 +00:00
1 parent d7d1b54044
commit 5aa7eaa508
8 files changed
+42 -31

No files matched your search

+6 -6
View File
@@ -14,7 +14,7 @@ use smol::fs::File;
use smol::io::AsyncReadExt;
use smol::lock::OnceCell;
use std::ffi::OsString;
use std::net::Ipv4Addr;
use std::net::IpAddr;
use std::str::FromStr;
use std::{
ffi::OsStr,
@@ -42,7 +42,7 @@ impl PythonDebugAdapter {
const LANGUAGE_NAME: &'static str = "Python";
async fn generate_debugpy_arguments<'a>(
host: &'a Ipv4Addr,
host: &'a IpAddr,
port: u16,
launch_mode: DebugpyLaunchMode<'a>,
user_installed_path: Option<&'a Path>,
@@ -380,7 +380,7 @@ impl PythonDebugAdapter {
}
if let Some(hostname) = config_host {
tcp_connection.host = Some(hostname.parse().context("hostname must be IPv4")?);
tcp_connection.host = Some(hostname.parse().context("invalid IP address")?);
}
tcp_connection.port = config_port;
DebugpyLaunchMode::AttachWithConnect { host: config_host }
@@ -974,7 +974,7 @@ mod tests {
.contains("Cannot have two different ports")
);
let host = Ipv4Addr::new(127, 0, 0, 1);
let host = IpAddr::V4(std::net::Ipv4Addr::LOCALHOST);
let config_with_host_conflict = json!({
"request": "attach",
"connect": {
@@ -1018,7 +1018,7 @@ mod tests {
#[gpui::test]
async fn test_attach_with_connect_mode_generates_correct_arguments() {
let host = Ipv4Addr::new(127, 0, 0, 1);
let host = IpAddr::V4(std::net::Ipv4Addr::LOCALHOST);
let port = 5678;
let args_without_host = PythonDebugAdapter::generate_debugpy_arguments(
@@ -1071,7 +1071,7 @@ mod tests {
#[gpui::test]
async fn test_debugpy_install_path_cases() {
let host = Ipv4Addr::new(127, 0, 0, 1);
let host = IpAddr::V4(std::net::Ipv4Addr::LOCALHOST);
let port = 5678;
// Case 1: User-defined debugpy path (highest precedence)