Skip to content

Commit

Permalink
feat(backend): make warp listen on both IPv4 and IPv6 (#216)
Browse files Browse the repository at this point in the history
Co-authored-by: ravenclaw900 <50060110+ravenclaw900@users.noreply.github.com>
  • Loading branch information
kingavatar and ravenclaw900 committed Apr 20, 2022
1 parent 61b2a33 commit 8bcf1b2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/backend/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use crate::shared::CONFIG;
use ring::digest;
use simple_logger::SimpleLogger;
use std::str::FromStr;
use std::net::IpAddr;
use warp::{http::header, Filter};

mod config;
Expand All @@ -25,7 +25,7 @@ fn main() {

SimpleLogger::new()
.with_level(
log::LevelFilter::from_str(&CONFIG.log_level).expect("Invalid log level"),
CONFIG.log_level.parse::<log::LevelFilter>().expect("Invalid log level"),
)
.env()
.init()
Expand Down Expand Up @@ -152,15 +152,17 @@ fn main() {
#[cfg(feature = "frontend")]
let routes = routes.or(page_routes);

let addr = IpAddr::from([0; 8]);

if CONFIG.tls {
warp::serve(routes)
.tls()
.cert_path(&CONFIG.cert)
.key_path(&CONFIG.key)
.run(([0, 0, 0, 0], CONFIG.port))
.run((addr, CONFIG.port))
.await;
} else {
warp::serve(routes).run(([0, 0, 0, 0], CONFIG.port)).await;
warp::serve(routes).run((addr, CONFIG.port)).await;
}
});
}

0 comments on commit 8bcf1b2

Please sign in to comment.