mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
fix build
This commit is contained in:
committed by
Aiden McClelland
parent
10312d89d7
commit
dd58044cdf
@@ -1,4 +1,3 @@
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
use std::path::Path;
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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<Self, Error> {
|
||||
pub async fn main(bind: SocketAddr, ctx: RpcContext) -> Result<Self, Error> {
|
||||
Ok(Self::new(bind, main_ui_server_router(ctx).await?))
|
||||
}
|
||||
|
||||
pub async fn setup(
|
||||
bind: impl AsRef<[SocketAddr]> + Send + Sync + 'static,
|
||||
ctx: SetupContext,
|
||||
) -> Result<Self, Error> {
|
||||
pub async fn setup(bind: SocketAddr, ctx: SetupContext) -> Result<Self, Error> {
|
||||
Ok(Self::new(bind, setup_ui_file_router(ctx).await?))
|
||||
}
|
||||
|
||||
pub async fn diagnostic(
|
||||
bind: impl AsRef<[SocketAddr]> + Send + Sync + 'static,
|
||||
ctx: DiagnosticContext,
|
||||
) -> Result<Self, Error> {
|
||||
pub async fn diagnostic(bind: SocketAddr, ctx: DiagnosticContext) -> Result<Self, Error> {
|
||||
Ok(Self::new(bind, diag_ui_file_router(ctx).await?))
|
||||
}
|
||||
|
||||
pub async fn install(
|
||||
bind: impl AsRef<[SocketAddr]> + Send + Sync + 'static,
|
||||
ctx: InstallContext,
|
||||
) -> Result<Self, Error> {
|
||||
pub async fn install(bind: SocketAddr, ctx: InstallContext) -> Result<Self, Error> {
|
||||
Ok(Self::new(bind, install_ui_file_router(ctx).await?))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user