|
|
|
@ -45,10 +45,12 @@ fn routing<'a>() -> impl warp::Filter<Error = warp::reject::Rejection> + Clone +
|
|
|
|
|
auth.or(push).or(get)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub async fn serve(cfg: impl Into<Config>) -> eyre::Result<()>
|
|
|
|
|
pub async fn serve(cfg: Config) -> eyre::Result<()>
|
|
|
|
|
{
|
|
|
|
|
let cfg = cfg.into();
|
|
|
|
|
let bans = ban::Banlist::new();
|
|
|
|
|
let bans: ban::Banlist = cfg.static_bans.iter().collect();
|
|
|
|
|
|
|
|
|
|
//TODO: Create state
|
|
|
|
|
|
|
|
|
|
// Filter: Extract the client IP from the remote address of the connection of the X-Forwarded-For header if it is trusted in `cfg`.
|
|
|
|
|
let client_ip = warp::addr::remote()
|
|
|
|
|
.and(warp::header("X-Forwarded-For"))
|
|
|
|
@ -57,10 +59,15 @@ pub async fn serve(cfg: impl Into<Config>) -> eyre::Result<()>
|
|
|
|
|
.and_then(|req: Result<source::ClientInfo, _>| async move { req.map_err(warp::reject::custom) })
|
|
|
|
|
// Enforce banlist
|
|
|
|
|
.and_then(bans.filter());
|
|
|
|
|
|
|
|
|
|
//.and_then(|req: source::ClientInfo| async move { Result::<_, std::convert::Infallible>::Ok(req) });
|
|
|
|
|
|
|
|
|
|
let r = warp::path("api").and(routing());
|
|
|
|
|
|
|
|
|
|
let filter = warp::path("api")
|
|
|
|
|
//how the FUCK do we insert shit into this????????????????????????
|
|
|
|
|
.and(routing());
|
|
|
|
|
|
|
|
|
|
warp::serve(client_ip).bind_with_graceful_shutdown(([127,0,0,1], 8001), tokio::signal::ctrl_c()).await;
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|