chore: fix clippy lints

This commit is contained in:
javalsai 2025-07-02 05:59:48 +02:00
parent 2ab9c5d134
commit eec62c129a
Signed by: javalsai
SSH Key Fingerprint: SHA256:3G83yKhBUWVABVX/vPWH88xnK4+ptMtHkZGCRXD4Mk8
3 changed files with 12 additions and 21 deletions

7
Cargo.lock generated
View File

@ -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",

View File

@ -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"

View File

@ -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<Ref<'a, String, AuthData>>)>,
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<String, AuthData> = DashMap::new();
static ref CSRF_MAP: DashMap<String, AuthData> = DashMap::new();
}
// TODO: might wanna save this one between runtimes
static AUTH_MAP: std::sync::LazyLock<DashMap<String, AuthData>> =
std::sync::LazyLock::new(DashMap::new);
static _CSRF_MAP: std::sync::LazyLock<DashMap<String, String>> =
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(())
}