diff options
author | metamuffin <metamuffin@disroot.org> | 2025-03-19 19:35:16 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-03-19 19:35:16 +0100 |
commit | 69a77b36172503ada9047a756bb5972a4c7005dc (patch) | |
tree | 8a361183533e972d38b06b59f7a77c98f76b3ab3 | |
parent | e22020da294381b22998ee885876b56614bca890 (diff) | |
download | gnix-69a77b36172503ada9047a756bb5972a4c7005dc.tar gnix-69a77b36172503ada9047a756bb5972a4c7005dc.tar.bz2 gnix-69a77b36172503ada9047a756bb5972a4c7005dc.tar.zst |
clippy
-rw-r--r-- | src/certs.rs | 2 | ||||
-rw-r--r-- | src/modules/auth/cookie.rs | 6 | ||||
-rw-r--r-- | src/modules/auth/openid.rs | 8 | ||||
-rw-r--r-- | src/modules/cache.rs | 4 | ||||
-rw-r--r-- | src/modules/cgi.rs | 6 | ||||
-rw-r--r-- | src/modules/fallback.rs | 4 | ||||
-rw-r--r-- | src/modules/files.rs | 2 | ||||
-rw-r--r-- | src/modules/headers.rs | 4 | ||||
-rw-r--r-- | src/modules/inspect.rs | 2 |
9 files changed, 18 insertions, 20 deletions
diff --git a/src/certs.rs b/src/certs.rs index 05a25c7..09a8621 100644 --- a/src/certs.rs +++ b/src/certs.rs @@ -38,7 +38,7 @@ impl CertPool { pub fn load(roots: &[PathBuf], fallback: Option<PathBuf>) -> Result<Self> { let mut s = Self::default(); for r in roots { - s.load_recursive(&r)?; + s.load_recursive(r)?; } if let Some(path) = fallback { let keypath = path.join("privkey.pem"); diff --git a/src/modules/auth/cookie.rs b/src/modules/auth/cookie.rs index e078b6f..8e6d1d6 100644 --- a/src/modules/auth/cookie.rs +++ b/src/modules/auth/cookie.rs @@ -77,7 +77,7 @@ impl Node for CookieAuth { debug!("login attempt for {username:?}"); if self.users.authentificate(username, password) { debug!("login success via creds"); - Ok(login_success_response(context, &self, referrer, username)) + Ok(login_success_response(context, self, referrer, username)) } else { debug!("login fail"); let mut r = Response::new(BoxBody::<_, ServiceError>::new( @@ -133,12 +133,12 @@ impl Node for CookieAuth { if let Some(username) = r.headers_mut().remove("gnix-auth-success") { debug!("login success via fail handler"); if r.headers_mut().remove("gnix-auth-no-redirect").is_some() { - apply_login_success_headers(context, &self, username.to_str()?, &mut r); + apply_login_success_headers(context, self, username.to_str()?, &mut r); Ok(r) } else { Ok(login_success_response( context, - &self, + self, referrer, username.to_str()?, )) diff --git a/src/modules/auth/openid.rs b/src/modules/auth/openid.rs index db03c2f..e22bc24 100644 --- a/src/modules/auth/openid.rs +++ b/src/modules/auth/openid.rs @@ -143,7 +143,7 @@ id_token={id_token:?}"# let mut v = context .state .crypto_key - .encrypt(Nonce::from_slice(&nonce), Payload { msg: &r, aad: &[] }) + .encrypt(Nonce::from_slice(&nonce), Payload { msg: r, aad: &[] }) .unwrap(); v.extend(nonce); @@ -190,7 +190,7 @@ fn redirect_uri(request: &NodeRequest) -> Result<Uri, ServiceError> { .to_str()?, ) .ok(); - Ok(Uri::from_parts(redirect_uri).map_err(|_| ServiceError::InvalidUri)?) + Uri::from_parts(redirect_uri).map_err(|_| ServiceError::InvalidUri) } async fn token_request( @@ -234,8 +234,8 @@ async fn token_request( let mut buf = String::new(); body.reader().read_to_string(&mut buf).unwrap(); eprintln!("{buf}"); - Ok(serde_json::from_str(&buf) - .map_err(|_| ServiceError::CustomStatic("invalid token response"))?) + serde_json::from_str(&buf) + .map_err(|_| ServiceError::CustomStatic("invalid token response")) } #[derive(Debug, Deserialize)] diff --git a/src/modules/cache.rs b/src/modules/cache.rs index 68f011f..8d77086 100644 --- a/src/modules/cache.rs +++ b/src/modules/cache.rs @@ -74,7 +74,7 @@ impl Node for Cache { hasher.update(k); hasher.update(v); } - let key: [u8; 32] = hasher.finalize().try_into().unwrap(); + let key: [u8; 32] = hasher.finalize().into(); if let Some(resp) = self.entries.read().await.get(&key) { return Ok(resp @@ -90,7 +90,7 @@ impl Node for Cache { let mut r1 = Response::new(Full::new(body.clone()).map_err(|e| match e {}).boxed()); *r1.headers_mut() = h.clone(); - *r1.status_mut() = s.clone(); + *r1.status_mut() = s; let mut r2 = Response::new(body); *r2.headers_mut() = h; diff --git a/src/modules/cgi.rs b/src/modules/cgi.rs index 6d68b15..d54ec9d 100644 --- a/src/modules/cgi.rs +++ b/src/modules/cgi.rs @@ -88,8 +88,7 @@ impl Node for Cgi { request .headers() .get(CONTENT_LENGTH) - .map(|x| x.to_str().ok()) - .flatten() + .and_then(|x| x.to_str().ok()) .unwrap_or_default(), ); command.env( @@ -97,8 +96,7 @@ impl Node for Cgi { request .headers() .get(CONTENT_TYPE) - .map(|x| x.to_str().ok()) - .flatten() + .and_then(|x| x.to_str().ok()) .unwrap_or_default(), ); command.env("GATEWAY_INTERFACE", "CGI/1.1"); diff --git a/src/modules/fallback.rs b/src/modules/fallback.rs index 22ae1ef..63e82d4 100644 --- a/src/modules/fallback.rs +++ b/src/modules/fallback.rs @@ -58,9 +58,9 @@ impl Node for Fallback { } } } - return Err(ServiceError::CustomStatic( + Err(ServiceError::CustomStatic( "fallback module without any handlers", - )); + )) }) } } diff --git a/src/modules/files.rs b/src/modules/files.rs index 319d6d5..bc458b0 100644 --- a/src/modules/files.rs +++ b/src/modules/files.rs @@ -83,7 +83,7 @@ impl Node for Files { for seg in rpath.split("/") { let seg = percent_decode_str(seg).decode_utf8()?; - if seg == "" || seg == "." { + if seg.is_empty() || seg == "." { continue; } diff --git a/src/modules/headers.rs b/src/modules/headers.rs index 731f785..906d816 100644 --- a/src/modules/headers.rs +++ b/src/modules/headers.rs @@ -38,11 +38,11 @@ impl Node for Headers { Box::pin(async move { request .headers_mut() - .extend(self.request.0.clone().into_iter()); + .extend(self.request.0.clone()); let mut response = self.next.handle(context, request).await?; response .headers_mut() - .extend(self.response.0.clone().into_iter()); + .extend(self.response.0.clone()); Ok(response) }) } diff --git a/src/modules/inspect.rs b/src/modules/inspect.rs index 1ad6522..a31e3e3 100644 --- a/src/modules/inspect.rs +++ b/src/modules/inspect.rs @@ -36,7 +36,7 @@ impl Node for Inspect { request.uri(), request.headers(), ); - Ok(self.next.handle(context, request).await?) + self.next.handle(context, request).await }) } } |