]> git.r.bdr.sh - rbdr/olden-mail/blob - src/configuration.rs
143759438bac1e9213a80094640a7a760acf0de5
[rbdr/olden-mail] / src / configuration.rs
1 use std::env;
2 use std::sync::Arc;
3
4 pub struct ProxyConfiguration {
5 pub local_port: u16,
6 pub remote_domain: String,
7 pub remote_port: u16,
8 pub protocol: &'static str,
9 }
10
11 pub struct Configuration {
12 pub imap_configuration: Arc<ProxyConfiguration>,
13 pub smtp_configuration: Arc<ProxyConfiguration>,
14 }
15
16 impl Configuration {
17 pub fn new() -> Self {
18 Configuration {
19 imap_configuration: Arc::new(ProxyConfiguration {
20 local_port: env::var("LOCAL_IMAP_PORT")
21 .expect("LOCAL_IMAP_PORT not set")
22 .parse()
23 .expect("Invalid LOCAL_IMAP_PORT"),
24 remote_domain: env::var("REMOTE_IMAP_DOMAIN").expect("REMOTE_IMAP_DOMAIN not set"),
25 remote_port: env::var("REMOTE_IMAP_PORT")
26 .expect("REMOTE_IMAP_PORT not set")
27 .parse()
28 .expect("Invalid REMOTE_IMAP_PORT"),
29 protocol: "IMAP",
30 }),
31 smtp_configuration: Arc::new(ProxyConfiguration {
32 local_port: env::var("LOCAL_SMTP_PORT")
33 .expect("LOCAL_SMTP_PORT not set")
34 .parse()
35 .expect("Invalid LOCAL_SMTP_PORT"),
36 remote_domain: env::var("REMOTE_SMTP_DOMAIN").expect("REMOTE_SMTP_DOMAIN not set"),
37 remote_port: env::var("REMOTE_SMTP_PORT")
38 .expect("REMOTE_SMTP_PORT not set")
39 .parse()
40 .expect("Invalid REMOTE_SMTP_PORT"),
41 protocol: "SMTP",
42 }),
43 }
44 }
45 }