fix binding to unspecified addr on v4 and v6
This commit is contained in:
parent
11f2b8f626
commit
43d03869ab
27
src/main.rs
27
src/main.rs
|
@ -200,7 +200,7 @@ async fn main() -> std::io::Result<()> {
|
||||||
});
|
});
|
||||||
start_reaper(data.clone());
|
start_reaper(data.clone());
|
||||||
|
|
||||||
HttpServer::new(move || {
|
let server = HttpServer::new(move || {
|
||||||
App::new()
|
App::new()
|
||||||
.app_data(data.clone())
|
.app_data(data.clone())
|
||||||
.wrap(if data.config.reverse_proxy {
|
.wrap(if data.config.reverse_proxy {
|
||||||
|
@ -213,25 +213,20 @@ async fn main() -> std::io::Result<()> {
|
||||||
.service(check_upload_password)
|
.service(check_upload_password)
|
||||||
.service(upload_limits)
|
.service(upload_limits)
|
||||||
.service(actix_files::Files::new("/", static_dir.clone()).index_file("index.html"))
|
.service(actix_files::Files::new("/", static_dir.clone()).index_file("index.html"))
|
||||||
})
|
});
|
||||||
.bind((
|
|
||||||
if reverse_proxy {
|
if reverse_proxy {
|
||||||
std::net::Ipv4Addr::LOCALHOST
|
server
|
||||||
|
.bind((std::net::Ipv4Addr::LOCALHOST, port))?
|
||||||
|
.bind((std::net::Ipv6Addr::LOCALHOST, port))?
|
||||||
} else {
|
} else {
|
||||||
std::net::Ipv4Addr::UNSPECIFIED
|
// Looks like this also picks up IPv4?
|
||||||
},
|
// Binding 0.0.0.0 and :: on the same port fails with an error.
|
||||||
port,
|
server.bind((std::net::Ipv6Addr::UNSPECIFIED, port))?
|
||||||
))?
|
}
|
||||||
.bind((
|
|
||||||
if reverse_proxy {
|
|
||||||
std::net::Ipv6Addr::LOCALHOST
|
|
||||||
} else {
|
|
||||||
std::net::Ipv6Addr::UNSPECIFIED
|
|
||||||
},
|
|
||||||
port,
|
|
||||||
))?
|
|
||||||
.run()
|
.run()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue