Skip to content

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

feat: Add reacher_version to JSON output, bump to v0.11.10 (#1667)

Amaury0b11b6f39271
diff --git a/Cargo.lock b/Cargo.lock
index 0aa9b484..1efd3d43 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -577,7 +577,7 @@ dependencies = [
[[package]]
name = "check-if-email-exists"
-version = "0.11.9"
+version = "0.11.10"
dependencies = [
"anyhow",
"async-recursion",
@@ -609,7 +609,7 @@ dependencies = [
[[package]]
name = "check-if-email-exists-cli"
-version = "0.11.9"
+version = "0.11.10"
dependencies = [
"anyhow",
"check-if-email-exists",
@@ -3058,7 +3058,7 @@ dependencies = [
[[package]]
name = "reacher_backend"
-version = "0.11.9"
+version = "0.11.10"
dependencies = [
"anyhow",
"async-smtp",
@@ -3091,7 +3091,7 @@ dependencies = [
[[package]]
name = "reacher_sqs"
-version = "0.11.9"
+version = "0.11.10"
dependencies = [
"check-if-email-exists",
"lambda_runtime",
diff --git a/backend/Cargo.toml b/backend/Cargo.toml
index 40181663..0413bd68 100644
--- a/backend/Cargo.toml
+++ b/backend/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "reacher_backend"
-version = "0.11.9"
+version = "0.11.10"
edition = "2018"
license = "MIT"
publish = false
diff --git a/backend/openapi.json b/backend/openapi.json
index 79a774a1..0f16fe2a 100644
--- a/backend/openapi.json
+++ b/backend/openapi.json
@@ -716,6 +716,10 @@
},
"description": "The name of the server that performed the verification."
},
+ "reacher_version": {
+ "type": "string",
+ "description": "The version of Reacher that performed the verification, e.g. \"0.11.10\"."
+ },
"smtp": {
"$ref": "#/components/schemas/DebugDetailsSmtp"
}
diff --git a/cli/Cargo.toml b/cli/Cargo.toml
index cceb2eb8..2b803b49 100644
--- a/cli/Cargo.toml
+++ b/cli/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "check-if-email-exists-cli"
-version = "0.11.9"
+version = "0.11.10"
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 8ce74df3..aee0198b 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "check-if-email-exists"
-version = "0.11.9"
+version = "0.11.10"
authors = ["Amaury <[email protected]>"]
categories = ["email"]
description = "Check if an email address exists without sending any email"
diff --git a/core/src/lib.rs b/core/src/lib.rs
index d5a65a6f..62aee4cb 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -86,6 +86,9 @@ pub use util::sentry::*;
/// The target where to log check-if-email-exists logs.
pub const LOG_TARGET: &str = "reacher";
+/// The version of Reacher, as defined in Cargo.toml.
+pub const CARGO_PKG_VERSION: &str = env!("CARGO_PKG_VERSION");
+
static INIT: Once = Once::new();
/// check-if-email-exists uses rustls for its TLS connections. This function
@@ -255,6 +258,7 @@ pub async fn check_email(input: &CheckEmailInput) -> CheckEmailOutput {
.unwrap_or(Duration::from_secs(0)),
smtp: smtp_debug,
backend_name: input.backend_name.clone(),
+ reacher_version: CARGO_PKG_VERSION.into(),
},
};
diff --git a/core/src/util/input_output.rs b/core/src/util/input_output.rs
index ae345d76..1a367e8d 100644
--- a/core/src/util/input_output.rs
+++ b/core/src/util/input_output.rs
@@ -171,6 +171,9 @@ pub enum Reachable {
pub struct DebugDetails {
/// Identifier for the service currently running Reacher.
pub backend_name: String,
+ /// Version of Reacher that performed the verification.
+ #[serde(default)]
+ pub reacher_version: String,
/// The time when the email verification started.
pub start_time: DateTime<Utc>,
/// The time when the email verification ended.
@@ -189,6 +192,7 @@ impl Default for DebugDetails {
duration: Duration::default(),
smtp: SmtpDebug::default(),
backend_name: "backend-dev".into(),
+ reacher_version: crate::CARGO_PKG_VERSION.into(),
}
}
}
@@ -334,4 +338,18 @@ mod tests {
let expected = r#""smtp":{"error":{"type":"AsyncSmtpError","message":"transient: foobar; 8BITMIME; SIZE 42"}}"#;
assert!(actual.contains(expected));
}
+
+ #[test]
+ fn should_serialize_reacher_version() {
+ let actual = serde_json::to_value(DebugDetails::default()).unwrap();
+ assert_eq!(actual["reacher_version"], crate::CARGO_PKG_VERSION);
+ }
+
+ #[test]
+ fn should_deserialize_without_reacher_version() {
+ let mut value = serde_json::to_value(DebugDetails::default()).unwrap();
+ value.as_object_mut().unwrap().remove("reacher_version");
+ let debug: DebugDetails = serde_json::from_value(value).unwrap();
+ assert_eq!(debug.reacher_version, "");
+ }
}
diff --git a/core/src/util/sentry.rs b/core/src/util/sentry.rs
index c14bdee6..c2fedb24 100644
--- a/core/src/util/sentry.rs
+++ b/core/src/util/sentry.rs
@@ -7,14 +7,12 @@
use crate::misc::MiscError;
use crate::mx::MxError;
use crate::LOG_TARGET;
-use crate::{smtp::SmtpError, CheckEmailOutput};
+use crate::{smtp::SmtpError, CheckEmailOutput, CARGO_PKG_VERSION};
use async_smtp::error::Error as AsyncSmtpError;
use sentry::protocol::{Event, Exception, Level, Values};
use thiserror::Error;
use tracing::{debug, info};
-const CARGO_PKG_VERSION: &str = env!("CARGO_PKG_VERSION");
-
/// Setup Sentry.
pub fn setup_sentry(sentry_dsn: &str) -> sentry::ClientInitGuard {
// Use an empty string if we don't have any env variable for sentry. Sentry
diff --git a/sqs/Cargo.toml b/sqs/Cargo.toml
index 0e618595..2699648d 100644
--- a/sqs/Cargo.toml
+++ b/sqs/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "reacher_sqs"
-version = "0.11.9"
+version = "0.11.10"
edition = "2018"
license = "MIT"
publish = false