Overview
| Comment: | revise how we minimize threads, more threads are spawned in mailin_embedded need to look on that side |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
bdac6388838350e9af437f456b3982c0 |
| User & Date: | arcade on 2026-11-01 07:14:54.988 |
| Other Links: | manifest | tags |
Context
|
2026-11-01
| ||
| 07:14 | revise how we minimize threads, more threads are spawned in mailin_embedded need to look on that side leaf check-in: bdac638883 user: arcade tags: trunk | |
|
2026-10-28
| ||
| 17:33 | case insensitive check and some tests check-in: e3cad77b2b user: arcade tags: trunk | |
Changes
Modified Cargo.lock
from [9df9e514d7]
to [0fcf516b6f].
| ︙ | ︙ | |||
1049 1050 1051 1052 1053 1054 1055 | dependencies = [ "getrandom 0.4.3", "libc", ] [[package]] name = "js-sys" | | | | 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 | dependencies = [ "getrandom 0.4.3", "libc", ] [[package]] name = "js-sys" version = "0.3.107" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8dc09d2154098bbf4ef54eab6b117a3c24cbbffe94046b16ee6d6d4510584d3a" dependencies = [ "cfg-if", "futures-util", "wasm-bindgen", ] [[package]] |
| ︙ | ︙ | |||
1084 1085 1086 1087 1088 1089 1090 | name = "litemap" version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" [[package]] name = "log" | | | | 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 | name = "litemap" version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" [[package]] name = "log" version = "0.4.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" [[package]] name = "lru-slab" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4050469837a6ff301cd14c1f8f24f88549e6d548f24f64e2148eb0f72cebc51f" |
| ︙ | ︙ | |||
1758 1759 1760 1761 1762 1763 1764 | name = "slab" version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" [[package]] name = "smallbox" | | | | 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 | name = "slab" version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" [[package]] name = "smallbox" version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8d91712aabb2e735436c02f70d990d8b2241f42dd092a973694e198ea95fc93" [[package]] name = "smallvec" version = "1.16.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0d5d4b1981b8bbbb7aed204cae5726d683d5d6ac7e74ec54122ea28f315e7c8" |
| ︙ | ︙ | |||
1785 1786 1787 1788 1789 1790 1791 1792 | "async-lock", "async-net", "async-process", "blocking", "futures-lite", ] [[package]] | < < < < < < < < < < < < < | < | 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 | "async-lock", "async-net", "async-process", "blocking", "futures-lite", ] [[package]] name = "smtp2tg" version = "0.6.10" dependencies = [ "async-compat", "clap", "config", "hostname", "html-escape", "mail-parser", "mailin-embedded", "regex", "smol", "stacked_errors", "tgbot", ] [[package]] name = "socket2" version = "0.6.5" |
| ︙ | ︙ | |||
2149 2150 2151 2152 2153 2154 2155 | "idna", "percent-encoding", "serde", ] [[package]] name = "utf8_iter" | | | > > > > > > > > > | 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 | "idna", "percent-encoding", "serde", ] [[package]] name = "utf8_iter" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" 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" dependencies = [ "same-file", |
| ︙ | ︙ | |||
2186 2187 2188 2189 2190 2191 2192 | name = "wasi" version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasm-bindgen" | | | < | | | | | | | | | | | 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 | name = "wasi" version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasm-bindgen" version = "0.2.130" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0181c14ddd6c7b8b0b0132a5f1ea2f32be0d893cd3ea97b6e3b28886b8a3d1c" dependencies = [ "cfg-if", "rustversion", "wasm-bindgen-macro", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" version = "0.4.80" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e14e0327cb5368ad60ccb22d04a9827a693c95a926d8d125e9fa39e0baec501" dependencies = [ "js-sys", "tokio", "wasm-bindgen", ] [[package]] name = "wasm-bindgen-macro" version = "0.2.130" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e931a02a39abdbf66966fc35902b5ed58344750a70885bed4ebb3d8eaf28ed9" dependencies = [ "quote", "wasm-bindgen-macro-support", ] [[package]] name = "wasm-bindgen-macro-support" version = "0.2.130" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ca4b54280e455bd831e33a6b8e734baf432fe63fbc35c42ac14ce67a043a53a" dependencies = [ "bumpalo", "proc-macro2", "quote", "syn 3.0.9", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" version = "0.2.130" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b1f9c3798725016c6ee5f2f57869ec0831e8bbc0ab0310a86e787e97f41389e" dependencies = [ "unicode-ident", ] [[package]] name = "wasm-streams" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d1ec4f6517c9e11ae630e200b2b65d193279042e28edd4a2cda233e46670bbb" dependencies = [ "futures-util", "js-sys", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", ] [[package]] name = "web-sys" version = "0.3.107" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7d179596ff5ec0f6de4db64d54011bde6289cc49603d3a6e4ce3f329207ab88" dependencies = [ "js-sys", "wasm-bindgen", ] [[package]] name = "web-time" |
| ︙ | ︙ |
Modified Cargo.toml
from [c93becb565]
to [95a34e7fde].
1 2 | [package] name = "smtp2tg" | | < | 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 |
[package]
name = "smtp2tg"
version = "0.6.10"
authors = [ "arcade@b1t.name" ]
edition = "2024"
license = "0BSD"
repository = "http://fs.b1t.name/smtp2tg"
[dependencies]
async-compat = "0.2.5"
config = { version = "0.15", default-features = false, features = [ "toml" ] }
hostname = "0.4.1"
html-escape = "0.3"
clap = { version = "4.6", features = [ "derive" ] }
mail-parser = "1"
mailin-embedded = "0.8"
regex = "1.11.1"
smol = "2.0.2"
stacked_errors = "0.8"
tgbot = "0.48"
# All tests are moved to tests/
[lib]
test = false
|
| ︙ | ︙ |
Modified README.md
from [3481cdb912]
to [56a240873d].
| ︙ | ︙ | |||
86 87 88 89 90 91 92 | ``` **Telegram message:** ```html <blockquote expandable> <u><i>Subject:</i></u> <code>Test</code> <u><i>From:</i></u> <code>user@example.com</code> | | | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | ``` **Telegram message:** ```html <blockquote expandable> <u><i>Subject:</i></u> <code>Test</code> <u><i>From:</i></u> <code>user@example.com</code> <u><i>Date:</i></u> <code>2024-01-01T12:00:00+00:00</code> </blockquote> <pre>Hello, world!</pre> ``` --- ## Links - **Original repository**: [http://fs.b1t.name/smtp2tg](http://fs.b1t.name/smtp2tg) |
| ︙ | ︙ |
Modified src/main.rs
from [44d6752f1f]
to [fcb6cd99e3].
1 2 3 4 | //! 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. | < < < < < | 1 2 3 4 5 6 7 8 9 10 11 |
//! 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 std::{
os::unix::fs::PermissionsExt,
path::Path,
};
use clap::Parser;
use smol::fs::metadata;
|
| ︙ | ︙ | |||
28 29 30 31 32 33 34 |
#[command(about = format!("SMTP-to-Telegram gateway v{}, (C) 2024 - 2026", env!("CARGO_PKG_VERSION")), long_about = None)]
struct Args {
/// Set configuration file location
#[arg(short, long, default_value = "smtp2tg.toml")]
config: String,
}
| < | > | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
#[command(about = format!("SMTP-to-Telegram gateway v{}, (C) 2024 - 2026", env!("CARGO_PKG_VERSION")), long_about = None)]
struct Args {
/// Set configuration file location
#[arg(short, long, default_value = "smtp2tg.toml")]
config: String,
}
/// 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.
///
/// # Errors
/// Returns an error if the configuration file is missing, inaccessible,
/// insecure, malformed, or contains invalid required settings.
/// 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.
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()? {
bail!("Configuration file not found: {config_file:?}\n\
Hint: Ensure the file exists and the path is correct.");
|
| ︙ | ︙ | |||
86 87 88 89 90 91 92 |
let server_name = settings.get_string("hostname").stack()?;
let core = MailServer::new(settings)?;
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()
| | > | > | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
let server_name = settings.get_string("hostname").stack()?;
let core = MailServer::new(settings)?;
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_num_threads(1);
server.serve().unwrap();
Ok(())
})
}
|