diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2022-06-20 18:09:20 +0200 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2022-06-20 18:09:20 +0200 |
commit | ca4c2e7505f28acad688705d45cc5c5dca1799c3 (patch) | |
tree | 6820ad27dfdaa5e51e2f296832d75a4a9a6678ae /src/server.rs | |
parent | 5dd5ae8bcd6f88703bc483d7f8d5882fefad4e7e (diff) | |
download | aerogramme-ca4c2e7505f28acad688705d45cc5c5dca1799c3.tar.gz aerogramme-ca4c2e7505f28acad688705d45cc5c5dca1799c3.zip |
WIP refactor
Diffstat (limited to 'src/server.rs')
-rw-r--r-- | src/server.rs | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/server.rs b/src/server.rs index acf9cf2..908ed11 100644 --- a/src/server.rs +++ b/src/server.rs @@ -1,21 +1,16 @@ use std::sync::Arc; -use boitalettres::server::accept::addr::AddrIncoming; -use boitalettres::server::accept::addr::AddrStream; -use boitalettres::server::Server as ImapServer; - use anyhow::{bail, Result}; use futures::{try_join, StreamExt}; use log::*; use rusoto_signature::Region; use tokio::sync::watch; -use tower::Service; use crate::config::*; use crate::lmtp::*; use crate::login::{ldap_provider::*, static_provider::*, *}; -use crate::mailbox::Mailbox; use crate::imap; +use crate::login::ArcLoginProvider; pub struct Server { lmtp_server: Option<Arc<LmtpServer>>, @@ -60,7 +55,7 @@ impl Server { } } -fn build(config: Config) -> Result<(Arc<dyn LoginProvider + Send + Sync>, Option<LmtpConfig>, Option<ImapConfig>> { +fn build(config: Config) -> Result<(ArcLoginProvider, Option<LmtpConfig>, Option<ImapConfig>)> { let s3_region = Region::Custom { name: config.aws_region.clone(), endpoint: config.s3_endpoint, @@ -70,7 +65,7 @@ fn build(config: Config) -> Result<(Arc<dyn LoginProvider + Send + Sync>, Option endpoint: config.k2v_endpoint, }; - let lp: Arc<dyn LoginProvider + Send + Sync> = match (config.login_static, config.login_ldap) { + let lp: ArcLoginProvider = match (config.login_static, config.login_ldap) { (Some(st), None) => Arc::new(StaticLoginProvider::new(st, k2v_region, s3_region)?), (None, Some(ld)) => Arc::new(LdapLoginProvider::new(ld, k2v_region, s3_region)?), (Some(_), Some(_)) => { @@ -79,7 +74,7 @@ fn build(config: Config) -> Result<(Arc<dyn LoginProvider + Send + Sync>, Option (None, None) => bail!("No login provider is set up in config file"), }; - Ok(lp, self.lmtp_config, self.imap_config) + Ok(lp, config.lmtp_config, config.imap_config) } pub fn watch_ctrl_c() -> (watch::Receiver<bool>, Arc<watch::Sender<bool>>) { |