From d9385ca44b2119dc82cf92f993c8b59efff1a6a6 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Tue, 8 Aug 2023 20:03:46 +0200 Subject: [PATCH] lint --- warpgate-admin/src/api/roles.rs | 4 ++-- warpgate-admin/src/api/targets.rs | 4 ++-- warpgate-admin/src/api/users.rs | 4 ++-- warpgate-core/src/auth_state_store.rs | 2 +- warpgate-protocol-http/src/api/auth.rs | 2 +- warpgate-protocol-http/src/api/targets_list.rs | 5 +---- warpgate-protocol-http/src/common.rs | 1 - warpgate-protocol-mysql/src/lib.rs | 6 ++++-- warpgate-protocol-mysql/src/session.rs | 3 +-- warpgate-protocol-ssh/src/server/session.rs | 1 - 10 files changed, 14 insertions(+), 18 deletions(-) diff --git a/warpgate-admin/src/api/roles.rs b/warpgate-admin/src/api/roles.rs index 1e31558..a205ad6 100644 --- a/warpgate-admin/src/api/roles.rs +++ b/warpgate-admin/src/api/roles.rs @@ -48,8 +48,8 @@ impl ListApi { let mut roles = Role::Entity::find().order_by_asc(Role::Column::Name); if let Some(ref search) = *search { - let search = format!("%{}%", search); - roles = roles.filter(Role::Column::Name.like(&*search)); + let search = format!("%{search}%"); + roles = roles.filter(Role::Column::Name.like(&search)); } let roles = roles diff --git a/warpgate-admin/src/api/targets.rs b/warpgate-admin/src/api/targets.rs index 43f0323..85b83a9 100644 --- a/warpgate-admin/src/api/targets.rs +++ b/warpgate-admin/src/api/targets.rs @@ -50,8 +50,8 @@ impl ListApi { let mut targets = Target::Entity::find().order_by_asc(Target::Column::Name); if let Some(ref search) = *search { - let search = format!("%{}%", search); - targets = targets.filter(Target::Column::Name.like(&*search)); + let search = format!("%{search}%"); + targets = targets.filter(Target::Column::Name.like(&search)); } let targets = targets.all(&*db).await.map_err(WarpgateError::from)?; diff --git a/warpgate-admin/src/api/users.rs b/warpgate-admin/src/api/users.rs index df589b8..ed30551 100644 --- a/warpgate-admin/src/api/users.rs +++ b/warpgate-admin/src/api/users.rs @@ -53,8 +53,8 @@ impl ListApi { let mut users = User::Entity::find().order_by_asc(User::Column::Username); if let Some(ref search) = *search { - let search = format!("%{}%", search); - users = users.filter(User::Column::Username.like(&*search)); + let search = format!("%{search}%"); + users = users.filter(User::Column::Username.like(&search)); } let users = users.all(&*db).await.map_err(WarpgateError::from)?; diff --git a/warpgate-core/src/auth_state_store.rs b/warpgate-core/src/auth_state_store.rs index 8d8225e..d940541 100644 --- a/warpgate-core/src/auth_state_store.rs +++ b/warpgate-core/src/auth_state_store.rs @@ -6,7 +6,7 @@ use once_cell::sync::Lazy; use tokio::sync::{broadcast, Mutex}; use uuid::Uuid; use warpgate_common::auth::{AuthResult, AuthState}; -use warpgate_common::{WarpgateError, SessionId}; +use warpgate_common::{SessionId, WarpgateError}; use crate::ConfigProvider; diff --git a/warpgate-protocol-http/src/api/auth.rs b/warpgate-protocol-http/src/api/auth.rs index 0f7f5c6..6988bda 100644 --- a/warpgate-protocol-http/src/api/auth.rs +++ b/warpgate-protocol-http/src/api/auth.rs @@ -360,7 +360,7 @@ async fn serialize_auth_state_inner( Ok(AuthStateResponse::Ok(Json(AuthStateResponseInternal { protocol: state.protocol().to_string(), address: peer_addr.map(|x| x.ip().to_string()), - started: state.started().clone(), + started: *state.started(), state: state.verify().into(), identification_string: state.identification_string().to_owned(), }))) diff --git a/warpgate-protocol-http/src/api/targets_list.rs b/warpgate-protocol-http/src/api/targets_list.rs index 019c9ec..b0ff477 100644 --- a/warpgate-protocol-http/src/api/targets_list.rs +++ b/warpgate-protocol-http/src/api/targets_list.rs @@ -45,10 +45,7 @@ impl Api { }; if let Some(ref search) = *search { - targets = targets - .into_iter() - .filter(|t| t.name.contains(search)) - .collect() + targets.retain(|t| t.name.contains(search)) } let mut targets = stream::iter(targets) diff --git a/warpgate-protocol-http/src/common.rs b/warpgate-protocol-http/src/common.rs index 8fa12bd..b7c9ab0 100644 --- a/warpgate-protocol-http/src/common.rs +++ b/warpgate-protocol-http/src/common.rs @@ -8,7 +8,6 @@ use poem::web::{Data, Redirect}; use poem::{Endpoint, EndpointExt, FromRequest, IntoResponse, Request, Response}; use serde::{Deserialize, Serialize}; use tokio::sync::Mutex; -use tracing::*; use uuid::Uuid; use warpgate_common::auth::AuthState; use warpgate_common::{ProtocolName, TargetOptions, WarpgateError}; diff --git a/warpgate-protocol-mysql/src/lib.rs b/warpgate-protocol-mysql/src/lib.rs index e976727..656bd08 100644 --- a/warpgate-protocol-mysql/src/lib.rs +++ b/warpgate-protocol-mysql/src/lib.rs @@ -86,13 +86,15 @@ impl ProtocolServer for MySQLProtocolServer { .register_session( &crate::common::PROTOCOL_NAME, SessionStateInit { - remote_address: Some(remote_address.clone()), + remote_address: Some(remote_address), handle: Box::new(session_handle), }, ) .await?; - let session = MySqlSession::new(server_handle, services, stream, tls_config, remote_address).await; + let session = + MySqlSession::new(server_handle, services, stream, tls_config, remote_address) + .await; let span = session.make_logging_span(); tokio::select! { result = session.run().instrument(span) => match result { diff --git a/warpgate-protocol-mysql/src/session.rs b/warpgate-protocol-mysql/src/session.rs index 2c6c6c6..9fd3f8f 100644 --- a/warpgate-protocol-mysql/src/session.rs +++ b/warpgate-protocol-mysql/src/session.rs @@ -312,8 +312,7 @@ impl MySqlSession { handle.set_target(&target).await?; } - self.run_authorized_inner(handshake, mysql_options) - .await + self.run_authorized_inner(handshake, mysql_options).await } async fn run_authorized_inner( diff --git a/warpgate-protocol-ssh/src/server/session.rs b/warpgate-protocol-ssh/src/server/session.rs index a20f236..cff6b9a 100644 --- a/warpgate-protocol-ssh/src/server/session.rs +++ b/warpgate-protocol-ssh/src/server/session.rs @@ -1325,7 +1325,6 @@ impl ServerSession { login_url, identification_string .chars() - .into_iter() .map(|x| x.to_string()) .collect::>() .join(" ")