diff --git a/clients/terminal/src/main.rs b/clients/terminal/src/main.rs index 2faeb99..8662edc 100644 --- a/clients/terminal/src/main.rs +++ b/clients/terminal/src/main.rs @@ -247,7 +247,6 @@ fn run() -> Result<(), Box> { let url = result.0; join_handle = Some(result.1); - //TODO: Make this work PlayMessage::new( mime_type, Some(url), @@ -366,8 +365,13 @@ impl ServerState { } fn host_file_and_get_url(local_ip: &IpAddr, file_path: &str, mime_type: &String, running: &Arc) -> Result<(String, thread::JoinHandle>), String> { + let local_ip_str = if local_ip.is_ipv6() { + format!("[{}]", local_ip) + } else { + format!("{}", local_ip) + }; let server = { - let this = Server::http(format!("{}:0", local_ip)); + let this = Server::http(format!("{local_ip_str}:0")); match this { Ok(t) => Ok(t), Err(e) => Err((|e| format!("Failed to create server: {}", e))(e)), @@ -375,7 +379,7 @@ fn host_file_and_get_url(local_ip: &IpAddr, file_path: &str, mime_type: &String, }?; let url = match server.server_addr() { - ListenAddr::IP(addr) => format!("http://{}:{}/", local_ip, addr.port()), + ListenAddr::IP(addr) => format!("http://{local_ip_str}:{}/", addr.port()), #[cfg(unix)] ListenAddr::Unix(_) => return Err("Unix socket addresses are not supported.".to_string()), };