Skip to content

Commit

Permalink
2024 update
Browse files Browse the repository at this point in the history
  • Loading branch information
MTRNord committed Aug 22, 2024
1 parent 4602fce commit 37c90b8
Show file tree
Hide file tree
Showing 12 changed files with 911 additions and 847 deletions.
1,679 changes: 878 additions & 801 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions crates/erooster/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
//! while being also fast and efficient.
//!
#![feature(string_remove_matches)]
#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
#![deny(unsafe_code, clippy::unwrap_used)]
#![warn(
clippy::cognitive_complexity,
Expand Down Expand Up @@ -167,7 +166,7 @@ async fn main() -> Result<()> {
shutdown_flag_clone,
receiver,
)
.await?;
.await?;

tokio::select! {
_ = tokio::signal::ctrl_c() => {
Expand Down
1 change: 0 additions & 1 deletion crates/erooster_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//! Core logic for the erooster mail server
//!
#![feature(string_remove_matches)]
#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
#![deny(unsafe_code, clippy::unwrap_used)]
#![warn(
clippy::cognitive_complexity,
Expand Down
4 changes: 2 additions & 2 deletions crates/erooster_core/src/panic_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct EroosterPanicMessage;
const VERSION: &str = env!("CARGO_PKG_VERSION");

impl PanicMessage for EroosterPanicMessage {
fn display(&self, pi: &std::panic::PanicInfo<'_>, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fn display(&self, pi: &std::panic::PanicHookInfo<'_>, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "{}", "The application panicked (crashed).".red())?;

// Print panic message.
Expand Down Expand Up @@ -78,7 +78,7 @@ fn custom_url(location: &Location<'_>, message: &str) -> impl fmt::Display {
message,
location,
)
.as_str(),
.as_str(),
),
],
);
Expand Down
2 changes: 0 additions & 2 deletions crates/erooster_deps/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
//
// SPDX-License-Identifier: Apache-2.0

#![cfg_attr(coverage_nightly, feature(coverage_attribute))]

pub use futures;
pub use tokio;
pub use tokio_rustls;
Expand Down
1 change: 1 addition & 0 deletions crates/erooster_imap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ bench = false
erooster_core = { version = "0.1.0", path = "../erooster_core" }
erooster_deps = { version = "0.1.0", path = "../erooster_deps" }
time = { version = "0.3.30", features = ["parsing", "macros"] }
tracing = "0.1.40"

[features]
default = []
Expand Down
3 changes: 1 addition & 2 deletions crates/erooster_imap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//!
#![feature(string_remove_matches)]
#![feature(box_into_inner)]
#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
#![deny(unsafe_code, clippy::unwrap_used)]
#![warn(
clippy::cognitive_complexity,
Expand Down Expand Up @@ -54,7 +53,7 @@ use erooster_deps::{
color_eyre,
const_format::formatcp,
tokio,
tracing::{self, instrument},
tracing::instrument,
};

pub(crate) mod commands;
Expand Down
46 changes: 23 additions & 23 deletions crates/erooster_smtp/src/commands/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl DataCommand<'_> {
pub async fn exec<S, E>(&mut self, lines: &mut S) -> color_eyre::eyre::Result<()>
where
E: std::error::Error + std::marker::Sync + std::marker::Send + 'static,
S: Sink<String, Error = E> + std::marker::Unpin + std::marker::Send,
S: Sink<String, Error=E> + std::marker::Unpin + std::marker::Send,
{
debug!("Waiting for incoming data");
{
Expand All @@ -62,7 +62,7 @@ impl DataCommand<'_> {
) -> color_eyre::eyre::Result<()>
where
E: std::error::Error + std::marker::Sync + std::marker::Send + 'static,
S: Sink<String, Error = E> + std::marker::Unpin + std::marker::Send,
S: Sink<String, Error=E> + std::marker::Unpin + std::marker::Send,
{
debug!("Reading incoming data");

Expand All @@ -89,15 +89,15 @@ impl DataCommand<'_> {
.or_default()
.push(address.clone());
let received_header = format!(
"Received: from {} ({} [{}])\r\n by {} (Erooster) with ESMTPS\r\n id 00000001\r\n (envelope-from <{}>)\r\n for <{}>; {}\r\n",
self.data.con_state.ehlo.as_ref().context("Missing ehlo")?,
self.data.con_state.ehlo.as_ref().context("Missing ehlo")?,
self.data.con_state.peer_addr,
config.mail.hostname,
self.data.con_state.sender.as_ref().context("Missing sender")?,
address,
OffsetDateTime::now_utc().format(&date_format)?
);
"Received: from {} ({} [{}])\r\n by {} (Erooster) with ESMTPS\r\n id 00000001\r\n (envelope-from <{}>)\r\n for <{}>; {}\r\n",
self.data.con_state.ehlo.as_ref().context("Missing ehlo")?,
self.data.con_state.ehlo.as_ref().context("Missing ehlo")?,
self.data.con_state.peer_addr,
config.mail.hostname,
self.data.con_state.sender.as_ref().context("Missing sender")?,
address,
OffsetDateTime::now_utc().format(&date_format)?
);
let temp_data = [received_header.as_bytes(), &inner_data.0].concat();
let data = from_utf8(&temp_data)?;

Expand All @@ -115,7 +115,7 @@ impl DataCommand<'_> {
address,
Some(username.to_string()),
)
.await?
.await?
} else {
data
};
Expand Down Expand Up @@ -154,21 +154,21 @@ impl DataCommand<'_> {
let mailbox_path = Path::new(&config.mail.maildir_folders)
.join(receipt.clone())
.join(folder.clone());
let db_foldername = format!("{}/{}", receipt, folder,);
let db_foldername = format!("{}/{}", receipt, folder, );
if !mailbox_path.exists() {
storage.create_dirs(&mailbox_path)?;
storage.add_flag(&mailbox_path, "\\Subscribed").await?;
storage.add_flag(&mailbox_path, "\\NoInferiors").await?;
}
let received_header = format!(
"Received: from {} ({} [{}])\r\n by {} (Erooster) with ESMTPS\r\n id 00000001\r\n for <{}>; {}\r\n",
self.data.con_state.ehlo.as_ref().context("Missing ehlo")?,
self.data.con_state.ehlo.as_ref().context("Missing ehlo")?,
self.data.con_state.peer_addr,
config.mail.hostname,
receipt,
OffsetDateTime::now_utc().format(&date_format)?,
);
"Received: from {} ({} [{}])\r\n by {} (Erooster) with ESMTPS\r\n id 00000001\r\n for <{}>; {}\r\n",
self.data.con_state.ehlo.as_ref().context("Missing ehlo")?,
self.data.con_state.ehlo.as_ref().context("Missing ehlo")?,
self.data.con_state.peer_addr,
config.mail.hostname,
receipt,
OffsetDateTime::now_utc().format(&date_format)?,
);
let temp_data = [received_header.as_bytes(), &data.0].concat();
let data = from_utf8(&temp_data)?;

