diff --git a/src/main.rs b/src/main.rs index 4fca1e1..adcf60d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -200,7 +200,7 @@ async fn main() -> std::io::Result<()> { }); start_reaper(data.clone()); - HttpServer::new(move || { + let server = HttpServer::new(move || { App::new() .app_data(data.clone()) .wrap(if data.config.reverse_proxy { @@ -213,25 +213,20 @@ async fn main() -> std::io::Result<()> { .service(check_upload_password) .service(upload_limits) .service(actix_files::Files::new("/", static_dir.clone()).index_file("index.html")) - }) - .bind(( - if reverse_proxy { - std::net::Ipv4Addr::LOCALHOST - } else { - std::net::Ipv4Addr::UNSPECIFIED - }, - port, - ))? - .bind(( - if reverse_proxy { - std::net::Ipv6Addr::LOCALHOST - } else { - std::net::Ipv6Addr::UNSPECIFIED - }, - port, - ))? + }); + + if reverse_proxy { + server + .bind((std::net::Ipv4Addr::LOCALHOST, port))? + .bind((std::net::Ipv6Addr::LOCALHOST, port))? + } else { + // Looks like this also picks up IPv4? + // Binding 0.0.0.0 and :: on the same port fails with an error. + server.bind((std::net::Ipv6Addr::UNSPECIFIED, port))? + } .run() .await?; + Ok(()) }