Fixed bug with base url and proxy enabled
This commit is contained in:
30
src/main.rs
30
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::<Vec<_>>()) {
|
|
||||||
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() {
|
if Some(srv.hostname.as_str()) != url.host_str() {
|
||||||
con.send_status(status::Status::ProxyRequestRefused, "Url doesn't match certificate!").await?;
|
con.send_status(status::Status::ProxyRequestRefused, "Url doesn't match certificate!").await?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@@ -158,6 +144,21 @@ async fn handle_connection(mut con: conn::Connection, srv: &config::ServerCfg) -
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if srv.proxy.len() != 0 {
|
||||||
|
match url.path_segments().map(|c| c.collect::<Vec<_>>()) {
|
||||||
|
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();
|
let mut path = PathBuf::new();
|
||||||
|
|
||||||
if url.path().starts_with("/~") && srv.usrdir == true{
|
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
|
// This block is terrible
|
||||||
if meta.is_dir() {
|
if meta.is_dir() {
|
||||||
if !url.path().ends_with("/") {
|
if !url.path().ends_with("/") {
|
||||||
|
println!("{}", url);
|
||||||
con.send_status(
|
con.send_status(
|
||||||
status::Status::RedirectPermanent,
|
status::Status::RedirectPermanent,
|
||||||
format!("{}/", url).as_str(),
|
format!("{}/", url).as_str(),
|
||||||
|
|||||||
Reference in New Issue
Block a user