Skip to content

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

fix: Add HoneyPot rule

Amauryfb428ef42586
diff --git a/Cargo.lock b/Cargo.lock
index 0cddfadd..4c3f8631 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2427,7 +2427,7 @@ dependencies = [
[[package]]
name = "reacher_worker"
-version = "0.1.0"
+version = "1.0.0"
dependencies = [
"async-global-executor",
"async-smtp",
diff --git a/core/src/lib.rs b/core/src/lib.rs
index b920f5b5..571101e2 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -80,6 +80,8 @@ use trust_dns_proto::rr::rdata::MX;
pub use util::constants::LOG_TARGET;
pub use util::input_output::*;
+use crate::rules::{has_rule, Rule};
+
/// Given an email's misc and smtp details, calculate an estimate of our
/// confidence on how reachable the email is.
///
@@ -209,6 +211,14 @@ pub async fn check_email(input: &CheckEmailInput) -> CheckEmailOutput {
.as_ref()
.expect("If lookup is error, we already returned. qed.")
.iter()
+ // Don't try to connect to honey pot servers.
+ .filter(|a| {
+ !has_rule(
+ &my_syntax.domain,
+ &a.exchange().to_string(),
+ &Rule::HoneyPot,
+ )
+ })
.collect::<Vec<&MX>>();
mx_records.sort_by_key(|a| a.preference());
let host = if mx_records.len() >= 3 {
diff --git a/core/src/rules.json b/core/src/rules.json
index cdc6b2cb..bc7e9110 100644
--- a/core/src/rules.json
+++ b/core/src/rules.json
@@ -7,6 +7,9 @@
"yahoo.com": { "rules": ["SkipCatchAll"] },
"yahoo.fr": { "rules": ["SkipCatchAll"] }
},
+ "by_mx": {
+ "filter30.antispamcloud.com.": { "rules": ["HoneyPot"] }
+ },
"by_mx_suffix": {
".antispamcloud.com.": {
"rules": ["SmtpTimeout45s", "SkipCatchAll"],
diff --git a/core/src/rules.rs b/core/src/rules.rs
index 1067e4de..f578cdab 100644
--- a/core/src/rules.rs
+++ b/core/src/rules.rs
@@ -30,6 +30,8 @@ pub enum Rule {
SkipCatchAll,
/// Set the SMTP timeout to 45s.
SmtpTimeout45s,
+ /// Honey pot.
+ HoneyPot,
}
#[derive(Debug, Deserialize, Serialize)]
@@ -41,6 +43,8 @@ struct RulesByDomain {
struct AllRules {
/// Apply rules by domain name, i.e. after the @ symbol.
by_domain: HashMap<String, RulesByDomain>,
+ /// Apply rules by the MX host.
+ by_mx: HashMap<String, RulesByDomain>,
/// Apply rules by the MX host. Since each domain potentially has multiple
/// MX records, we match by their suffix.
by_mx_suffix: HashMap<String, RulesByDomain>,
@@ -58,6 +62,14 @@ fn does_domain_have_rule(domain: &str, rule: &Rule) -> bool {
}
fn does_mx_have_rule(host: &str, rule: &Rule) -> bool {
+ if let Some(v) = ALL_RULES.by_mx.get(host) {
+ return v.rules.contains(rule);
+ }
+
+ false
+}
+
+fn does_mx_suffix_have_rule(host: &str, rule: &Rule) -> bool {
for (k, v) in ALL_RULES.by_mx_suffix.iter() {
if host.ends_with(k) {
return v.rules.contains(rule);
@@ -69,5 +81,7 @@ fn does_mx_have_rule(host: &str, rule: &Rule) -> bool {
/// Check if either the domain or the MX host has any given rule.
pub fn has_rule(domain: &str, host: &str, rule: &Rule) -> bool {
- does_domain_have_rule(domain, rule) || does_mx_have_rule(host, rule)
+ does_domain_have_rule(domain, rule)
+ || does_mx_have_rule(host, rule)
+ || does_mx_suffix_have_rule(host, rule)
}
diff --git a/fly.toml b/fly.toml
new file mode 100644
index 00000000..78711f04
--- /dev/null
+++ b/fly.toml
@@ -0,0 +1,14 @@
+# fly.toml app configuration file generated for backend2-fly on 2023-12-06T19:00:32+01:00
+#
+# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
+#
+
+app = "backend2-fly"
+primary_region = "cdg"
+
+[[vm]]
+cpu_kind = "shared"
+cpus = 1
+memory_mb = 1024
+
+[[services]]
diff --git a/worker/Cargo.toml b/worker/Cargo.toml
index 0637bae5..e59c902e 100644
--- a/worker/Cargo.toml
+++ b/worker/Cargo.toml
@@ -1,13 +1,12 @@
[package]
name = "reacher_worker"
-version = "0.1.0"
+version = "1.0.0"
edition = "2018"
description = "RabbitMQ worker for Reacher"
authors = ["Amaury <[email protected]>"]
license = "AGPL-3.0"
publish = false
-
[dependencies]
async-smtp = "0.6"
async-global-executor = "2.4.0"