Skip to content

Commit

Permalink
more file reorganization
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-maron committed Feb 12, 2024
1 parent df65606 commit 7990273
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 20 deletions.
32 changes: 32 additions & 0 deletions marshal/src/handlers.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use proto::{
connection::{
auth::marshal::MarshalAuth,
protocols::{Protocol, Sender},
},
crypto::{Scheme, Serializable},
redis,
};

use crate::Marshal;

impl<SignatureScheme: Scheme, ProtocolType: Protocol> Marshal<SignatureScheme, ProtocolType>
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::<SignatureScheme, ProtocolType>::verify_user(
&mut connection,
&mut redis_client,
)
.await;

// We don't care about this, just drop the connection immediately.
let _ = connection.0.finish().await;
}
}
23 changes: 3 additions & 20 deletions marshal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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::<SignatureScheme, ProtocolType>::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.
///
Expand Down

0 comments on commit 7990273

Please sign in to comment.