mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-04 14:29:45 +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 std::path::Path;
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::convert::Infallible;
|
use std::convert::Infallible;
|
||||||
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};
|
use std::net::{IpAddr, Ipv6Addr, SocketAddr};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::sync::{Arc, Weak};
|
use std::sync::{Arc, Weak};
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ use tokio_rustls::{LazyConfigAcceptor, TlsConnector};
|
|||||||
|
|
||||||
use crate::net::keys::Key;
|
use crate::net::keys::Key;
|
||||||
use crate::net::ssl::SslManager;
|
use crate::net::ssl::SslManager;
|
||||||
use crate::net::utils::{SingleAccept, TcpListeners};
|
use crate::net::utils::SingleAccept;
|
||||||
use crate::util::io::BackTrackingReader;
|
use crate::util::io::BackTrackingReader;
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,8 @@ use std::net::SocketAddr;
|
|||||||
use futures::future::ready;
|
use futures::future::ready;
|
||||||
use futures::FutureExt;
|
use futures::FutureExt;
|
||||||
use helpers::NonDetachingJoinHandle;
|
use helpers::NonDetachingJoinHandle;
|
||||||
use hyper::server::conn::AddrIncoming;
|
|
||||||
use hyper::service::{make_service_fn, service_fn};
|
use hyper::service::{make_service_fn, service_fn};
|
||||||
use hyper::Server;
|
use hyper::Server;
|
||||||
use tokio::net::TcpListener;
|
|
||||||
use tokio::sync::oneshot;
|
use tokio::sync::oneshot;
|
||||||
|
|
||||||
use crate::context::{DiagnosticContext, InstallContext, RpcContext, SetupContext};
|
use crate::context::{DiagnosticContext, InstallContext, RpcContext, SetupContext};
|
||||||
@@ -22,23 +20,17 @@ pub struct WebServer {
|
|||||||
thread: NonDetachingJoinHandle<()>,
|
thread: NonDetachingJoinHandle<()>,
|
||||||
}
|
}
|
||||||
impl WebServer {
|
impl WebServer {
|
||||||
pub fn new(
|
pub fn new(bind: SocketAddr, router: HttpHandler) -> Self {
|
||||||
bind: impl AsRef<[SocketAddr]> + Send + Sync + 'static,
|
|
||||||
router: HttpHandler,
|
|
||||||
) -> Self {
|
|
||||||
let (shutdown, shutdown_recv) = oneshot::channel();
|
let (shutdown, shutdown_recv) = oneshot::channel();
|
||||||
let thread = NonDetachingJoinHandle::from(tokio::spawn(async move {
|
let thread = NonDetachingJoinHandle::from(tokio::spawn(async move {
|
||||||
let server = Server::builder(
|
let server = Server::bind(&bind)
|
||||||
AddrIncoming::from_listener(TcpListener::bind(bind.as_ref()).await.unwrap())
|
.http1_preserve_header_case(true)
|
||||||
.unwrap(),
|
.http1_title_case_headers(true)
|
||||||
)
|
.serve(make_service_fn(move |_| {
|
||||||
.http1_preserve_header_case(true)
|
let router = router.clone();
|
||||||
.http1_title_case_headers(true)
|
ready(Ok::<_, Infallible>(service_fn(move |req| router(req))))
|
||||||
.serve(make_service_fn(move |_| {
|
}))
|
||||||
let router = router.clone();
|
.with_graceful_shutdown(shutdown_recv.map(|_| ()));
|
||||||
ready(Ok::<_, Infallible>(service_fn(move |req| router(req))))
|
|
||||||
}))
|
|
||||||
.with_graceful_shutdown(shutdown_recv.map(|_| ()));
|
|
||||||
if let Err(e) = server.await {
|
if let Err(e) = server.await {
|
||||||
tracing::error!("Spawning hyper server error: {}", e);
|
tracing::error!("Spawning hyper server error: {}", e);
|
||||||
}
|
}
|
||||||
@@ -51,31 +43,19 @@ impl WebServer {
|
|||||||
self.thread.await.unwrap()
|
self.thread.await.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn main(
|
pub async fn main(bind: SocketAddr, ctx: RpcContext) -> Result<Self, Error> {
|
||||||
bind: impl AsRef<[SocketAddr]> + Send + Sync + 'static,
|
|
||||||
ctx: RpcContext,
|
|
||||||
) -> Result<Self, Error> {
|
|
||||||
Ok(Self::new(bind, main_ui_server_router(ctx).await?))
|
Ok(Self::new(bind, main_ui_server_router(ctx).await?))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn setup(
|
pub async fn setup(bind: SocketAddr, ctx: SetupContext) -> Result<Self, Error> {
|
||||||
bind: impl AsRef<[SocketAddr]> + Send + Sync + 'static,
|
|
||||||
ctx: SetupContext,
|
|
||||||
) -> Result<Self, Error> {
|
|
||||||
Ok(Self::new(bind, setup_ui_file_router(ctx).await?))
|
Ok(Self::new(bind, setup_ui_file_router(ctx).await?))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn diagnostic(
|
pub async fn diagnostic(bind: SocketAddr, ctx: DiagnosticContext) -> Result<Self, Error> {
|
||||||
bind: impl AsRef<[SocketAddr]> + Send + Sync + 'static,
|
|
||||||
ctx: DiagnosticContext,
|
|
||||||
) -> Result<Self, Error> {
|
|
||||||
Ok(Self::new(bind, diag_ui_file_router(ctx).await?))
|
Ok(Self::new(bind, diag_ui_file_router(ctx).await?))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn install(
|
pub async fn install(bind: SocketAddr, ctx: InstallContext) -> Result<Self, Error> {
|
||||||
bind: impl AsRef<[SocketAddr]> + Send + Sync + 'static,
|
|
||||||
ctx: InstallContext,
|
|
||||||
) -> Result<Self, Error> {
|
|
||||||
Ok(Self::new(bind, install_ui_file_router(ctx).await?))
|
Ok(Self::new(bind, install_ui_file_router(ctx).await?))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user