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