From 82b6d785deb107b8e7c607a558df6d9f3e4cfe5b Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Sun, 30 Jun 2024 18:03:29 +0300 Subject: [PATCH] add option to allow listening on localhost --- src/bin/taskchampion-sync-server.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/bin/taskchampion-sync-server.rs b/src/bin/taskchampion-sync-server.rs index 3de9157..9b1efef 100644 --- a/src/bin/taskchampion-sync-server.rs +++ b/src/bin/taskchampion-sync-server.rs @@ -36,6 +36,10 @@ async fn main() -> anyhow::Result<()> { .value_parser(value_parser!(u16)) .default_value(defaults.port.to_string()), ) + .arg( + arg!(--host
"On what address to host server") + .default_value("localhost"), + ) .arg( arg!(--"snapshot-versions" "Target number of versions between snapshots") .value_parser(value_parser!(u32)) @@ -75,6 +79,7 @@ async fn main() -> anyhow::Result<()> { } }, None => { + let host: &String = matches.get_one("host").unwrap(); let port: u16 = *matches.get_one("port").unwrap(); let snapshot_versions: u32 = *matches.get_one("snapshot-versions").unwrap(); let snapshot_days: i64 = *matches.get_one("snapshot-days").unwrap(); @@ -85,13 +90,13 @@ async fn main() -> anyhow::Result<()> { let server = Server::new(config, Box::new(storage)); - log::warn!("Serving on port {}", port); + log::info!("Serving on {}:{}", host, port); HttpServer::new(move || { App::new() .wrap(Logger::default()) .configure(|cfg| server.config(cfg)) }) - .bind(format!("0.0.0.0:{}", port))? + .bind(format!("{}:{}", host, port))? .run() .await?; },