Expand All @@ -186,7 +186,7 @@ impl DataCommand<'_> {
receipt,
None,
)
.await?
.await?
} else {
data
};
Expand Down Expand Up @@ -307,7 +307,7 @@ impl DataCommand<'_> {
username: Option<String>,
) -> color_eyre::Result<&'a str> {
let client = reqwest::Client::builder()
.trust_dns(true)
.hickory_dns(true)
.timeout(Duration::from_secs(30))
.user_agent("Erooster")
.build()?;
Expand Down
1 change: 0 additions & 1 deletion crates/erooster_smtp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
//! This crate is containing the smtp logic of the erooster mail server.
//!
#![feature(string_remove_matches)]
#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
#![deny(unsafe_code, clippy::unwrap_used)]
#![warn(
clippy::branches_sharing_code,
Expand Down
3 changes: 1 addition & 2 deletions crates/erooster_web/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//! Core logic for the webserver for the erooster mail server
//!
#![feature(string_remove_matches)]
#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
#![deny(unsafe_code, clippy::unwrap_used)]
#![warn(
clippy::cognitive_complexity,
Expand Down Expand Up @@ -91,7 +90,7 @@ pub async fn start(config: &Config) -> color_eyre::eyre::Result<()> {
config.tls.cert_path.clone(),
config.tls.key_path.clone(),
)
.await
.await
{
Ok(tls_config) => tls_config,
Err(e) => {
Expand Down
9 changes: 4 additions & 5 deletions crates/eroosterctl/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
//! while being also fast and efficient.
//!
#![feature(string_remove_matches)]
#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
#![deny(unsafe_code, clippy::unwrap_used)]
#![warn(
clippy::cognitive_complexity,
Expand Down Expand Up @@ -155,7 +154,7 @@ fn status() {
HEAD, FINS, HEAD, EYES, HEAD, EYES, HEAD, BEAK, HEAD, FEATHER, BODY, LINE, CLAWS, LINE,
CLAWS, LINE, CLAWS,
]
.map(|color| color.parse().unwrap());
.map(|color| color.parse().unwrap());

let mut current_color_index = 0;
let mut out = String::new();
Expand Down Expand Up @@ -240,7 +239,7 @@ async fn register(username: Option<String>, password: Option<SecretString>, conf
rpassword::prompt_password(
"Please enter the email password of the new user: ".fg::<BrightCyan>(),
)
.expect("Couldn't read line"),
.expect("Couldn't read line"),
);

let pb = ProgressBar::new_spinner();
Expand Down Expand Up @@ -344,7 +343,7 @@ async fn change_password(
rpassword::prompt_password(
"Please enter the current password of the user: ".fg::<BrightCyan>(),
)
.expect("Couldn't read line"),
.expect("Couldn't read line"),
);

// TODO repromt as needed
Expand All @@ -360,7 +359,7 @@ async fn change_password(
rpassword::prompt_password(
"Please enter the new password of the user: ".fg::<BrightCyan>(),
)
.expect("Couldn't read line"),
.expect("Couldn't read line"),
);

let pb = ProgressBar::new_spinner();
Expand Down
6 changes: 0 additions & 6 deletions rust-toolchain.toml

This file was deleted.

0 comments on commit 37c90b8

Please sign in to comment.