Skip to content

Commit

Permalink
Refactor proxy.rs to rename serve_static to serve_request
Browse files Browse the repository at this point in the history
Refactor web_func.rs to update serve_http_request authentication logic
  • Loading branch information
arloor committed Sep 26, 2024
1 parent 88755c0 commit 7d6ef8f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions rust_http_proxy/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl ProxyHandler {
// http2.0肯定是over tls的,所以不是普通GET/POST代理请求。
// URL中不包含host(GET / HTTP/1.1)也不是普通GET/POST代理请求。
return self
.serve_static(
.serve_request(
&req,
config_basic_auth,
never_ask_for_auth,
Expand Down Expand Up @@ -332,7 +332,7 @@ impl ProxyHandler {
}
}

async fn serve_static(
async fn serve_request(
&self,
req: &Request<Incoming>,
config_basic_auth: &HashMap<String, String>,
Expand Down
5 changes: 2 additions & 3 deletions rust_http_proxy/src/web_func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,12 @@ pub async fn serve_http_request(
#[cfg(target_os = "linux")]
(_, "/net") => _speed(&proxy_handler.net_monitor, _hostname, can_gzip).await,
(_, "/metrics") => {
let (_, authed) = check_auth(
if let (_, false) = check_auth(
&proxy_handler.config.basic_auth,
req,
&client_socket_addr,
hyper::header::AUTHORIZATION,
);
if !authed {
) {
return Ok(build_authenticate_resp(false));
}
#[cfg(feature = "bpf")]
Expand Down

0 comments on commit 7d6ef8f

Please sign in to comment.