From dd58044cdf6456344201e0e40263874d957db9cd Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Fri, 16 Jun 2023 23:09:38 -0600 Subject: [PATCH] fix build --- backend/src/disk/mount/filesystem/efivarfs.rs | 1 - backend/src/net/vhost.rs | 4 +- backend/src/net/web_server.rs | 46 ++++++------------- 3 files changed, 15 insertions(+), 36 deletions(-) diff --git a/backend/src/disk/mount/filesystem/efivarfs.rs b/backend/src/disk/mount/filesystem/efivarfs.rs index 19a38e60f..3b2bae3ba 100644 --- a/backend/src/disk/mount/filesystem/efivarfs.rs +++ b/backend/src/disk/mount/filesystem/efivarfs.rs @@ -1,4 +1,3 @@ -use std::os::unix::ffi::OsStrExt; use std::path::Path; use async_trait::async_trait; diff --git a/backend/src/net/vhost.rs b/backend/src/net/vhost.rs index bb3857427..840acafb0 100644 --- a/backend/src/net/vhost.rs +++ b/backend/src/net/vhost.rs @@ -1,6 +1,6 @@ use std::collections::BTreeMap; use std::convert::Infallible; -use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}; +use std::net::{IpAddr, Ipv6Addr, SocketAddr}; use std::str::FromStr; use std::sync::{Arc, Weak}; @@ -18,7 +18,7 @@ use tokio_rustls::{LazyConfigAcceptor, TlsConnector}; use crate::net::keys::Key; use crate::net::ssl::SslManager; -use crate::net::utils::{SingleAccept, TcpListeners}; +use crate::net::utils::SingleAccept; use crate::util::io::BackTrackingReader; use crate::Error; diff --git a/backend/src/net/web_server.rs b/backend/src/net/web_server.rs index 5cfca0024..c2e25a413 100644 --- a/backend/src/net/web_server.rs +++ b/backend/src/net/web_server.rs @@ -4,10 +4,8 @@ use std::net::SocketAddr; use futures::future::ready; use futures::FutureExt; use helpers::NonDetachingJoinHandle; -use hyper::server::conn::AddrIncoming; use hyper::service::{make_service_fn, service_fn}; use hyper::Server; -use tokio::net::TcpListener; use tokio::sync::oneshot; use crate::context::{DiagnosticContext, InstallContext, RpcContext, SetupContext}; @@ -22,23 +20,17 @@ pub struct WebServer { thread: NonDetachingJoinHandle<()>, } impl WebServer { - pub fn new( - bind: impl AsRef<[SocketAddr]> + Send + Sync + 'static, - router: HttpHandler, - ) -> Self { + pub fn new(bind: SocketAddr, router: HttpHandler) -> Self { let (shutdown, shutdown_recv) = oneshot::channel(); let thread = NonDetachingJoinHandle::from(tokio::spawn(async move { - let server = Server::builder( - AddrIncoming::from_listener(TcpListener::bind(bind.as_ref()).await.unwrap()) - .unwrap(), - ) - .http1_preserve_header_case(true) - .http1_title_case_headers(true) - .serve(make_service_fn(move |_| { - let router = router.clone(); - ready(Ok::<_, Infallible>(service_fn(move |req| router(req)))) - })) - .with_graceful_shutdown(shutdown_recv.map(|_| ())); + let server = Server::bind(&bind) + .http1_preserve_header_case(true) + .http1_title_case_headers(true) + .serve(make_service_fn(move |_| { + let router = router.clone(); + ready(Ok::<_, Infallible>(service_fn(move |req| router(req)))) + })) + .with_graceful_shutdown(shutdown_recv.map(|_| ())); if let Err(e) = server.await { tracing::error!("Spawning hyper server error: {}", e); } @@ -51,31 +43,19 @@ impl WebServer { self.thread.await.unwrap() } - pub async fn main( - bind: impl AsRef<[SocketAddr]> + Send + Sync + 'static, - ctx: RpcContext, - ) -> Result { + pub async fn main(bind: SocketAddr, ctx: RpcContext) -> Result { Ok(Self::new(bind, main_ui_server_router(ctx).await?)) } - pub async fn setup( - bind: impl AsRef<[SocketAddr]> + Send + Sync + 'static, - ctx: SetupContext, - ) -> Result { + pub async fn setup(bind: SocketAddr, ctx: SetupContext) -> Result { Ok(Self::new(bind, setup_ui_file_router(ctx).await?)) } - pub async fn diagnostic( - bind: impl AsRef<[SocketAddr]> + Send + Sync + 'static, - ctx: DiagnosticContext, - ) -> Result { + pub async fn diagnostic(bind: SocketAddr, ctx: DiagnosticContext) -> Result { Ok(Self::new(bind, diag_ui_file_router(ctx).await?)) } - pub async fn install( - bind: impl AsRef<[SocketAddr]> + Send + Sync + 'static, - ctx: InstallContext, - ) -> Result { + pub async fn install(bind: SocketAddr, ctx: InstallContext) -> Result { Ok(Self::new(bind, install_ui_file_router(ctx).await?)) } }