- Add proton-bridge as optional dep behind `proton` feature flag - New proton-bridge/src/lib.rs: pub fn start() spins a background Tokio thread, pre-binds ports, and signals readiness via mpsc before returning - src/main.rs: conditionally starts bridge before TUI enters raw mode; derives effective IMAP/SMTP config via Provider enum - src/config.rs: add Provider enum, optional imap/smtp, ProtonConfig/ BridgeConfig mirrors, effective_imap/smtp() helpers - Remove all per-operation eprintln!/println! from imap_server, smtp_server, and api.rs that fired during TUI operation and corrupted the display - config.toml.example: unified format covering both imap and proton providers Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
32 lines
1 KiB
Rust
32 lines
1 KiB
Rust
use std::fs;
|
|
|
|
fn main() {
|
|
env_logger::init();
|
|
|
|
let content = fs::read_to_string("config.toml").unwrap_or_else(|e| {
|
|
eprintln!("Failed to read config.toml: {e}");
|
|
std::process::exit(1);
|
|
});
|
|
let config: proton_bridge::config::Config = toml::from_str(&content).unwrap_or_else(|e| {
|
|
eprintln!("Failed to parse config.toml: {e}");
|
|
std::process::exit(1);
|
|
});
|
|
|
|
let imap_port = config.bridge.imap_port;
|
|
let smtp_port = config.bridge.smtp_port;
|
|
|
|
eprint!("Starting ProtonMail bridge...");
|
|
proton_bridge::start(config).unwrap_or_else(|e| {
|
|
eprintln!("\nBridge failed to start: {e}");
|
|
std::process::exit(1);
|
|
});
|
|
eprintln!(" ready. IMAP :{imap_port} SMTP :{smtp_port} (Ctrl-C to stop)");
|
|
|
|
// Block until Ctrl-C (the servers run in a background thread).
|
|
let rt = tokio::runtime::Builder::new_current_thread()
|
|
.enable_all()
|
|
.build()
|
|
.expect("tokio runtime");
|
|
rt.block_on(tokio::signal::ctrl_c()).ok();
|
|
println!("Shutting down.");
|
|
}
|