aboutsummaryrefslogtreecommitdiff
path: root/src/server.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/server.rs')
-rw-r--r--src/server.rs18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/server.rs b/src/server.rs
index bd2fd5d..0df1caf 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -15,6 +15,7 @@ use crate::login::{demo_provider::*, ldap_provider::*, static_provider::*};
pub struct Server {
lmtp_server: Option<Arc<LmtpServer>>,
+ imap_unsecure_server: Option<imap::Server>,
imap_server: Option<imap::Server>,
pid_file: Option<PathBuf>,
}
@@ -25,10 +26,11 @@ impl Server {
let login = Arc::new(StaticLoginProvider::new(config.users).await?);
let lmtp_server = None;
- let imap_server = Some(imap::new(config.imap, login.clone()));
+ let imap_unsecure_server = Some(imap::new_unsecure(config.imap, login.clone()));
Ok(Self {
lmtp_server,
- imap_server,
+ imap_unsecure_server,
+ imap_server: None,
pid_file: config.pid,
})
}
@@ -41,11 +43,13 @@ impl Server {
UserManagement::Ldap(x) => Arc::new(LdapLoginProvider::new(x)?),
};
- let lmtp_server = Some(LmtpServer::new(config.lmtp, login.clone()));
- let imap_server = Some(imap::new(config.imap, login.clone()));
+ let lmtp_server = config.lmtp.map(|lmtp| LmtpServer::new(lmtp, login.clone()));
+ let imap_unsecure_server = config.imap_unsecure.map(|imap| imap::new_unsecure(imap, login.clone()));
+ let imap_server = config.imap.map(|imap| imap::new(imap, login.clone())).transpose()?;
Ok(Self {
lmtp_server,
+ imap_unsecure_server,
imap_server,
pid_file: config.pid,
})
@@ -80,6 +84,12 @@ impl Server {
}
},
async {
+ match self.imap_unsecure_server {
+ None => Ok(()),
+ Some(s) => s.run(exit_signal.clone()).await,
+ }
+ },
+ async {
match self.imap_server {
None => Ok(()),
Some(s) => s.run(exit_signal.clone()).await,