Skip to content

Check if an email address exists without sending any email, written in Rust. Comes with a ⚙️ HTTP backend.

fix: Show thread ID in logs (#1579)

Amaury3388163d03b6
diff --git a/Cargo.lock b/Cargo.lock
index 91bcdd1d..43318f47 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -601,7 +601,7 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
[[package]]
name = "check-if-email-exists"
-version = "0.11.0"
+version = "0.11.2"
dependencies = [
"anyhow",
"async-recursion",
@@ -633,7 +633,7 @@ dependencies = [
[[package]]
name = "check-if-email-exists-cli"
-version = "0.11.0"
+version = "0.11.2"
dependencies = [
"anyhow",
"check-if-email-exists",
@@ -3062,7 +3062,7 @@ dependencies = [
[[package]]
name = "reacher_backend"
-version = "0.11.0"
+version = "0.11.2"
dependencies = [
"anyhow",
"async-smtp",
@@ -3095,7 +3095,7 @@ dependencies = [
[[package]]
name = "reacher_sqs"
-version = "0.11.0"
+version = "0.11.2"
dependencies = [
"check-if-email-exists",
"lambda_runtime",
diff --git a/backend/Cargo.toml b/backend/Cargo.toml
index d6460846..0c8aa5c1 100644
--- a/backend/Cargo.toml
+++ b/backend/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "reacher_backend"
-version = "0.11.0"
+version = "0.11.2"
edition = "2018"
license = "AGPL-3.0"
publish = false
diff --git a/cli/Cargo.toml b/cli/Cargo.toml
index 03695314..1a12afcf 100644
--- a/cli/Cargo.toml
+++ b/cli/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "check-if-email-exists-cli"
-version = "0.11.0"
+version = "0.11.2"
default-run = "check_if_email_exists"
edition = "2018"
description = "Check if an email address exists without sending any email."
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 8a30a050..f3607242 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "check-if-email-exists"
-version = "0.11.0"
+version = "0.11.2"
authors = ["Amaury <[email protected]>"]
categories = ["email"]
description = "Check if an email address exists without sending any email"
diff --git a/core/src/haveibeenpwned.rs b/core/src/haveibeenpwned.rs
index 27fffe8a..c8e4c834 100644
--- a/core/src/haveibeenpwned.rs
+++ b/core/src/haveibeenpwned.rs
@@ -43,6 +43,7 @@ pub async fn check_haveibeenpwned(to_email: &str, api_key: Option<String>) -> Op
let breaches: Vec<serde_json::Value> = response.json().await.unwrap_or_default();
tracing::debug!(
target: LOG_TARGET,
+ thread_id=?tokio::task::id(),
breach_count=breaches.len(),
"HaveIBeenPwned check completed"
);
diff --git a/core/src/lib.rs b/core/src/lib.rs
index 2093758f..afb7b51d 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -149,6 +149,7 @@ pub async fn check_email(input: &CheckEmailInput) -> CheckEmailOutput {
tracing::debug!(
target: LOG_TARGET,
+ thread_id=?tokio::task::id(),
email=%to_email,
"Checking email"
);
@@ -164,6 +165,7 @@ pub async fn check_email(input: &CheckEmailInput) -> CheckEmailOutput {
tracing::debug!(
target: LOG_TARGET,
+ thread_id=?tokio::task::id(),
email=%to_email,
syntax=?my_syntax,
"Found syntax validation"
@@ -209,6 +211,7 @@ pub async fn check_email(input: &CheckEmailInput) -> CheckEmailOutput {
tracing::debug!(
target: LOG_TARGET,
+ thread_id=?tokio::task::id(),
email=%to_email,
mx_hosts=?mx_hosts,
"Found MX hosts"
@@ -223,6 +226,7 @@ pub async fn check_email(input: &CheckEmailInput) -> CheckEmailOutput {
tracing::debug!(
target: LOG_TARGET,
+ thread_id=?tokio::task::id(),
email=%to_email,
misc=?my_misc,
"Found misc details"
diff --git a/core/src/misc/gravatar.rs b/core/src/misc/gravatar.rs
index eca5b2f5..fb658ea5 100644
--- a/core/src/misc/gravatar.rs
+++ b/core/src/misc/gravatar.rs
@@ -28,6 +28,7 @@ pub async fn check_gravatar(to_email: &str) -> Option<String> {
tracing::debug!(
target: LOG_TARGET,
+ thread_id=?tokio::task::id(),
email=to_email,
url=url,
"Request Gravatar API"
@@ -43,6 +44,7 @@ pub async fn check_gravatar(to_email: &str) -> Option<String> {
tracing::debug!(
target: LOG_TARGET,
+ thread_id=?tokio::task::id(),
"[email={}] Gravatar response: {:?}",
to_email,
response
diff --git a/core/src/smtp/connect.rs b/core/src/smtp/connect.rs
index 38138a60..8dcd0da1 100644
--- a/core/src/smtp/connect.rs
+++ b/core/src/smtp/connect.rs
@@ -43,6 +43,7 @@ macro_rules! try_smtp (
if let Err(err) = $res {
tracing::debug!(
target: LOG_TARGET,
+ thread_id=?tokio::task::id(),
email=$to_email.to_string(),
mx_host=$host,
port=$port,
@@ -227,6 +228,7 @@ async fn smtp_is_catch_all<S: AsyncBufRead + AsyncWrite + Unpin + Send>(
if has_rule(domain, host, &Rule::SkipCatchAll) {
tracing::debug!(
target: LOG_TARGET,
+ thread_id=?tokio::task::id(),
email=to_email.to_string(),
domain=domain,
"Skipping catch-all check"
@@ -280,6 +282,7 @@ async fn create_smtp_future(
if parser::is_err_io_errors(e) {
tracing::debug!(
target: LOG_TARGET,
+ thread_id=?tokio::task::id(),
email=to_email.to_string(),
error=?e,
"Got `io: incomplete` error, reconnecting"
@@ -346,6 +349,7 @@ pub async fn check_smtp_with_retry(
) -> Result<SmtpDetails, SmtpError> {
tracing::debug!(
target: LOG_TARGET,
+ thread_id=?tokio::task::id(),
email=to_email.to_string(),
attempt=verif_method.config.retries - count + 1,
mx_host=mx_host,
@@ -358,6 +362,7 @@ pub async fn check_smtp_with_retry(
tracing::debug!(
target: LOG_TARGET,
+ thread_id=?tokio::task::id(),
email=to_email.to_string(),
attempt=verif_method.config.retries - count + 1,
mx_host=mx_host,
@@ -380,6 +385,7 @@ pub async fn check_smtp_with_retry(
} else {
tracing::debug!(
target: LOG_TARGET,
+ thread_id=?tokio::task::id(),
email=to_email.to_string(),
"Potential greylisting detected, retrying"
);
diff --git a/core/src/smtp/gmail.rs b/core/src/smtp/gmail.rs
index 7ba556a9..7e6aa1fb 100644
--- a/core/src/smtp/gmail.rs
+++ b/core/src/smtp/gmail.rs
@@ -63,6 +63,7 @@ pub async fn check_gmail_via_api(
tracing::debug!(
target: LOG_TARGET,
+ thread_id=?tokio::task::id(),
email = %to_email,
response = ?response,
"Gmail API response"
diff --git a/core/src/smtp/outlook/headless.rs b/core/src/smtp/outlook/headless.rs
index 1a094bea..1e835ecc 100644
--- a/core/src/smtp/outlook/headless.rs
+++ b/core/src/smtp/outlook/headless.rs
@@ -39,6 +39,7 @@ pub async fn check_password_recovery(
let to_email = to_email.to_string();
tracing::debug!(
target: LOG_TARGET,
+ thread_id=?tokio::task::id(),
email=to_email,
"Using Hotmail password recovery in headless navigator"
);
@@ -94,6 +95,7 @@ pub async fn check_password_recovery(
if is_deliverable {
tracing::debug!(
target: LOG_TARGET,
+ thread_id=?tokio::task::id(),
email=to_email,
exists=is_deliverable,
"Did not find error message in password recovery, email exists"
@@ -101,6 +103,7 @@ pub async fn check_password_recovery(
} else {
tracing::debug!(
target: LOG_TARGET,
+ thread_id=?tokio::task::id(),
email=to_email,
exists=is_deliverable,
"Found error message in password recovery, email does not exist"
@@ -111,6 +114,7 @@ pub async fn check_password_recovery(
tracing::debug!(
target: LOG_TARGET,
+ thread_id=?tokio::task::id(),
email=to_email,
exists=is_deliverable,
"Password recovery check result"
diff --git a/core/src/smtp/outlook/microsoft365.rs b/core/src/smtp/outlook/microsoft365.rs
index 321ff38d..a8826f4f 100644
--- a/core/src/smtp/outlook/microsoft365.rs
+++ b/core/src/smtp/outlook/microsoft365.rs
@@ -79,6 +79,7 @@ pub async fn check_microsoft365_api(
tracing::debug!(
target: LOG_TARGET,
+ thread_id=?tokio::task::id(),
email = %to_email,
response = ?response,
"microsoft365 response"
diff --git a/core/src/smtp/yahoo/api.rs b/core/src/smtp/yahoo/api.rs
index a4d64a15..35729c4c 100644
--- a/core/src/smtp/yahoo/api.rs
+++ b/core/src/smtp/yahoo/api.rs
@@ -93,6 +93,7 @@ pub async fn check_api(to_email: &str, input: &CheckEmailInput) -> Result<SmtpDe
tracing::debug!(
target: LOG_TARGET,
+ thread_id=?tokio::task::id(),
email=to_email,
"Yahoo succesfully got cookies after response"
);
@@ -156,6 +157,7 @@ pub async fn check_api(to_email: &str, input: &CheckEmailInput) -> Result<SmtpDe
tracing::debug!(
target: LOG_TARGET,
+ thread_id=?tokio::task::id(),
email=to_email,
"Yahoo 2nd response: {:?}",
res
diff --git a/core/src/smtp/yahoo/headless.rs b/core/src/smtp/yahoo/headless.rs
index 784a5d5d..c7501be0 100644
--- a/core/src/smtp/yahoo/headless.rs
+++ b/core/src/smtp/yahoo/headless.rs
@@ -44,6 +44,7 @@ pub async fn check_headless(
attempts += 1;
tracing::debug!(
target: LOG_TARGET,
+ thread_id=?tokio::task::id(),
email=%to_email,
attempt=%attempts,
"Using Yahoo password recovery in headless navigator"
diff --git a/core/src/util/sentry.rs b/core/src/util/sentry.rs
index 2314e5f6..4864cb68 100644
--- a/core/src/util/sentry.rs
+++ b/core/src/util/sentry.rs
@@ -37,7 +37,11 @@ pub fn setup_sentry(sentry_dsn: &str) -> sentry::ClientInitGuard {
// will just silently ignore.
let sentry = sentry::init(sentry_dsn);
if sentry.is_enabled() {
- info!(target: LOG_TARGET, "Sentry is successfully set up.")
+ info!(
+ target: LOG_TARGET,
+ thread_id=?tokio::task::id(),
+ "Sentry is successfully set up."
+ );
}
sentry
@@ -68,7 +72,12 @@ impl<'a> SentryError<'a> {
/// info before sending to Sentry, by removing all instances of `username`.
fn error(err: SentryError, result: &CheckEmailOutput, backend_name: &str) {
let exception_value = redact(format!("{err:?}").as_str(), &result.syntax.username);
- debug!(target: LOG_TARGET, "Sending error to Sentry: {}", exception_value);
+ debug!(
+ target: LOG_TARGET,
+ thread_id=?tokio::task::id(),
+ "Sending error to Sentry: {}",
+ exception_value,
+ );
let exception = Exception {
ty: err.get_exception_type(),
diff --git a/sqs/Cargo.toml b/sqs/Cargo.toml
index edbee997..6dcecaa3 100644
--- a/sqs/Cargo.toml
+++ b/sqs/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "reacher_sqs"
-version = "0.11.0"
+version = "0.11.2"
edition = "2018"
license = "AGPL-3.0"
publish = false