diff --git a/Cargo.lock b/Cargo.lock index 4ad8d44..e0b0061 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -229,12 +229,6 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" - [[package]] name = "libc" version = "0.2.174" @@ -511,7 +505,6 @@ dependencies = [ "ctrlc", "dashmap", "httparse", - "lazy_static", "parking_lot", "serde", "shlex", diff --git a/Cargo.toml b/Cargo.toml index 850e3ff..f8e9573 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,6 @@ cookie = "0" ctrlc = "3" dashmap = "6" httparse = "1" -lazy_static = "1" parking_lot = { version = "0", features = ["arc_lock", "serde"] } serde = { version = "1", features = ["derive"] } shlex = "1" diff --git a/src/main.rs b/src/main.rs index 9fe8744..ae8dac8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,7 +18,6 @@ use std::{ use anyhow::Context; use clap::Parser; use dashmap::{DashMap, mapref::one::Ref}; -use lazy_static::lazy_static; use thiserror::Error; use crate::utils::headers::HeadersExt; @@ -156,7 +155,7 @@ impl AuthData { into.write_all(b"X-WEBAUTH-FULLNAME: ")?; into.write_all(fullname.as_bytes())?; into.write_all(NL)?; - }; + } }; r.map_err(ClientError::AuthHeadersIoError) } @@ -165,10 +164,10 @@ impl AuthData { fn what_to_do<'a>( req: &httparse::Request, id_auth: Option<(String, Option>)>, - backend: (net::SocketAddr, String, String), + _backend: (net::SocketAddr, String, String), ) -> ProxyAction<'a> { - let is_auth = id_auth.as_ref().is_some_and(|id_auth| id_auth.1.is_some()); - match (req.path, req.method, is_auth) { + let is_authd = id_auth.as_ref().is_some_and(|id_auth| id_auth.1.is_some()); + match (req.path, req.method, is_authd) { (Some("/user/login"), Some("GET"), false) => todo!(), (Some("/user/login"), Some("POST"), false) => todo!(), _ => ProxyAction { @@ -179,11 +178,11 @@ fn what_to_do<'a>( } } -lazy_static! { - // TODO: might wanna save this one between runtimes - static ref AUTH_MAP: DashMap = DashMap::new(); - static ref CSRF_MAP: DashMap = DashMap::new(); -} +// TODO: might wanna save this one between runtimes +static AUTH_MAP: std::sync::LazyLock> = + std::sync::LazyLock::new(DashMap::new); +static _CSRF_MAP: std::sync::LazyLock> = + std::sync::LazyLock::new(DashMap::new); fn handle_client(client: &mut TcpStream, config: &config::Schema) -> Result<(), ClientError> { use ClientError as E; @@ -223,7 +222,7 @@ fn handle_client(client: &mut TcpStream, config: &config::Schema) -> Result<(), // Try to find auth data let id_auth = if let Some(cookies) = cookies { if let Some(id_ck) = cookie::Cookie::split_parse(cookies) - .filter_map(|ck| ck.ok()) + .filter_map(Result::ok) .find(|ck| ck.name() == id_keyname) { let id = id_ck.value().to_string(); @@ -251,7 +250,7 @@ fn handle_client(client: &mut TcpStream, config: &config::Schema) -> Result<(), .map_err(E::ExchangeIoError)?; if let Some(auth) = action.auth { auth.write_as_headers(&mut stream)?; - }; + } // send our overhead stream @@ -270,7 +269,7 @@ fn handle_client(client: &mut TcpStream, config: &config::Schema) -> Result<(), } else { io::copy(&mut stream, client).map_err(E::ExchangeIoError)?; } - }; + } Ok(()) }