Skip to main content

debugger/common/
mod.rs

1//! Common utilities shared between CLI and daemon modes
2
3pub mod config;
4pub mod error;
5pub mod logging;
6pub mod paths;
7
8pub use error::{Error, Result};
9
10/// Parse a "listening at:" address from adapter output.
11/// Handles IPv6 format [::]:PORT by converting to 127.0.0.1:PORT
12pub fn parse_listen_address(line: &str) -> Option<String> {
13    if let Some(addr_start) = line.find("listening at:") {
14        let addr_part = &line[addr_start + "listening at:".len()..];
15        let addr = addr_part.trim().to_string();
16        // Handle IPv6 format [::]:PORT
17        let addr = if addr.starts_with("[::]:") {
18            addr.replace("[::]:", "127.0.0.1:")
19        } else {
20            addr
21        };
22        Some(addr)
23    } else {
24        None
25    }
26}