Overview
Comment: | Make buildable on older Rust versions, check that config file is only readable by owner |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | v0.3.4 |
Files: | files | file ages | folders |
SHA3-256: |
cfe321bd6f9bf28a8a0af7b90c2564c1 |
User & Date: | arcade on 2025-01-23 12:20:39.173 |
Other Links: | manifest | tags |
Context
2025-01-25
| ||
06:21 | fix markdown errors, message passing, errors produced check-in: 65b2967a92 user: arcade tags: trunk, v0.3.5 | |
2025-01-23
| ||
12:20 | Make buildable on older Rust versions, check that config file is only readable by owner check-in: cfe321bd6f user: arcade tags: trunk, v0.3.4 | |
2025-01-21
| ||
19:31 | add arg parsing check-in: e66352b9cc user: arcade tags: trunk, v0.3.4 | |
Changes
Modified Cargo.lock
from [732c2f949c]
to [77073657ea].
1 2 | # This file is automatically @generated by Cargo. # It is not intended for manual editing. | | | 1 2 3 4 5 6 7 8 9 10 | # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "addr2line" version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ |
︙ | ︙ | |||
508 509 510 511 512 513 514 | name = "equivalent" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "erasable" | | | | | 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 | name = "equivalent" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "erasable" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c18404d99ecdee16598948437ef1a18b94c74f4d3a374cd41f642626c2c57cd8" dependencies = [ "autocfg", "scopeguard", ] [[package]] name = "errno" version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", "windows-sys 0.52.0", ] [[package]] name = "event-listener" version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" |
︙ | ︙ | |||
765 766 767 768 769 770 771 | name = "hermit-abi" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" [[package]] name = "home" | | | | | 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 | name = "hermit-abi" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" [[package]] name = "home" version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "http" version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" |
︙ | ︙ | |||
1120 1121 1122 1123 1124 1125 1126 | [[package]] name = "libloading" version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" dependencies = [ "cfg-if", | | | 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 | [[package]] name = "libloading" version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" dependencies = [ "cfg-if", "windows-targets 0.48.5", ] [[package]] name = "linux-raw-sys" version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" |
︙ | ︙ | |||
1467 1468 1469 1470 1471 1472 1473 | checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] [[package]] name = "rc-box" | | | | 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 | checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] [[package]] name = "rc-box" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0690759eabf094030c2cdabc25ade1395bac02210d920d655053c1d49583fd8" dependencies = [ "erasable", ] [[package]] name = "regex" version = "1.11.1" |
︙ | ︙ | |||
1596 1597 1598 1599 1600 1601 1602 | source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6" dependencies = [ "bitflags 2.8.0", "errno", "libc", "linux-raw-sys", | | | 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 | source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6" dependencies = [ "bitflags 2.8.0", "errno", "libc", "linux-raw-sys", "windows-sys 0.52.0", ] [[package]] name = "rustls" version = "0.21.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" |
︙ | ︙ | |||
2035 2036 2037 2038 2039 2040 2041 | checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" dependencies = [ "cfg-if", "fastrand", "getrandom", "once_cell", "rustix", | | | 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 | checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" dependencies = [ "cfg-if", "fastrand", "getrandom", "once_cell", "rustix", "windows-sys 0.52.0", ] [[package]] name = "ternop" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d4ae32d0a4605a89c28534371b056919c12e7a070ee07505af75130ff030111" |
︙ | ︙ |
Modified src/main.rs
from [1f629cd869]
to [86c96bbf98].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | //! 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 anyhow::{ anyhow, bail, Result, }; use async_std::{ io::Error, task, }; use just_getopt::{ OptFlags, OptSpecs, OptValueType, | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | //! 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 anyhow::{ anyhow, bail, Result, }; use async_std::{ fs::metadata, io::Error, task, }; use just_getopt::{ OptFlags, OptSpecs, OptValueType, |
︙ | ︙ | |||
36 37 38 39 40 41 42 43 44 45 46 47 48 49 | use std::{ borrow::Cow, collections::{ HashMap, HashSet, }, path::Path, vec::Vec, }; /// `SomeHeaders` object to store data through SMTP session #[derive(Clone, Debug)] struct SomeHeaders { | > | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | use std::{ borrow::Cow, collections::{ HashMap, HashSet, }, os::unix::fs::PermissionsExt, path::Path, vec::Vec, }; /// `SomeHeaders` object to store data through SMTP session #[derive(Clone, Debug)] struct SomeHeaders { |
︙ | ︙ | |||
371 372 373 374 375 376 377 378 379 380 381 382 383 384 | } else { "smtp2tg.toml" }); if !config_file.exists() { eprintln!("Error: can't read configuration from {:?}", config_file); std::process::exit(1); }; let settings: config::Config = config::Config::builder() .set_default("fields", vec!["date", "from", "subject"]).unwrap() .set_default("hostname", "smtp.2.tg").unwrap() .set_default("listen_on", "0.0.0.0:1025").unwrap() .set_default("unknown", "relay").unwrap() .add_source(config::File::from(config_file)) .build() | > > > > > > > > > | 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | } else { "smtp2tg.toml" }); if !config_file.exists() { eprintln!("Error: can't read configuration from {:?}", config_file); std::process::exit(1); }; { let meta = metadata(config_file).await?; if (!0o100600 & meta.permissions().mode()) > 0 { eprintln!("Error: other users can read or write config file {:?}\n\ File permissions: {:o}", config_file, meta.permissions().mode()); std::process::exit(1); } } let settings: config::Config = config::Config::builder() .set_default("fields", vec!["date", "from", "subject"]).unwrap() .set_default("hostname", "smtp.2.tg").unwrap() .set_default("listen_on", "0.0.0.0:1025").unwrap() .set_default("unknown", "relay").unwrap() .add_source(config::File::from(config_file)) .build() |
︙ | ︙ |