Changed hostname check to be case insensitive

This commit is contained in:
int 80h
2021-11-21 16:02:38 -05:00
parent c7677ce2f2
commit 0afdf8075f
3 changed files with 11 additions and 6 deletions

2
Cargo.lock generated
View File

@@ -140,7 +140,7 @@ dependencies = [
[[package]] [[package]]
name = "gemserv" name = "gemserv"
version = "0.4.8" version = "0.4.9"
dependencies = [ dependencies = [
"futures-util", "futures-util",
"log", "log",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "gemserv" name = "gemserv"
version = "0.4.8" version = "0.4.9"
authors = ["int 80h <int@80h.dev>"] authors = ["int 80h <int@80h.dev>"]
edition = "2018" edition = "2018"
description = "A gemini server" description = "A gemini server"

View File

@@ -204,10 +204,15 @@ async fn get_request(mut con: conn::Connection) -> Result<(conn::Connection, url
} }
}; };
if Some(con.srv.server.hostname.as_str()) != url.host_str() { match url.host_str() {
logger::logger(con.peer_addr, Status::ProxyRequestRefused, &url.as_str()); Some(h) => {
con.send_status(Status::ProxyRequestRefused, None).await.map_err(|e| e.to_string())?; if con.srv.server.hostname.as_str() != h.to_lowercase() {
return Err("Wrong host".to_string()); logger::logger(con.peer_addr, Status::ProxyRequestRefused, &url.as_str());
con.send_status(Status::ProxyRequestRefused, None).await.map_err(|e| e.to_string())?;
return Err("Wrong host".to_string());
}
},
None => {}
} }
match url.port() { match url.port() {