Index: Cargo.lock ================================================================== --- Cargo.lock +++ Cargo.lock @@ -1051,13 +1051,13 @@ "libc", ] [[package]] name = "js-sys" -version = "0.3.106" +version = "0.3.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7883d941dae510fb2d978fc3fe018c71c9e2892fd38854de3e8b92c2e5ad9cc5" +checksum = "8dc09d2154098bbf4ef54eab6b117a3c24cbbffe94046b16ee6d6d4510584d3a" dependencies = [ "cfg-if", "futures-util", "wasm-bindgen", ] @@ -1086,13 +1086,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" [[package]] name = "log" -version = "0.4.34" +version = "0.4.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" +checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" [[package]] name = "lru-slab" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1760,13 +1760,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" [[package]] name = "smallbox" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aca054fd9f8c2ebe8557a2433f307e038c0716124efd045daa0388afa5172189" +checksum = "e8d91712aabb2e735436c02f70d990d8b2241f42dd092a973694e198ea95fc93" [[package]] name = "smallvec" version = "1.16.4" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1787,26 +1787,13 @@ "async-process", "blocking", "futures-lite", ] -[[package]] -name = "smol-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfcaedb62e0475a6898988138995ec7b1e5d116167a72bb12c7b59d0649fbbc2" -dependencies = [ - "async-executor", - "async-io", - "async-lock", - "event-listener", - "futures-lite", -] - [[package]] name = "smtp2tg" -version = "0.6.9" +version = "0.6.10" dependencies = [ "async-compat", "clap", "config", "hostname", @@ -1813,11 +1800,10 @@ "html-escape", "mail-parser", "mailin-embedded", "regex", "smol", - "smol-macros", "stacked_errors", "tgbot", ] [[package]] @@ -2151,20 +2137,29 @@ "serde", ] [[package]] name = "utf8_iter" -version = "1.0.4" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" +checksum = "af3bd9d3e571c26fcce9d033b87ea5ab061b8d2ffe9b7a5675d810d68f03edf0" +dependencies = [ + "utf_types", +] [[package]] name = "utf8parse" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" +[[package]] +name = "utf_types" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a3b425286980a367278453f3b6d28cdcb134b574e5a35824a6ff5eebad50bb6" + [[package]] name = "walkdir" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" @@ -2188,47 +2183,46 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasm-bindgen" -version = "0.2.129" +version = "0.2.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409" +checksum = "a0181c14ddd6c7b8b0b0132a5f1ea2f32be0d893cd3ea97b6e3b28886b8a3d1c" dependencies = [ "cfg-if", - "once_cell", "rustversion", "wasm-bindgen-macro", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.79" +version = "0.4.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cbab34de2d982e9b48e18d216d04c4a6f641066ff19ffb699980f591ee3610e" +checksum = "5e14e0327cb5368ad60ccb22d04a9827a693c95a926d8d125e9fa39e0baec501" dependencies = [ "js-sys", "tokio", "wasm-bindgen", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.129" +version = "0.2.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535" +checksum = "6e931a02a39abdbf66966fc35902b5ed58344750a70885bed4ebb3d8eaf28ed9" dependencies = [ "quote", "wasm-bindgen-macro-support", ] [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.129" +version = "0.2.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7" +checksum = "2ca4b54280e455bd831e33a6b8e734baf432fe63fbc35c42ac14ce67a043a53a" dependencies = [ "bumpalo", "proc-macro2", "quote", "syn 3.0.9", @@ -2235,13 +2229,13 @@ "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.129" +version = "0.2.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6" +checksum = "3b1f9c3798725016c6ee5f2f57869ec0831e8bbc0ab0310a86e787e97f41389e" dependencies = [ "unicode-ident", ] [[package]] @@ -2257,13 +2251,13 @@ "web-sys", ] [[package]] name = "web-sys" -version = "0.3.106" +version = "0.3.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88261b9deccee56594c11a3460c462c41f58d148598fe70ad77070126a68aba4" +checksum = "d7d179596ff5ec0f6de4db64d54011bde6289cc49603d3a6e4ce3f329207ab88" dependencies = [ "js-sys", "wasm-bindgen", ] Index: Cargo.toml ================================================================== --- Cargo.toml +++ Cargo.toml @@ -1,8 +1,8 @@ [package] name = "smtp2tg" -version = "0.6.9" +version = "0.6.10" authors = [ "arcade@b1t.name" ] edition = "2024" license = "0BSD" repository = "http://fs.b1t.name/smtp2tg" @@ -14,11 +14,10 @@ clap = { version = "4.6", features = [ "derive" ] } mail-parser = "1" mailin-embedded = "0.8" regex = "1.11.1" smol = "2.0.2" -smol-macros = "0.1" stacked_errors = "0.8" tgbot = "0.48" # All tests are moved to tests/ [lib] Index: README.md ================================================================== --- README.md +++ README.md @@ -88,11 +88,11 @@ **Telegram message:** ```html
Subject: Test From: user@example.com -Date: Mon, 01 Jan 2024 12:00:00 +0000 +Date: 2024-01-01T12:00:00+00:00
Hello, world!
``` --- Index: src/main.rs ================================================================== --- src/main.rs +++ src/main.rs @@ -1,14 +1,9 @@ //! Simple SMTP-to-Telegram gateway. Can parse email and send them as telegram //! messages to specified chats, generally you specify which email address is //! available in configuration, everything else is sent to default address. -use smol_macros::{ - LocalExecutor, - main, -}; - use std::{ os::unix::fs::PermissionsExt, path::Path, }; @@ -30,11 +25,10 @@ /// Set configuration file location #[arg(short, long, default_value = "smtp2tg.toml")] config: String, } -main! { /// Main asynchronous entry point for the application. Runs the gateway using /// the configuration selected on the command line. /// /// The configuration file must use owner-only permissions. Once configured, /// the SMTP server runs until it stops or encounters an error. @@ -45,11 +39,12 @@ /// Also returns an error if the system hostname cannot be read or is not /// valid UTF-8, or if mail server initialisation fails. /// /// # Panics /// Panics if configuring or serving the SMTP server fails. - async fn main (ex: &LocalExecutor<'_>) -> Result<()> { +fn main () -> Result<()> { + smol::block_on(async move{ let args = Args::parse(); let settings = { // Load configuration defaults and overrides after checking file permissions. let config_file = Path::new(&args.config); if !config_file.try_exists().stack()? { @@ -88,10 +83,12 @@ let mut server = mailin_embedded::Server::new(core); // TODO: remove unwraps when mailin-embedded bumps with better error handling server.with_name(server_name) .with_ssl(mailin_embedded::SslConfig::None).unwrap() - .with_addr(listen_on).unwrap(); + .with_addr(listen_on).unwrap() + .with_num_threads(1); server.serve().unwrap(); Ok(()) -} } + }) +}