From ca4c2e7505f28acad688705d45cc5c5dca1799c3 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Mon, 20 Jun 2022 18:09:20 +0200 Subject: WIP refactor --- src/server.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'src/server.rs') 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>, @@ -60,7 +55,7 @@ impl Server { } } -fn build(config: Config) -> Result<(Arc, Option, Option> { +fn build(config: Config) -> Result<(ArcLoginProvider, Option, Option)> { let s3_region = Region::Custom { name: config.aws_region.clone(), endpoint: config.s3_endpoint, @@ -70,7 +65,7 @@ fn build(config: Config) -> Result<(Arc, Option endpoint: config.k2v_endpoint, }; - let lp: Arc = 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, 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, Arc>) { -- cgit v1.2.3