Skip to content

Commit 795b9c8

Browse files
benthecarmanclaude
andcommitted
Replace wildcard listen addresses with loopback in CLI
When the CLI reads a base URL from config, 0.0.0.0 or [::] aren't connectable. Rewrite them to 127.0.0.1 or [::1] so the client can actually reach the server. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 695a812 commit 795b9c8

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

ldk-server-cli/src/main.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,13 +433,20 @@ async fn main() {
433433
});
434434

435435
// Get base URL from argument then from config file
436-
let base_url =
436+
let mut base_url =
437437
cli.base_url.or_else(|| config.as_ref().map(|c| c.node.rest_service_address.clone()))
438438
.unwrap_or_else(|| {
439439
eprintln!("Base URL not provided. Use --base-url or ensure config file exists at ~/.ldk-server/config.toml");
440440
std::process::exit(1);
441441
});
442442

443+
// Replace wildcard listen addresses with loopback addresses for connectivity
444+
if base_url.contains("0.0.0.0") {
445+
base_url = base_url.replacen("0.0.0.0", "127.0.0.1", 1);
446+
} else if base_url.contains("[::]") {
447+
base_url = base_url.replacen("[::]", "[::1]", 1);
448+
}
449+
443450
// Get TLS cert path from argument, then from config file, then try default location
444451
let tls_cert_path = cli.tls_cert.map(PathBuf::from).or_else(|| {
445452
config

0 commit comments

Comments
 (0)