diff --git a/src/main.rs b/src/main.rs index add880f..2bdd763 100644 --- a/src/main.rs +++ b/src/main.rs @@ -123,20 +123,6 @@ async fn handle_connection(mut con: conn::Connection, srv: &config::ServerCfg) - } }; - if srv.proxy.len() != 0 { - let seg = match url.path_segments().map(|c| c.collect::>()) { - Some(s) => s, - None => return Ok(()), - }; - match srv.proxy.get(seg[0]) { - Some(p) => { - revproxy::proxy(p.to_string(), url, con).await?; - return Ok(()); - }, - None => {}, - } - } - if Some(srv.hostname.as_str()) != url.host_str() { con.send_status(status::Status::ProxyRequestRefused, "Url doesn't match certificate!").await?; return Ok(()); @@ -158,6 +144,21 @@ async fn handle_connection(mut con: conn::Connection, srv: &config::ServerCfg) - return Ok(()); } + if srv.proxy.len() != 0 { + match url.path_segments().map(|c| c.collect::>()) { + Some(s) => { + match srv.proxy.get(s[0]) { + Some(p) => { + revproxy::proxy(p.to_string(), url, con).await?; + return Ok(()); + }, + None => {}, + } + } + None => {}, + } + } + let mut path = PathBuf::new(); if url.path().starts_with("/~") && srv.usrdir == true{ @@ -189,6 +190,7 @@ async fn handle_connection(mut con: conn::Connection, srv: &config::ServerCfg) - // This block is terrible if meta.is_dir() { if !url.path().ends_with("/") { + println!("{}", url); con.send_status( status::Status::RedirectPermanent, format!("{}/", url).as_str(),