aboutsummaryrefslogtreecommitdiff
path: root/src/configuration.rs
diff options
context:
space:
mode:
authorRuben Beltran del Rio <git@r.bdr.sh>2025-01-24 20:34:35 +0100
committerRuben Beltran del Rio <git@r.bdr.sh>2025-01-24 20:34:35 +0100
commitdc3d68214e2cd4b5f86279a7fa7b7d64c341b446 (patch)
tree30da7fdfcf612f00705e87acdf379a0334d6cb08 /src/configuration.rs
First approach
Diffstat (limited to 'src/configuration.rs')
-rw-r--r--src/configuration.rs45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/configuration.rs b/src/configuration.rs
new file mode 100644
index 0000000..1437594
--- /dev/null
+++ b/src/configuration.rs
@@ -0,0 +1,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",
+ }),
+ }
+ }
+}