Skip to content

Commit

Permalink
api!: remove hostname dependency
Browse files Browse the repository at this point in the history
This change removes `ClientId::hostname()`.
If someone wants to send the hostname,
they have to configure it manually.

For clients default value "[127.0.0.1]"
is a better default as it does
not leak local hostname
and it works successfully
both in Delta Chat and TorBirdy for years.
  • Loading branch information
link2xt committed Dec 3, 2024
1 parent 3e87374 commit 9f70067
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 39 deletions.
20 changes: 1 addition & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ anyhow = "1"
async-std = { version = "1.11", features = ["unstable"], optional = true }
base64 = "^0.13"
futures = "0.3.21"
hostname = "0.3.1"
log = "^0.4"
nom = "^7.0"
thiserror = "1"
Expand Down
19 changes: 0 additions & 19 deletions src/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,11 @@ use crate::authentication::Mechanism;
use crate::error::Error;
use crate::response::Response;
use crate::util::XText;
use hostname;
use std::collections::HashSet;
use std::fmt::{self, Display, Formatter};
use std::net::{Ipv4Addr, Ipv6Addr};
use std::result::Result;

/// Default client id.
///
/// It passes
/// `smtpd_helo_restrictions = reject_non_fqdn_helo_hostname`
/// Postfix check, but not `reject_unknown_helo_hostname`.
const DEFAULT_DOMAIN_CLIENT_ID: &str = "localhost.localdomain";

/// Client identifier, the parameter to `EHLO`
#[derive(PartialEq, Eq, Clone, Debug)]
pub enum ClientId {
Expand Down Expand Up @@ -57,17 +49,6 @@ impl ClientId {
pub fn new(domain: String) -> ClientId {
ClientId::Domain(domain)
}

/// Defines a `ClientId` with the current hostname, or
/// `localhost.localdomain` if hostname could not be found.
pub fn hostname() -> ClientId {
ClientId::Domain(
hostname::get()
.ok()
.and_then(|s| s.into_string().ok())
.unwrap_or_else(|| DEFAULT_DOMAIN_CLIENT_ID.to_string()),
)
}
}

/// Supported ESMTP keywords
Expand Down

0 comments on commit 9f70067

Please sign in to comment.