use std::sync::mpsc;
mod configuration;
+mod middleware;
mod proxy;
use configuration::Configuration;
--- /dev/null
+use log::debug;
+
+/// MailDrop can't find folders to sync because it sends FIND MAILBOXES /*
+/// which is not understood by modern servers. It instead replaces it with
+/// a LIST command.
+pub fn middleware(input: &[u8]) -> Vec<u8> {
+ let command = String::from_utf8_lossy(input);
+ if let Some(tag) = command.split("FIND MAILBOXES /*").next() {
+ let replacement = format!("{} LIST \"/INBOX\" \"*\"\r\n", tag.trim());
+ debug!("### {replacement}");
+ return replacement.into_bytes();
+ }
+ return input.to_vec();
+}
--- /dev/null
+mod find_mailboxes_compatibility;
+
+use find_mailboxes_compatibility::middleware as find_mailboxes_compatibility_middleware;
+
+type Middleware = fn(&[u8]) -> Vec<u8>;
+
+pub const MIDDLEWARE: [Middleware; 1] = [find_mailboxes_compatibility_middleware];
use std::time::Duration;
use crate::configuration::Proxy;
+use crate::middleware::MIDDLEWARE;
/// A proxy server that listens for plaintext connections and forwards them
/// via TLS.
}
};
- let debug_str = String::from_utf8_lossy(&buffer[..bytes_read])
+ let mut command = buffer[..bytes_read].to_vec();
+
+ for middleware in MIDDLEWARE {
+ command = middleware(&command);
+ }
+
+ let debug_str = String::from_utf8_lossy(&command)
.replace('\n', "\\n")
.replace('\r', "\\r")
.replace('\t', "\\t");