fix: support remote host in CDP discovery (#854)
* fix: support remote host in CDP discovery (#851) `discover_cdp_url` now accepts a host parameter instead of hardcoding 127.0.0.1, allowing `connect "http://<remote-ip>:<port>"` to query the correct remote `/json/version` endpoint. The returned webSocketDebuggerUrl is rewritten to match the requested host and port, since Chrome always reports 127.0.0.1 regardless of the interface it was reached through. * style: apply cargo fmt Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor: unify discover_cdp_url and discover_cdp_url_with_request_timeout Merge the two discovery functions into discover_cdp_url(host, port) and discover_cdp_url_with_timeout(host, port, timeout), eliminating duplicated logic. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor: merge discover_cdp_url into single function with optional timeout Replace discover_cdp_url + discover_cdp_url_with_timeout with a single discover_cdp_url(host, port, timeout) where timeout is Option<Duration>. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor: replace Option<Duration> with separate discover_cdp_url_with_timeout Split back into two functions for cleaner call sites: - discover_cdp_url(host, port) for default timeout - discover_cdp_url_with_timeout(host, port, timeout) for custom timeout Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: bracket IPv6 addresses in CDP discovery HTTP URL Extract bracket_ipv6 helper and apply it in fetch_cdp_info to produce valid URLs like http://[::1]:9222/json/version instead of malformed http://::1:9222/json/version. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: hyunjinee <leehj0110@kakao.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
hyunjinee
parent
8163f6cdca
commit
0883813cd3
@@ -6,7 +6,7 @@ use std::process::{Child, Command, Stdio};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::Duration;
|
||||
|
||||
use super::discovery::discover_cdp_url_with_request_timeout;
|
||||
use super::discovery::discover_cdp_url_with_timeout;
|
||||
|
||||
const LIGHTPANDA_STARTUP_TIMEOUT: Duration = Duration::from_secs(10);
|
||||
const LIGHTPANDA_POLL_INTERVAL: Duration = Duration::from_millis(100);
|
||||
@@ -257,7 +257,7 @@ async fn wait_for_lightpanda_ready(
|
||||
));
|
||||
}
|
||||
|
||||
match discover_cdp_url_with_request_timeout(port, LIGHTPANDA_DISCOVERY_TIMEOUT).await {
|
||||
match discover_cdp_url_with_timeout("127.0.0.1", port, LIGHTPANDA_DISCOVERY_TIMEOUT).await {
|
||||
Ok(ws_url) => return Ok(ws_url),
|
||||
Err(err) => last_probe_error = Some(err),
|
||||
}
|
||||
@@ -365,7 +365,7 @@ mod tests {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(ws_url, "ws://127.0.0.1:9222/");
|
||||
assert_eq!(ws_url, format!("ws://127.0.0.1:{}/", port));
|
||||
let _ = child.kill();
|
||||
let _ = child.wait();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user