diff --git a/src/args.rs b/src/args.rs index 15546df..e36eb08 100644 --- a/src/args.rs +++ b/src/args.rs @@ -1,3 +1,4 @@ +use std::net::IpAddr; use clap::Parser; use lazy_static::lazy_static; @@ -36,7 +37,10 @@ pub struct Args { pub highlightsyntax: bool, #[clap(short, long, default_value_t = 8080)] - pub port: u32, + pub port: u16, + + #[clap(short, long, default_value_t = IpAddr::from([127, 0, 0, 1]))] + pub bind: IpAddr, #[clap(long)] pub private: bool, @@ -55,4 +59,4 @@ pub struct Args { #[clap(long)] pub wide: bool, -} +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 9f12d4b..1c18a31 100644 --- a/src/main.rs +++ b/src/main.rs @@ -58,7 +58,8 @@ async fn main() -> std::io::Result<()> { .init(); log::info!( - "MicroBin starting on http://127.0.0.1:{}", + "MicroBin starting on http://{}:{}", + ARGS.bind.to_string(), ARGS.port.to_string() ); @@ -97,7 +98,7 @@ async fn main() -> std::io::Result<()> { HttpAuthentication::basic(util::auth::auth_validator), )) }) - .bind(format!("0.0.0.0:{}", ARGS.port.to_string()))? + .bind((ARGS.bind, ARGS.port))? .workers(ARGS.threads as usize) .run() .await