From c07a3e477b05dd29d76b2efef7e9411bcf4ad2ea Mon Sep 17 00:00:00 2001 From: "m.habedank" Date: Sun, 21 Jan 2024 08:17:45 +0100 Subject: [PATCH] IP address can be set for headless --- headless/src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/headless/src/main.rs b/headless/src/main.rs index 98edd0d5de..f1ed1f556f 100644 --- a/headless/src/main.rs +++ b/headless/src/main.rs @@ -15,6 +15,7 @@ extern crate anyhow; extern crate log; use std::collections::{BTreeMap, BTreeSet, HashMap}; +use std::net::IpAddr; use std::sync::RwLock; use anyhow::Result; @@ -56,6 +57,8 @@ lazy_static::lazy_static! { about = "Simulate traffic with a JSON API, not a GUI" )] struct Args { + #[structopt(long, default_value = "127.0.0.1")] + ip: IpAddr, /// What port to run the JSON API on. #[structopt(long)] port: u16, @@ -83,7 +86,7 @@ async fn main() { *SIM.write().unwrap() = sim; } - let addr = std::net::SocketAddr::from(([127, 0, 0, 1], args.port)); + let addr = std::net::SocketAddr::from((args.ip, args.port)); info!("Listening on http://{}", addr); let serve_future = Server::bind(&addr).serve(hyper::service::make_service_fn(|_| async { Ok::<_, hyper::Error>(hyper::service::service_fn(serve_req))