From 799027343b2d1f8f0452684d5d634ee9e1cc8163 Mon Sep 17 00:00:00 2001 From: Rob Date: Mon, 12 Feb 2024 11:40:05 -0500 Subject: [PATCH] more file reorganization --- marshal/src/handlers.rs | 32 ++++++++++++++++++++++++++++++++ marshal/src/lib.rs | 23 +++-------------------- 2 files changed, 35 insertions(+), 20 deletions(-) create mode 100644 marshal/src/handlers.rs diff --git a/marshal/src/handlers.rs b/marshal/src/handlers.rs new file mode 100644 index 0000000..4975ba7 --- /dev/null +++ b/marshal/src/handlers.rs @@ -0,0 +1,32 @@ +use proto::{ + connection::{ + auth::marshal::MarshalAuth, + protocols::{Protocol, Sender}, + }, + crypto::{Scheme, Serializable}, + redis, +}; + +use crate::Marshal; + +impl Marshal +where + SignatureScheme::VerificationKey: Serializable, + SignatureScheme::Signature: Serializable, +{ + /// Handles a user's connection, including authentication. + pub async fn handle_connection( + mut connection: (ProtocolType::Sender, ProtocolType::Receiver), + mut redis_client: redis::Client, + ) { + // Verify (authenticate) the connection + let _ = MarshalAuth::::verify_user( + &mut connection, + &mut redis_client, + ) + .await; + + // We don't care about this, just drop the connection immediately. + let _ = connection.0.finish().await; + } +} diff --git a/marshal/src/lib.rs b/marshal/src/lib.rs index 06c8bcc..40d8ab5 100644 --- a/marshal/src/lib.rs +++ b/marshal/src/lib.rs @@ -5,12 +5,11 @@ use std::{marker::PhantomData, sync::Arc}; +mod handlers; + use proto::{ bail, - connection::{ - auth::marshal::MarshalAuth, - protocols::{Listener, Protocol, Sender}, - }, + connection::protocols::{Listener, Protocol}, crypto::{Scheme, Serializable}, error::{Error, Result}, redis, @@ -74,22 +73,6 @@ where }) } - /// Handles a user's connection, including authentication. - pub async fn handle_connection( - mut connection: (ProtocolType::Sender, ProtocolType::Receiver), - mut redis_client: redis::Client, - ) { - // Verify (authenticate) the connection - let _ = MarshalAuth::::verify_user( - &mut connection, - &mut redis_client, - ) - .await; - - // We don't care about this, just drop the connection immediately. - let _ = connection.0.finish().await; - } - /// The main loop for a marshal. /// Consumes self. ///