From 0afdf8075f0a4c42777e465037fca56de00f8478 Mon Sep 17 00:00:00 2001 From: int 80h Date: Sun, 21 Nov 2021 16:02:38 -0500 Subject: [PATCH] Changed hostname check to be case insensitive --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/main.rs | 13 +++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2dfa87f..ee3f381 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -140,7 +140,7 @@ dependencies = [ [[package]] name = "gemserv" -version = "0.4.8" +version = "0.4.9" dependencies = [ "futures-util", "log", diff --git a/Cargo.toml b/Cargo.toml index 4203ccd..fdd651b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gemserv" -version = "0.4.8" +version = "0.4.9" authors = ["int 80h "] edition = "2018" description = "A gemini server" diff --git a/src/main.rs b/src/main.rs index ee42fab..4680ed1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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() { - 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()); + match url.host_str() { + Some(h) => { + if con.srv.server.hostname.as_str() != h.to_lowercase() { + 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() {