Skip to content

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

refactor: Use fantoccini instead of headless chrome (#1168)

Amaury3883823bcbdd
diff --git a/.env.example b/.env.example
index 9b7cd098..1b028ff8 100644
--- a/.env.example
+++ b/.env.example
@@ -7,7 +7,7 @@
RUST_LOG=reacher=info
SQLX_OFFLINE=1
-RCH_HOTMAIL_USE_HEADLESS=1
+RCH_HOTMAIL_USE_HEADLESS=http://localhost:4444
# To enable bulk email verification, set the value below to 1, and fill out all
# other env variables below.
diff --git a/Cargo.lock b/Cargo.lock
index 6727cf45..a9bda2ae 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -23,9 +23,9 @@ version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
dependencies = [
- "getrandom 0.2.7",
+ "getrandom",
"once_cell",
- "version_check 0.9.4",
+ "version_check",
]
[[package]]
@@ -114,7 +114,7 @@ dependencies = [
"concurrent-queue",
"futures-lite",
"libc",
- "log 0.4.17",
+ "log",
"once_cell",
"parking",
"polling",
@@ -142,7 +142,7 @@ dependencies = [
"native-tls",
"thiserror",
"tokio",
- "url 2.2.2",
+ "url",
]
[[package]]
@@ -181,12 +181,12 @@ checksum = "6da21e1dd19fbad3e095ad519fb1558ab77fd82e5c4778dca8f9be0464589e1e"
dependencies = [
"async-native-tls",
"async-trait",
- "base64 0.13.0",
+ "base64",
"bufstream",
"fast-socks5",
"futures",
"hostname",
- "log 0.4.17",
+ "log",
"nom",
"pin-project",
"pin-utils",
@@ -215,7 +215,7 @@ dependencies = [
"futures-lite",
"gloo-timers",
"kv-log-macro",
- "log 0.4.17",
+ "log",
"memchr",
"once_cell",
"pin-project-lite",
@@ -282,29 +282,6 @@ dependencies = [
"winapi",
]
-[[package]]
-name = "auto_generate_cdp"
-version = "0.3.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3c784e363772b68d4a52cd18ac3aa6bb1c268421f0916be916461c965f269c09"
-dependencies = [
- "convert_case",
- "proc-macro2",
- "quote",
- "reqwest",
- "serde",
- "serde_json",
-]
-
-[[package]]
-name = "autocfg"
-version = "0.1.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78"
-dependencies = [
- "autocfg 1.1.0",
-]
-
[[package]]
name = "autocfg"
version = "1.1.0"
@@ -326,25 +303,6 @@ dependencies = [
"rustc-demangle",
]
-[[package]]
-name = "base64"
-version = "0.9.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643"
-dependencies = [
- "byteorder",
- "safemem",
-]
-
-[[package]]
-name = "base64"
-version = "0.10.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e"
-dependencies = [
- "byteorder",
-]
-
[[package]]
name = "base64"
version = "0.13.0"
@@ -457,17 +415,17 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
name = "check-if-email-exists"
version = "0.9.1"
dependencies = [
- "anyhow",
"async-native-tls",
"async-recursion",
"async-smtp",
"async-std",
"async-std-resolver",
+ "fantoccini",
"fast-socks5",
- "headless_chrome",
- "log 0.4.17",
+ "futures",
+ "log",
"mailchecker",
- "rand 0.8.5",
+ "rand",
"regex",
"reqwest",
"serde",
@@ -501,7 +459,7 @@ dependencies = [
"num-integer",
"num-traits",
"serde",
- "time",
+ "time 0.1.44",
"wasm-bindgen",
"winapi",
]
@@ -518,7 +476,7 @@ dependencies = [
"clap_lex",
"indexmap",
"once_cell",
- "strsim 0.10.0",
+ "strsim",
"termcolor",
"textwrap",
]
@@ -545,15 +503,6 @@ dependencies = [
"os_str_bytes",
]
-[[package]]
-name = "cloudabi"
-version = "0.0.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
-dependencies = [
- "bitflags",
-]
-
[[package]]
name = "concurrent-queue"
version = "1.2.4"
@@ -564,10 +513,15 @@ dependencies = [
]
[[package]]
-name = "convert_case"
-version = "0.4.0"
+name = "cookie"
+version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
+checksum = "94d4706de1b0fa5b132270cddffa8585166037822e260a944fe161acd137ca05"
+dependencies = [
+ "percent-encoding",
+ "time 0.3.14",
+ "version_check",
+]
[[package]]
name = "core-foundation"
@@ -671,41 +625,6 @@ dependencies = [
"syn",
]
-[[package]]
-name = "darling"
-version = "0.10.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858"
-dependencies = [
- "darling_core",
- "darling_macro",
-]
-
-[[package]]
-name = "darling_core"
-version = "0.10.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b"
-dependencies = [
- "fnv",
- "ident_case",
- "proc-macro2",
- "quote",
- "strsim 0.9.3",
- "syn",
-]
-
-[[package]]
-name = "darling_macro"
-version = "0.10.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72"
-dependencies = [
- "darling_core",
- "quote",
- "syn",
-]
-
[[package]]
name = "data-encoding"
version = "2.3.2"
@@ -722,31 +641,6 @@ dependencies = [
"uuid 0.8.2",
]
-[[package]]
-name = "derive_builder"
-version = "0.8.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9a71d29c78eaaf1534fc79955d500f7f7799ed350c97bceb6cfd908a2241eba7"
-dependencies = [
- "darling",
- "derive_builder_core",
- "proc-macro2",
- "quote",
- "syn",
-]
-
-[[package]]
-name = "derive_builder_core"
-version = "0.8.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "69cecb1f2c698fd8faf108b53ad47f1fc4cd0c2a16691fe2db2d371f52f71421"
-dependencies = [
- "darling",
- "proc-macro2",
- "quote",
- "syn",
-]
-
[[package]]
name = "digest"
version = "0.9.0"
@@ -840,7 +734,7 @@ checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3"
dependencies = [
"atty",
"humantime",
- "log 0.4.17",
+ "log",
"regex",
"termcolor",
]
@@ -852,12 +746,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0"
[[package]]
-name = "failure"
-version = "0.1.8"
+name = "fantoccini"
+version = "0.19.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86"
+checksum = "65f0fbe245d714b596ba5802b46f937f5ce68dcae0f32f9a70b5c3b04d3c6f64"
dependencies = [
- "backtrace",
+ "base64",
+ "cookie",
+ "futures-core",
+ "futures-util",
+ "http",
+ "hyper",
+ "hyper-tls",
+ "mime",
+ "serde",
+ "serde_json",
+ "time 0.3.14",
+ "tokio",
+ "url",
+ "webdriver",
]
[[package]]
@@ -867,7 +774,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2687b5a6108f18ba8621e0e618a3be1dcc2768632dad24b7cea1f87975375a9"
dependencies = [
"anyhow",
- "log 0.4.17",
+ "log",
"thiserror",
"tokio",
"tokio-stream",
@@ -919,15 +826,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191"
dependencies = [
"matches",
- "percent-encoding 2.1.0",
+ "percent-encoding",
]
-[[package]]
-name = "fuchsia-cprng"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
-
[[package]]
name = "futures"
version = "0.3.23"
@@ -1050,18 +951,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9"
dependencies = [
"typenum",
- "version_check 0.9.4",
-]
-
-[[package]]
-name = "getrandom"
-version = "0.1.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
-dependencies = [
- "cfg-if",
- "libc",
- "wasi 0.9.0+wasi-snapshot-preview1",
+ "version_check",
]
[[package]]
@@ -1136,13 +1026,13 @@ version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cff78e5788be1e0ab65b04d306b2ed5092c815ec97ec70f4ebd5aee158aa55d"
dependencies = [
- "base64 0.13.0",
+ "base64",
"bitflags",
"bytes",
"headers-core",
"http",
"httpdate",
- "mime 0.3.16",
+ "mime",
"sha-1 0.10.0",
]
@@ -1155,27 +1045,6 @@ dependencies = [
"http",
]
-[[package]]
-name = "headless_chrome"
-version = "0.9.0"
-source = "git+https://github.com/atroche/rust-headless-chrome#3aecbf81016c036a21875db4cb773639e25ced6b"
-dependencies = [
- "anyhow",
- "auto_generate_cdp",
- "base64 0.10.1",
- "derive_builder",
- "log 0.4.17",
- "rand 0.7.3",
- "regex",
- "serde",
- "serde_json",
- "tempfile",
- "thiserror",
- "websocket",
- "which",
- "winreg 0.6.2",
-]
-
[[package]]
name = "heck"
version = "0.4.0"
@@ -1269,25 +1138,6 @@ version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
-[[package]]
-name = "hyper"
-version = "0.10.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0a0652d9a2609a968c14be1a9ea00bf4b1d64e2e1f53a1b51b6fff3a6e829273"
-dependencies = [
- "base64 0.9.3",
- "httparse",
- "language-tags",
- "log 0.3.9",
- "mime 0.2.6",
- "num_cpus",
- "time",
- "traitobject",
- "typeable",
- "unicase 1.4.2",
- "url 1.7.2",
-]
-
[[package]]
name = "hyper"
version = "0.14.20"
@@ -1319,7 +1169,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
dependencies = [
"bytes",
- "hyper 0.14.20",
+ "hyper",
"native-tls",
"tokio",
"tokio-native-tls",
@@ -1338,23 +1188,6 @@ dependencies = [
"winapi",
]
-[[package]]
-name = "ident_case"
-version = "1.0.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
-
-[[package]]
-name = "idna"
-version = "0.1.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e"
-dependencies = [
- "matches",
- "unicode-bidi",
- "unicode-normalization",
-]
-
[[package]]
name = "idna"
version = "0.2.3"
@@ -1372,7 +1205,7 @@ version = "1.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e"
dependencies = [
- "autocfg 1.1.0",
+ "autocfg",
"hashbrown",
]
@@ -1439,15 +1272,9 @@ version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f"
dependencies = [
- "log 0.4.17",
+ "log",
]
-[[package]]
-name = "language-tags"
-version = "0.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a"
-
[[package]]
name = "lazy_static"
version = "1.4.0"
@@ -1472,19 +1299,10 @@ version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53"
dependencies = [
- "autocfg 1.1.0",
+ "autocfg",
"scopeguard",
]
-[[package]]
-name = "log"
-version = "0.3.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
-dependencies = [
- "log 0.4.17",
-]
-
[[package]]
name = "log"
version = "0.4.17"
@@ -1541,15 +1359,6 @@ version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
-[[package]]
-name = "mime"
-version = "0.2.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0"
-dependencies = [
- "log 0.3.9",
-]
-
[[package]]
name = "mime"
version = "0.3.16"
@@ -1562,8 +1371,8 @@ version = "2.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef"
dependencies = [
- "mime 0.3.16",
- "unicase 2.6.0",
+ "mime",
+ "unicase",
]
[[package]]
@@ -1588,7 +1397,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf"
dependencies = [
"libc",
- "log 0.4.17",
+ "log",
"wasi 0.11.0+wasi-snapshot-preview1",
"windows-sys",
]
@@ -1601,11 +1410,11 @@ checksum = "00dec633863867f29cb39df64a397cdf4a6354708ddd7759f70c7fb51c5f9182"
dependencies = [
"buf_redux",
"httparse",
- "log 0.4.17",
- "mime 0.3.16",
+ "log",
+ "mime",
"mime_guess",
"quick-error",
- "rand 0.8.5",
+ "rand",
"safemem",
"tempfile",
"twoway",
@@ -1619,7 +1428,7 @@ checksum = "fd7e2f3618557f980e0b17e8856252eee3c97fa12c54dff0ca290fb6266ca4a9"
dependencies = [
"lazy_static",
"libc",
- "log 0.4.17",
+ "log",
"openssl",
"openssl-probe",
"openssl-sys",
@@ -1645,7 +1454,7 @@ version = "0.1.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
dependencies = [
- "autocfg 1.1.0",
+ "autocfg",
"num-traits",
]
@@ -1655,7 +1464,7 @@ version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
dependencies = [
- "autocfg 1.1.0",
+ "autocfg",
]
[[package]]
@@ -1668,6 +1477,15 @@ dependencies = [
"libc",
]
+[[package]]
+name = "num_threads"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44"
+dependencies = [
+ "libc",
+]
+
[[package]]
name = "object"
version = "0.29.0"
@@ -1736,7 +1554,7 @@ version = "0.9.75"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5f9bd0c2710541a3cda73d6f9ac4f1b240de4ae261065d309dbe73d9dceb42f"
dependencies = [
- "autocfg 1.1.0",
+ "autocfg",
"cc",
"libc",
"openssl-src",
@@ -1810,12 +1628,6 @@ version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9423e2b32f7a043629287a536f21951e8c6a82482d0acb1eeebfc90bc2225b22"
-[[package]]
-name = "percent-encoding"
-version = "1.0.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
-
[[package]]
name = "percent-encoding"
version = "2.1.0"
@@ -1868,7 +1680,7 @@ checksum = "685404d509889fade3e86fe3a5803bca2ec09b0c0778d5ada6ec8bf7a8de5259"
dependencies = [
"cfg-if",
"libc",
- "log 0.4.17",
+ "log",
"wepoll-ffi",
"winapi",
]
@@ -1889,7 +1701,7 @@ dependencies = [
"proc-macro2",
"quote",
"syn",
- "version_check 0.9.4",
+ "version_check",
]
[[package]]
@@ -1900,7 +1712,7 @@ checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
dependencies = [
"proc-macro2",
"quote",
- "version_check 0.9.4",
+ "version_check",
]
[[package]]
@@ -1927,38 +1739,6 @@ dependencies = [
"proc-macro2",
]
-[[package]]
-name = "rand"
-version = "0.6.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca"
-dependencies = [
- "autocfg 0.1.8",
- "libc",
- "rand_chacha 0.1.1",
- "rand_core 0.4.2",
- "rand_hc 0.1.0",
- "rand_isaac",
- "rand_jitter",
- "rand_os",
- "rand_pcg",
- "rand_xorshift",
- "winapi",
-]
-
-[[package]]
-name = "rand"
-version = "0.7.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
-dependencies = [
- "getrandom 0.1.16",
- "libc",
- "rand_chacha 0.2.2",
- "rand_core 0.5.1",
- "rand_hc 0.2.0",
-]
-
[[package]]
name = "rand"
version = "0.8.5"
@@ -1966,28 +1746,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [
"libc",
- "rand_chacha 0.3.1",
- "rand_core 0.6.3",
-]
-
-[[package]]
-name = "rand_chacha"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef"
-dependencies = [
- "autocfg 0.1.8",
- "rand_core 0.3.1",
-]
-
-[[package]]
-name = "rand_chacha"
-version = "0.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
-dependencies = [
- "ppv-lite86",
- "rand_core 0.5.1",
+ "rand_chacha",
+ "rand_core",
]
[[package]]
@@ -1997,31 +1757,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
- "rand_core 0.6.3",
-]
-
-[[package]]
-name = "rand_core"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
-dependencies = [
- "rand_core 0.4.2",
-]
-
-[[package]]
-name = "rand_core"
-version = "0.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
-
-[[package]]
-name = "rand_core"
-version = "0.5.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
-dependencies = [
- "getrandom 0.1.16",
+ "rand_core",
]
[[package]]
@@ -2030,87 +1766,7 @@ version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
dependencies = [
- "getrandom 0.2.7",
-]
-
-[[package]]
-name = "rand_hc"
-version = "0.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4"
-dependencies = [
- "rand_core 0.3.1",
-]
-
-[[package]]
-name = "rand_hc"
-version = "0.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
-dependencies = [
- "rand_core 0.5.1",
-]
-
-[[package]]
-name = "rand_isaac"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08"
-dependencies = [
- "rand_core 0.3.1",
-]
-
-[[package]]
-name = "rand_jitter"
-version = "0.1.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b"
-dependencies = [
- "libc",
- "rand_core 0.4.2",
- "winapi",
-]
-
-[[package]]
-name = "rand_os"
-version = "0.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071"
-dependencies = [
- "cloudabi",
- "fuchsia-cprng",
- "libc",
- "rand_core 0.4.2",
- "rdrand",
- "winapi",
-]
-
-[[package]]
-name = "rand_pcg"
-version = "0.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44"
-dependencies = [
- "autocfg 0.1.8",
- "rand_core 0.4.2",
-]
-
-[[package]]
-name = "rand_xorshift"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c"
-dependencies = [
- "rand_core 0.3.1",
-]
-
-[[package]]
-name = "rdrand"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
-dependencies = [
- "rand_core 0.3.1",
+ "getrandom",
]
[[package]]
@@ -2122,7 +1778,7 @@ dependencies = [
"csv",
"dotenv",
"env_logger",
- "log 0.4.17",
+ "log",
"openssl",
"sentry",
"serde",
@@ -2149,7 +1805,7 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b"
dependencies = [
- "getrandom 0.2.7",
+ "getrandom",
"redox_syscall",
"thiserror",
]
@@ -2192,7 +1848,7 @@ version = "0.11.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b75aa69a3f06bbcc66ede33af2af253c6f7a86b1ca0033f60c580a27074fbf92"
dependencies = [
- "base64 0.13.0",
+ "base64",
"bytes",
"encoding_rs",
"futures-core",
@@ -2200,15 +1856,15 @@ dependencies = [
"h2",
"http",
"http-body",
- "hyper 0.14.20",
+ "hyper",
"hyper-tls",
"ipnet",
"js-sys",
"lazy_static",
- "log 0.4.17",
- "mime 0.3.16",
+ "log",
+ "mime",
"native-tls",
- "percent-encoding 2.1.0",
+ "percent-encoding",
"pin-project-lite",
"serde",
"serde_json",
@@ -2217,7 +1873,7 @@ dependencies = [
"tokio-native-tls",
"tokio-socks",
"tower-service",
- "url 2.2.2",
+ "url",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
@@ -2362,7 +2018,7 @@ checksum = "f9a957270c9a430218f8031c866493061a27e35a70250e9527f093563a33ce6b"
dependencies = [
"chrono",
"lazy_static",
- "rand 0.8.5",
+ "rand",
"sentry-types",
"serde",
"serde_json",
@@ -2389,7 +2045,7 @@ dependencies = [
"serde",
"serde_json",
"thiserror",
- "url 2.2.2",
+ "url",
"uuid 0.8.2",
]
@@ -2460,21 +2116,6 @@ dependencies = [
"digest 0.10.3",
]
-[[package]]
-name = "sha1"
-version = "0.6.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770"
-dependencies = [
- "sha1_smol",
-]
-
-[[package]]
-name = "sha1_smol"
-version = "1.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012"
-
[[package]]
name = "sha2"
version = "0.10.2"
@@ -2511,7 +2152,7 @@ version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef"
dependencies = [
- "autocfg 1.1.0",
+ "autocfg",
]
[[package]]
@@ -2559,7 +2200,7 @@ checksum = "8c21d3b5e7cadfe9ba7cdc1295f72cc556c750b4419c27c219c0693198901f8e"
dependencies = [
"ahash",
"atoi",
- "base64 0.13.0",
+ "base64",
"bitflags",
"byteorder",
"bytes",
@@ -2581,13 +2222,13 @@ dependencies = [
"indexmap",
"itoa 1.0.3",
"libc",
- "log 0.4.17",
+ "log",
"md-5",
"memchr",
"once_cell",
"paste",
- "percent-encoding 2.1.0",
- "rand 0.8.5",
+ "percent-encoding",
+ "rand",
"serde",
"serde_json",
"sha-1 0.10.0",
@@ -2598,7 +2239,7 @@ dependencies = [
"stringprep",
"thiserror",
"tokio-stream",
- "url 2.2.2",
+ "url",
"uuid 1.1.2",
"whoami",
]
@@ -2622,7 +2263,7 @@ dependencies = [
"sqlx-core",
"sqlx-rt",
"syn",
- "url 2.2.2",
+ "url",
]
[[package]]
@@ -2646,7 +2287,7 @@ dependencies = [
"anymap2",
"chrono",
"dotenv",
- "log 0.4.17",
+ "log",
"serde",
"serde_json",
"sqlx",
@@ -2676,12 +2317,6 @@ dependencies = [
"unicode-normalization",
]
-[[package]]
-name = "strsim"
-version = "0.9.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c"
-
[[package]]
name = "strsim"
version = "0.10.0"
@@ -2765,6 +2400,24 @@ dependencies = [
"winapi",
]
+[[package]]
+name = "time"
+version = "0.3.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3c3f9a28b618c3a6b9251b6908e9c99e04b9e5c02e6581ccbb67d59c34ef7f9b"
+dependencies = [
+ "itoa 1.0.3",
+ "libc",
+ "num_threads",
+ "time-macros",
+]
+
+[[package]]
+name = "time-macros"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "42657b1a6f4d817cda8e7a0ace261fe0cc946cf3a80314390b22cc61ae080792"
+
[[package]]
name = "tinyvec"
version = "1.6.0"
@@ -2786,7 +2439,7 @@ version = "1.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a8325f63a7d4774dd041e363b2409ed1c5cbbd0f867795e661df066b2b0a581"
dependencies = [
- "autocfg 1.1.0",
+ "autocfg",
"bytes",
"libc",
"memchr",
@@ -2852,7 +2505,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "511de3f85caf1c98983545490c3d09685fa8eb634e57eec22bb4db271f46cbd8"
dependencies = [
"futures-util",
- "log 0.4.17",
+ "log",
"pin-project",
"tokio",
"tungstenite",
@@ -2867,7 +2520,7 @@ dependencies = [
"bytes",
"futures-core",
"futures-sink",
- "log 0.4.17",
+ "log",
"pin-project-lite",
"tokio",
]
@@ -2899,7 +2552,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fce9567bd60a67d08a16488756721ba392f24f29006402881e43b19aac64307"
dependencies = [
"cfg-if",
- "log 0.4.17",
+ "log",
"pin-project-lite",
"tracing-core",
]
@@ -2913,12 +2566,6 @@ dependencies = [
"once_cell",
]
-[[package]]
-name = "traitobject"
-version = "0.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079"
-
[[package]]
name = "trust-dns-proto"
version = "0.21.2"
@@ -2932,16 +2579,16 @@ dependencies = [
"futures-channel",
"futures-io",
"futures-util",
- "idna 0.2.3",
+ "idna",
"ipnet",
"lazy_static",
- "log 0.4.17",
- "rand 0.8.5",
+ "log",
+ "rand",
"smallvec",
"thiserror",
"tinyvec",
"tokio",
- "url 2.2.2",
+ "url",
]
[[package]]
@@ -2954,7 +2601,7 @@ dependencies = [
"futures-util",
"ipconfig",
"lazy_static",
- "log 0.4.17",
+ "log",
"lru-cache",
"parking_lot 0.12.1",
"resolv-conf",
@@ -2975,16 +2622,16 @@ version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0b2d8558abd2e276b0a8df5c05a2ec762609344191e5fd23e292c910e9165b5"
dependencies = [
- "base64 0.13.0",
+ "base64",
"byteorder",
"bytes",
"http",
"httparse",
- "log 0.4.17",
- "rand 0.8.5",
+ "log",
+ "rand",
"sha-1 0.9.8",
"thiserror",
- "url 2.2.2",
+ "url",
"utf-8",
]
@@ -2997,12 +2644,6 @@ dependencies = [
"memchr",
]
-[[package]]
-name = "typeable"
-version = "0.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887"
-
[[package]]
name = "typenum"
version = "1.15.0"
@@ -3018,22 +2659,13 @@ dependencies = [
"libc",
]
-[[package]]
-name = "unicase"
-version = "1.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33"
-dependencies = [
- "version_check 0.1.5",
-]
-
[[package]]
name = "unicase"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
dependencies = [
- "version_check 0.9.4",
+ "version_check",
]
[[package]]
@@ -3069,17 +2701,6 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e"
-[[package]]
-name = "url"
-version = "1.7.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a"
-dependencies = [
- "idna 0.1.5",
- "matches",
- "percent-encoding 1.0.1",
-]
-
[[package]]
name = "url"
version = "2.2.2"
@@ -3087,9 +2708,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c"
dependencies = [
"form_urlencoded",
- "idna 0.2.3",
+ "idna",
"matches",
- "percent-encoding 2.1.0",
+ "percent-encoding",
"serde",
]
@@ -3105,7 +2726,7 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
dependencies = [
- "getrandom 0.2.7",
+ "getrandom",
"serde",
]
@@ -3115,7 +2736,7 @@ version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd6469f4314d5f1ffec476e05f17cc9a78bc7a27a6a857842170bdf8d6f98d2f"
dependencies = [
- "getrandom 0.2.7",
+ "getrandom",
]
[[package]]
@@ -3125,7 +2746,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2209b78d1249f7e6f3293657c9779fe31ced465df091bbd433a1cf88e916ec55"
dependencies = [
"ctor",
- "version_check 0.9.4",
+ "version_check",
]
[[package]]
@@ -3134,12 +2755,6 @@ version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
-[[package]]
-name = "version_check"
-version = "0.1.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
-
[[package]]
name = "version_check"
version = "0.9.4"
@@ -3158,7 +2773,7 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0"
dependencies = [
- "log 0.4.17",
+ "log",
"try-lock",
]
@@ -3173,12 +2788,12 @@ dependencies = [
"futures-util",
"headers",
"http",
- "hyper 0.14.20",
- "log 0.4.17",
- "mime 0.3.16",
+ "hyper",
+ "log",
+ "mime",
"mime_guess",
"multipart",
- "percent-encoding 2.1.0",
+ "percent-encoding",
"pin-project",
"scoped-tls",
"serde",
@@ -3192,12 +2807,6 @@ dependencies = [
"tracing",
]
-[[package]]
-name = "wasi"
-version = "0.9.0+wasi-snapshot-preview1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
-
[[package]]
name = "wasi"
version = "0.10.0+wasi-snapshot-preview1"
@@ -3227,7 +2836,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "662cd44805586bd52971b9586b1df85cdbbd9112e4ef4d8f41559c334dc6ac3f"
dependencies = [
"bumpalo",
- "log 0.4.17",
+ "log",
"once_cell",
"proc-macro2",
"quote",
@@ -3287,19 +2896,22 @@ dependencies = [
]
[[package]]
-name = "websocket"
-version = "0.23.0"
+name = "webdriver"
+version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b255b190f412e45000c35be7fe9b48b39a2ac5eb90d093d421694e5dae8b335c"
+checksum = "9973cb72c8587d5ad5efdb91e663d36177dc37725e6c90ca86c626b0cc45c93f"
dependencies = [
- "base64 0.10.1",
- "bitflags",
- "byteorder",
- "hyper 0.10.16",
- "rand 0.6.5",
- "sha1",
- "unicase 1.4.2",
- "url 1.7.2",
+ "base64",
+ "bytes",
+ "cookie",
+ "http",
+ "log",
+ "serde",
+ "serde_derive",
+ "serde_json",
+ "time 0.3.14",
+ "unicode-segmentation",
+ "url",
]
[[package]]
@@ -3311,16 +2923,6 @@ dependencies = [
"cc",
]
-[[package]]
-name = "which"
-version = "3.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724"
-dependencies = [
- "failure",
- "libc",
-]
-
[[package]]
name = "whoami"
version = "1.2.1"
@@ -3411,15 +3013,6 @@ version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680"
-[[package]]
-name = "winreg"
-version = "0.6.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9"
-dependencies = [
- "winapi",
-]
-
[[package]]
name = "winreg"
version = "0.7.0"
diff --git a/Dockerfile b/Dockerfile
index c8cb7326..03188e66 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -22,36 +22,41 @@ RUN cargo build --bin reacher_backend --release --target=x86_64-unknown-linux-mu
FROM alpine:latest
-# Installs latest Chromium package.
-RUN apk upgrade --no-cache --available \
- && apk add --no-cache \
- chromium \
- ttf-freefont \
- font-noto-emoji \
- && apk add --no-cache \
- --repository=https://dl-cdn.alpinelinux.org/alpine/edge/testing \
- font-wqy-zenhei
-
RUN addgroup -g 1000 reacher
RUN adduser -D -s /bin/sh -u 1000 -G reacher reacher
WORKDIR /home/reacher/bin/
+# Install glibc
+# https://github.com/sgerrand/alpine-pkg-glibc
+RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
+ wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.35-r0/glibc-2.35-r0.apk && \
+ apk add glibc-2.35-r0.apk
+
+# We need Firefox if we actually want to use GeckoDriver
+RUN apk add firefox-esr
+
+# Then install GeckoDriver
+ARG GECKODRIVER_VERSION=v0.31.0
+RUN wget https://github.com/mozilla/geckodriver/releases/download/$GECKODRIVER_VERSION/geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz && \
+ tar -zxf geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz -C /usr/bin
+
COPY --from=cargo-build /usr/src/reacher/target/x86_64-unknown-linux-musl/release/reacher_backend .
+COPY --from=cargo-build /usr/src/reacher/docker.sh .
RUN chown reacher:reacher reacher_backend
+RUN chown reacher:reacher docker.sh
USER reacher
ENV RUST_LOG=reacher=info
ENV RCH_HTTP_HOST=0.0.0.0
ENV PORT=8080
-# Using a headless navigator to verify Hotmail emails is disabled. Set to 1 to enable it.
-ENV RCH_HOTMAIL_USE_HEADLESS=0
+ENV RCH_HOTMAIL_USE_HEADLESS=http://localhost:4444
# Bulk verification is disabled by default. Set to 1 to enable it.
ENV RCH_ENABLE_BULK=0
EXPOSE 8080
-CMD ["./reacher_backend"]
+CMD ["./docker.sh"]
diff --git a/backend/README.md b/backend/README.md
index 196d3148..b1981ede 100644
--- a/backend/README.md
+++ b/backend/README.md
@@ -48,20 +48,20 @@ Then send a `POST http://localhost:8080/v0/check_email` request with the followi
These are the environment variables used to configure the HTTP server. To pass them to the Docker container, use the `-e {ENV_VAR}={VALUE}` flag.
-| Env Var | Required? | Description | Default |
-| ----------------------------------- | --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
-| `RCH_ENABLE_BULK` | No | If set to `1`, then bulk verification endpoints will be added to the backend. | 0 |
-| `DATABASE_URL` | Yes if `RCH_ENABLE_BULK==1` | Database connection string for storing results and task queue | not defined |
-| `RCH_HTTP_HOST` | No | The host name to bind the HTTP server to. | `127.0.0.1` |
-| `PORT` | No | The port to bind the HTTP server to, often populated by the cloud provider. | `8080` |
-| `RCH_HOTMAIL_USE_HEADLESS` | No | If set to `1`, use a headless navigator to Hotmail's password recovery page to check Hotmail/Outlook addresses. Requires a local instance of Chrome/Chromium. | not defined |
-| `RCH_FROM_EMAIL` | No | The email to use in the `MAIL FROM:` SMTP command. | `[email protected]` |
-| `RCH_SENTRY_DSN` | No | If set, bug reports will be sent to this [Sentry](https://sentry.io) DSN. | not defined |
-| `RCH_HEADER_SECRET` | No | If set, then all HTTP requests must have the `x-reacher-secret` header set to this value. This is used to protect the backend against public unwanted HTTP requests. | undefined |
-| `RCH_DATABASE_MAX_CONNECTIONS` | No | (Bulk) Connections created for the database pool | 5 |
-| `RCH_MINIMUM_TASK_CONCURRENCY` | No | (Bulk) Minimum number of concurrent running tasks below which more tasks are fetched | 10 |
-| `RCH_MAXIMUM_CONCURRENT_TASK_FETCH` | No | (Bulk) Maximum number of tasks fetched at once | 20 |
-| `RUST_LOG` | No | One of `trace,debug,warn,error,info`. 💡 PRO TIP: `RUST_LOG=debug` is very handful for debugging purposes. | not defined |
+| Env Var | Required? | Description | Default |
+| ----------------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------ |
+| `RCH_ENABLE_BULK` | No | If set to `1`, then bulk verification endpoints will be added to the backend. | 0 |
+| `DATABASE_URL` | Yes if `RCH_ENABLE_BULK==1` | Database connection string for storing results and task queue | not defined |
+| `RCH_HTTP_HOST` | No | The host name to bind the HTTP server to. | `127.0.0.1` |
+| `PORT` | No | The port to bind the HTTP server to, often populated by the cloud provider. | `8080` |
+| `RCH_HOTMAIL_USE_HEADLESS` | No | Set to a running WebDriver process endpoint (e.g. `http://localhost:4444`) to use a headless navigator to Hotmail's password recovery page to check Hotmail/Outlook addresses. | not defined |
+| `RCH_FROM_EMAIL` | No | The email to use in the `MAIL FROM:` SMTP command. | `[email protected]` |
+| `RCH_SENTRY_DSN` | No | If set, bug reports will be sent to this [Sentry](https://sentry.io) DSN. | not defined |
+| `RCH_HEADER_SECRET` | No | If set, then all HTTP requests must have the `x-reacher-secret` header set to this value. This is used to protect the backend against public unwanted HTTP requests. | undefined |
+| `RCH_DATABASE_MAX_CONNECTIONS` | No | (Bulk) Connections created for the database pool | 5 |
+| `RCH_MINIMUM_TASK_CONCURRENCY` | No | (Bulk) Minimum number of concurrent running tasks below which more tasks are fetched | 10 |
+| `RCH_MAXIMUM_CONCURRENT_TASK_FETCH` | No | (Bulk) Maximum number of tasks fetched at once | 20 |
+| `RUST_LOG` | No | One of `trace,debug,warn,error,info`. 💡 PRO TIP: `RUST_LOG=debug` is very handful for debugging purposes. | not defined |
## REST API Documentation
diff --git a/backend/src/check.rs b/backend/src/check.rs
index bf39c0c0..0194ac62 100644
--- a/backend/src/check.rs
+++ b/backend/src/check.rs
@@ -32,9 +32,7 @@ const SMTP_TIMEOUT: u64 = 30;
/// inputs and error handling.
pub async fn check_email(mut input: CheckEmailInput) -> CheckEmailOutput {
input.set_smtp_timeout(Duration::from_secs(SMTP_TIMEOUT));
- input.set_hotmail_use_headless(
- env::var("RCH_HOTMAIL_USE_HEADLESS").unwrap_or_else(|_| "".into()) == "1",
- );
+ input.set_hotmail_use_headless(env::var("RCH_HOTMAIL_USE_HEADLESS").ok());
let res = ciee_check_email(&input).await;
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 6ff2cece..091cb10d 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -13,14 +13,14 @@ readme = "../README.md"
repository = "https://github.com/reacherhq/check-if-email-exists"
[dependencies]
-anyhow = { version = "1.0.61", optional = true }
async-native-tls = { version = "0.4", default-features = false }
async-recursion = "1.0.0"
async-smtp = { version = "0.5.0", features = ["socks5"] }
async-std = "1.12.0"
async-std-resolver = "0.21.2"
+fantoccini = { version = "0.19.3", optional = true }
+futures = { version = "0.3.23", optional = true }
fast-socks5 = "0.8.1"
-headless_chrome = { git = "https://github.com/atroche/rust-headless-chrome", optional = true }
log = "0.4.17"
mailchecker = "5.0.0"
rand = {version = "0.8.5", features = ["small_rng"] }
@@ -34,4 +34,4 @@ trust-dns-proto = "0.21.2"
tokio = { version = "1.16.1" }
[features]
-headless = ["anyhow", "headless_chrome"]
+headless = ["fantoccini", "futures"]
diff --git a/core/src/smtp/connect.rs b/core/src/smtp/connect.rs
new file mode 100644
index 00000000..eeeb9bc7
--- /dev/null
+++ b/core/src/smtp/connect.rs
@@ -0,0 +1,364 @@
+// check-if-email-exists
+// Copyright (C) 2018-2022 Reacher
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published
+// by the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+use async_native_tls::TlsConnector;
+use async_recursion::async_recursion;
+use async_smtp::{
+ smtp::{commands::*, extension::ClientId, ServerAddress, Socks5Config},
+ ClientTlsParameters, EmailAddress, SmtpClient, SmtpTransport,
+};
+use async_std::future;
+use rand::rngs::SmallRng;
+use rand::{distributions::Alphanumeric, Rng, SeedableRng};
+use std::iter;
+use std::str::FromStr;
+use std::time::Duration;
+
+use trust_dns_proto::rr::Name;
+
+use super::parser;
+use super::{SmtpDetails, SmtpError};
+use crate::util::{constants::LOG_TARGET, input_output::CheckEmailInput};
+
+/// Try to send an smtp command, close and return Err if fails.
+macro_rules! try_smtp (
+ ($res: expr, $client: ident, $to_email: expr, $host: expr, $port: expr) => ({
+ if let Err(err) = $res {
+ log::debug!(target: LOG_TARGET, "[email={}] Closing [host={}:{}], because of error '{:?}'.", $to_email, $host, $port, err);
+ // Try to close the connection, but ignore if there's an error.
+ let _ = $client.close().await;
+
+ return Err(SmtpError::SmtpError(err));
+ }
+ })
+);
+
+/// Attempt to connect to host via SMTP, and return SMTP client on success.
+async fn connect_to_host(
+ host: &Name,
+ port: u16,
+ input: &CheckEmailInput,
+) -> Result<SmtpTransport, SmtpError> {
+ // hostname verification fails if it ends with '.', for example, using
+ // SOCKS5 proxies we can `io: incomplete` error.
+ let host = host.to_string();
+ let host = host.trim_end_matches('.').to_string();
+
+ let security = {
+ let tls_params = ClientTlsParameters::new(host.clone(), TlsConnector::new().use_sni(true));
+
+ input.smtp_security.to_client_security(tls_params)
+ };
+
+ let mut smtp_client = SmtpClient::with_security(
+ ServerAddress {
+ host: host.clone(),
+ port,
+ },
+ security,
+ )
+ .hello_name(ClientId::Domain(input.hello_name.clone()))
+ .timeout(Some(Duration::new(30, 0))); // Set timeout to 30s
+
+ if let Some(proxy) = &input.proxy {
+ let socks5_config = match (&proxy.username, &proxy.password) {
+ (Some(username), Some(password)) => Socks5Config::new_with_user_pass(
+ proxy.host.clone(),
+ proxy.port,
+ username.clone(),
+ password.clone(),
+ ),
+ _ => Socks5Config::new(proxy.host.clone(), proxy.port),
+ };
+
+ smtp_client = smtp_client.use_socks5(socks5_config);
+ }
+
+ let mut smtp_transport = smtp_client.into_transport();
+
+ try_smtp!(
+ smtp_transport.connect().await,
+ smtp_transport,
+ input.to_email,
+ host,
+ port
+ );
+
+ // "MAIL FROM: [email protected]"
+ let from_email = EmailAddress::from_str(input.from_email.as_ref()).unwrap_or_else(|_| {
+ log::warn!(
+ "Inputted from_email \"{}\" is not a valid email, using \"[email protected]\" instead",
+ input.from_email
+ );
+ EmailAddress::from_str("[email protected]").expect("This is a valid email. qed.")
+ });
+ try_smtp!(
+ smtp_transport
+ .command(MailCommand::new(Some(from_email), vec![],))
+ .await,
+ smtp_transport,
+ input.to_email,
+ host,
+ port
+ );
+
+ Ok(smtp_transport)
+}
+
+/// Description of the deliverability information we can gather from
+/// communicating with the SMTP server.
+struct Deliverability {
+ /// Is this email account's inbox full?
+ has_full_inbox: bool,
+ /// Can we send an email to this address?
+ is_deliverable: bool,
+ /// Is the email blocked or disabled by the provider?
+ is_disabled: bool,
+}
+
+/// Check if `to_email` exists on host SMTP server. This is the core logic of
+/// this tool.
+async fn email_deliverable(
+ smtp_transport: &mut SmtpTransport,
+ to_email: &EmailAddress,
+) -> Result<Deliverability, SmtpError> {
+ // "RCPT TO: <target email>"
+ // FIXME Do not clone `to_email`?
+ match smtp_transport
+ .command(RcptCommand::new(to_email.clone(), vec![]))
+ .await
+ {
+ Ok(_) => {
+ // According to RFC 5321, `RCPT TO` command succeeds with 250 and
+ // 251 codes only (no 3xx codes at all):
+ // https://tools.ietf.org/html/rfc5321#page-56
+ //
+ // Where the 251 code is used for forwarding, which is not our case,
+ // because we always deliver to the SMTP server hosting the address
+ // itself.
+ //
+ // So, if `response.is_positive()` (which is a condition for
+ // returning `Ok` from the `command()` method above), then delivery
+ // succeeds, accordingly to RFC 5321.
+ Ok(Deliverability {
+ has_full_inbox: false,
+ is_deliverable: true, // response.is_positive()
+ is_disabled: false,
+ })
+ }
+ Err(err) => {
+ // We cast to lowercase, because our matched strings below are all
+ // lowercase.
+ let err_string = err.to_string().to_lowercase();
+
+ // Check if the email account has been disabled or blocked.
+ if parser::is_disabled_account(err_string.as_str()) {
+ return Ok(Deliverability {
+ has_full_inbox: false,
+ is_deliverable: false,
+ is_disabled: true,
+ });
+ }
+
+ // Check if the email account has a full inbox.
+ if parser::is_full_inbox(err_string.as_str()) {
+ return Ok(Deliverability {
+ has_full_inbox: true,
+ is_deliverable: false,
+ is_disabled: false,
+ });
+ }
+
+ // Check error messages that say that user can actually receive
+ // emails.
+ // 4.2.1 The user you are trying to contact is receiving mail at a rate that
+ if err_string
+ .contains("the user you are trying to contact is receiving mail at a rate that")
+ {
+ return Ok(Deliverability {
+ has_full_inbox: false,
+ is_deliverable: true,
+ is_disabled: false,
+ });
+ }
+
+ // Check that the mailbox doesn't exist.
+ if parser::is_invalid(err_string.as_str(), to_email) {
+ return Ok(Deliverability {
+ has_full_inbox: false,
+ is_deliverable: false,
+ is_disabled: false,
+ });
+ }
+
+ // Return all unparsable errors,.
+ Err(SmtpError::SmtpError(err))
+ }
+ }
+}
+
+/// Verify the existence of a catch-all on the domain.
+async fn smtp_is_catch_all(
+ smtp_transport: &mut SmtpTransport,
+ domain: &str,
+) -> Result<bool, SmtpError> {
+ // Create a random 15-char alphanumerical string.
+ let mut rng = SmallRng::from_entropy();
+ let random_email: String = iter::repeat(())
+ .map(|()| rng.sample(Alphanumeric))
+ .map(char::from)
+ .take(15)
+ .collect();
+ let random_email = EmailAddress::new(format!("{}@{}", random_email, domain));
+
+ email_deliverable(
+ smtp_transport,
+ &random_email.expect("Email is correctly constructed. qed."),
+ )
+ .await
+ .map(|deliverability| deliverability.is_deliverable)
+}
+
+async fn create_smtp_future(
+ to_email: &EmailAddress,
+ host: &Name,
+ port: u16,
+ domain: &str,
+ input: &CheckEmailInput,
+) -> Result<(bool, Deliverability), SmtpError> {
+ // FIXME If the SMTP is not connectable, we should actually return an
+ // Ok(SmtpDetails { can_connect_smtp: false, ... }).
+ let mut smtp_transport = connect_to_host(host, port, input).await?;
+
+ let is_catch_all = smtp_is_catch_all(&mut smtp_transport, domain)
+ .await
+ .unwrap_or(false);
+ let deliverability = if is_catch_all {
+ Deliverability {
+ has_full_inbox: false,
+ is_deliverable: true,
+ is_disabled: false,
+ }
+ } else {
+ let mut result = email_deliverable(&mut smtp_transport, to_email).await;
+
+ // Some SMTP servers automatically close the connection after an error,
+ // so we should reconnect to perform a next command.
+ //
+ // Unfortunately `smtp_transport.is_connected()` doesn't report about this,
+ // so we can only check for "io: incomplete" SMTP error being returned.
+ // https://github.com/async-email/async-smtp/issues/37
+ if let Err(e) = &result {
+ if parser::is_err_io_errors(e) {
+ log::debug!(
+ target: LOG_TARGET,
+ "Got `io: incomplete` error, reconnecting."
+ );
+
+ let _ = smtp_transport.close().await;
+ smtp_transport = connect_to_host(host, port, input).await?;
+ result = email_deliverable(&mut smtp_transport, to_email).await;
+ }
+ }
+
+ result?
+ };
+
+ smtp_transport.close().await.map_err(SmtpError::SmtpError)?;
+
+ Ok((is_catch_all, deliverability))
+}
+
+/// Get all email details we can from one single `EmailAddress`, without
+/// retries.
+async fn check_smtp_without_retry(
+ to_email: &EmailAddress,
+ host: &Name,
+ port: u16,
+ domain: &str,
+ input: &CheckEmailInput,
+) -> Result<SmtpDetails, SmtpError> {
+ let fut = create_smtp_future(to_email, host, port, domain, input);
+ let (is_catch_all, deliverability) = if let Some(smtp_timeout) = input.smtp_timeout {
+ future::timeout(smtp_timeout, fut).await??
+ } else {
+ fut.await?
+ };
+
+ Ok(SmtpDetails {
+ can_connect_smtp: true,
+ has_full_inbox: deliverability.has_full_inbox,
+ is_catch_all,
+ is_deliverable: deliverability.is_deliverable,
+ is_disabled: deliverability.is_disabled,
+ })
+}
+
+/// Get all email details we can from one single `EmailAddress`.
+/// Retry the SMTP connection on error, in particular to avoid greylisting.
+#[async_recursion]
+pub async fn check_smtp_with_retry(
+ to_email: &EmailAddress,
+ host: &Name,
+ port: u16,
+ domain: &str,
+ input: &CheckEmailInput,
+ count: usize,
+) -> Result<SmtpDetails, SmtpError> {
+ log::debug!(
+ target: LOG_TARGET,
+ "[email={}] Check SMTP [attempt={}] on [host={}:{}]",
+ input.to_email,
+ input.retries - count + 1,
+ host,
+ port
+ );
+
+ let result = check_smtp_without_retry(to_email, host, port, domain, input).await;
+
+ log::debug!(
+ target: LOG_TARGET,
+ "[email={}] Got result for [attempt={}] on [host={}:{}], [result={:?}]",
+ input.to_email,
+ input.retries - count + 1,
+ host,
+ port,
+ result
+ );
+
+ match &result {
+ // Don't retry if we used Hotmail or Yahoo API. This two options should
+ // be non-callable, as this function only deals with actual SMTP
+ // connection errors.
+ #[cfg(feature = "headless")]
+ Err(SmtpError::HotmailError(_)) => result,
+ Err(SmtpError::YahooError(_)) => result,
+ // Only retry if the SMTP error was unknown.
+ Err(err) if err.get_description().is_none() => {
+ if count <= 1 {
+ result
+ } else {
+ log::debug!(
+ target: LOG_TARGET,
+ "[email={}] Potential greylisting detected, retrying.",
+ input.to_email,
+ );
+ check_smtp_with_retry(to_email, host, port, domain, input, count - 1).await
+ }
+ }
+ _ => result,
+ }
+}
diff --git a/core/src/smtp/hotmail.rs b/core/src/smtp/hotmail.rs
index 694dd697..eb12dcb7 100644
--- a/core/src/smtp/hotmail.rs
+++ b/core/src/smtp/hotmail.rs
@@ -14,12 +14,15 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
-use std::fs;
-use std::time::Duration;
+use std::{thread::sleep, time::Duration};
use async_smtp::EmailAddress;
-use headless_chrome::protocol::cdp::Page;
-use headless_chrome::{Browser, LaunchOptionsBuilder};
+use async_std::prelude::FutureExt;
+use fantoccini::{
+ error::{CmdError, NewSessionError},
+ ClientBuilder, Locator,
+};
+use futures::TryFutureExt;
use serde::Serialize;
use super::SmtpDetails;
@@ -27,122 +30,118 @@ use crate::util::ser_with_display::ser_with_display;
use crate::LOG_TARGET;
#[derive(Debug, Serialize)]
-pub struct HotmailError {
+pub enum HotmailError {
#[serde(serialize_with = "ser_with_display")]
- err: anyhow::Error,
+ Cmd(CmdError),
+ #[serde(serialize_with = "ser_with_display")]
+ NewSession(NewSessionError),
}
-impl From<anyhow::Error> for HotmailError {
- fn from(err: anyhow::Error) -> Self {
- Self { err }
+impl From<CmdError> for HotmailError {
+ fn from(e: CmdError) -> Self {
+ Self::Cmd(e)
}
}
-/// Check if a Hotmail/Outlook email exists by connecting to the password
-/// recovery page https://account.live.com/password/reset using a headless
-/// Chrome browser. Make sure you have Chrome/Chromium installed locally before
-/// running this, or this will error.
-pub fn check_password_recovery(to_email: &EmailAddress) -> Result<SmtpDetails, HotmailError> {
- let mut res = run_headless(to_email, false);
-
- // In some rare cases, `run_headless` errors, with the following message:
- // "Scrolling element into view failed: Node is detached from document"
- // In those cases, re-run max 2 times more.
- for _ in 0..2 {
- if res.is_ok() {
- return res;
- }
-
- res = run_headless(to_email, false);
+impl From<NewSessionError> for HotmailError {
+ fn from(e: NewSessionError) -> Self {
+ Self::NewSession(e)
}
-
- res
}
-/// Launch a headless navigator to perform email password recovery. Optionally
-/// takes a screenshot of the last page, and saves it to disk, by setting
-/// `save_jpg` to true; only use this option while debugging.
-fn run_headless(to_email: &EmailAddress, save_jpg: bool) -> Result<SmtpDetails, HotmailError> {
+/// Check if a Hotmail/Outlook email exists by connecting to the password
+/// recovery page https://account.live.com/password/reset using a headless
+/// browser. Make sure you have a WebDriver server running locally before
+/// running this, or this will error.
+pub async fn check_password_recovery(
+ to_email: &EmailAddress,
+ webdriver: &str,
+) -> Result<SmtpDetails, HotmailError> {
+ let to_email = to_email.to_string();
log::debug!(
target: LOG_TARGET,
"[email={}] Using Hotmail password recovery in headless navigator",
to_email,
);
- let options = LaunchOptionsBuilder::default()
- .window_size(Some((1800, 1500)))
- .sandbox(false)
- .build()
- .unwrap();
- let browser = Browser::new(options)?;
- let tab = browser.wait_for_initial_tab()?;
- let to_email = to_email.to_string();
+
+ // Connect to webdriver instance that is listening on port 4444
+ let c = ClientBuilder::native().connect(webdriver).await?;
// Navigate to Microsoft password recovery page.
- tab.navigate_to("https://account.live.com/password/reset")?;
+ c.goto("https://account.live.com/password/reset").await?;
// Wait for network/javascript/dom to make the input-box available
// and click it.
- tab.wait_for_element("input#iSigninName")?.click()?;
-
- // Type in a query and press `Enter`
- tab.type_str(to_email.as_str())?.press_key("Enter")?;
-
- // We should end up on the WebKit-page once navigated
- tab.wait_until_navigated()?;
-
- // Somehow, empirically, it works better by waiting first for #signinNameSection,
- // then waiting for its child #pMemberNameErr.
- tab.wait_for_element_with_custom_timeout("#signinNameSection", Duration::from_secs(2))?;
- let account_does_not_exist = tab
- .wait_for_element_with_custom_timeout("#pMemberNameErr", Duration::from_secs(1))
- .is_ok();
-
- if save_jpg {
- let jpeg_data =
- tab.capture_screenshot(Page::CaptureScreenshotFormatOption::Jpeg, None, None, true)?;
- fs::write("hotmail.jpeg", &jpeg_data)
- .expect("Safe to unwrap, as save_jpg should only be used for debugging purposes.");
- }
-
- if account_does_not_exist {
+ let input = c.wait().for_element(Locator::Id("iSigninName")).await?;
+ // Sometimes I get "input ... is not reachable by keyboard". Addind this
+ // small sleep helps.
+ sleep(Duration::from_millis(200));
+ input.send_keys(to_email.as_str()).await?;
+
+ // Click on "Next"
+ c.find(Locator::Id("resetPwdHipAction"))
+ .await?
+ .click()
+ .await?;
+
+ // "Try entering your Microsoft account again. We don't recognise this one." means the account does not exist.
+ let f1 = c
+ .wait()
+ .for_element(Locator::Id("pMemberNameErr"))
+ .and_then(|_| async { Ok(false) });
+ // "We need to verify your identity" means that the account exists.
+ let f2 = c
+ .wait()
+ .for_element(Locator::Id("iSelectProofTitle"))
+ .and_then(|_| async { Ok(true) });
+ let is_deliverable = f1.try_race(f2).await?;
+
+ if is_deliverable {
log::debug!(
target: LOG_TARGET,
- "[email={}] Found error message in password recovery, email does not exist",
+ "[email={}] Did not find error message in password recovery, email exists",
to_email,
);
} else {
log::debug!(
target: LOG_TARGET,
- "[email={}] Did not find error message in password recovery, email exists",
+ "[email={}] Found error message in password recovery, email does not exist",
to_email,
);
}
+ c.close().await?;
+
Ok(SmtpDetails {
can_connect_smtp: true,
has_full_inbox: false,
is_catch_all: false,
- is_deliverable: !account_does_not_exist,
+ is_deliverable,
is_disabled: false,
})
}
#[cfg(test)]
mod tests {
- use super::run_headless;
+ use super::check_password_recovery;
use async_smtp::EmailAddress;
use std::str::FromStr;
- // Ignoring this test as it requires a local instance of Chromium. To debug
- // the headless password recovery page, simply remove the "#[ignore]".
- #[test]
+ // Ignoring this test as it requires a local process of WebDriver running on
+ // "http://localhost:4444". To debug the headless password recovery page,
+ // run e.g. geckodriver and remove the "#[ignore]".
+ // Also see: https://github.com/jonhoo/fantoccini
+ #[tokio::test]
#[ignore]
- fn test_hotmail_address() {
+ async fn test_hotmail_address() {
+ // This email does not exist.
let email = EmailAddress::from_str("[email protected]").unwrap();
// Run 10 headless sessions with the above fake email (not deliverable).
// It should not error.
for _ in 0..10 {
- let res = run_headless(&email, true).unwrap();
+ let res = check_password_recovery(&email, "http://localhost:4444")
+ .await
+ .unwrap();
assert!(!res.is_deliverable)
}
}
diff --git a/core/src/smtp/mod.rs b/core/src/smtp/mod.rs
index a8b6adc8..dd725fe6 100644
--- a/core/src/smtp/mod.rs
+++ b/core/src/smtp/mod.rs
@@ -14,30 +14,23 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
-pub mod error;
+mod connect;
+mod error;
#[cfg(feature = "headless")]
mod hotmail;
mod parser;
mod yahoo;
-use super::util::{constants::LOG_TARGET, input_output::CheckEmailInput};
-use async_native_tls::TlsConnector;
-use async_recursion::async_recursion;
-use async_smtp::{
- smtp::{commands::*, extension::ClientId, ServerAddress, Socks5Config},
- ClientTlsParameters, EmailAddress, SmtpClient, SmtpTransport,
-};
-use async_std::future;
-pub use error::*;
-use rand::rngs::SmallRng;
-use rand::{distributions::Alphanumeric, Rng, SeedableRng};
-use serde::{Deserialize, Serialize};
use std::default::Default;
-use std::iter;
-use std::str::FromStr;
-use std::time::Duration;
+
+use async_smtp::EmailAddress;
+use serde::{Deserialize, Serialize};
use trust_dns_proto::rr::Name;
+use crate::util::input_output::CheckEmailInput;
+use connect::check_smtp_with_retry;
+pub use error::*;
+
/// Details that we gathered from connecting to this email via SMTP
#[derive(Debug, Default, Deserialize, Serialize)]
pub struct SmtpDetails {
@@ -53,351 +46,32 @@ pub struct SmtpDetails {
pub is_disabled: bool,
}
-/// Try to send an smtp command, close and return Err if fails.
-macro_rules! try_smtp (
- ($res: expr, $client: ident, $to_email: expr, $host: expr, $port: expr) => ({
- if let Err(err) = $res {
- log::debug!(target: LOG_TARGET, "[email={}] Closing [host={}:{}], because of error '{:?}'.", $to_email, $host, $port, err);
- // Try to close the connection, but ignore if there's an error.
- let _ = $client.close().await;
-
- return Err(SmtpError::SmtpError(err));
- }
- })
-);
-
-/// Attempt to connect to host via SMTP, and return SMTP client on success.
-async fn connect_to_host(
- host: &Name,
- port: u16,
- input: &CheckEmailInput,
-) -> Result<SmtpTransport, SmtpError> {
- // hostname verification fails if it ends with '.', for example, using
- // SOCKS5 proxies we can `io: incomplete` error.
- let host = host.to_string();
- let host = host.trim_end_matches('.').to_string();
-
- let security = {
- let tls_params = ClientTlsParameters::new(host.clone(), TlsConnector::new().use_sni(true));
-
- input.smtp_security.to_client_security(tls_params)
- };
-
- let mut smtp_client = SmtpClient::with_security(
- ServerAddress {
- host: host.clone(),
- port,
- },
- security,
- )
- .hello_name(ClientId::Domain(input.hello_name.clone()))
- .timeout(Some(Duration::new(30, 0))); // Set timeout to 30s
-
- if let Some(proxy) = &input.proxy {
- let socks5_config = match (&proxy.username, &proxy.password) {
- (Some(username), Some(password)) => Socks5Config::new_with_user_pass(
- proxy.host.clone(),
- proxy.port,
- username.clone(),
- password.clone(),
- ),
- _ => Socks5Config::new(proxy.host.clone(), proxy.port),
- };
-
- smtp_client = smtp_client.use_socks5(socks5_config);
- }
-
- let mut smtp_transport = smtp_client.into_transport();
-
- try_smtp!(
- smtp_transport.connect().await,
- smtp_transport,
- input.to_email,
- host,
- port
- );
-
- // "MAIL FROM: [email protected]"
- let from_email = EmailAddress::from_str(input.from_email.as_ref()).unwrap_or_else(|_| {
- log::warn!(
- "Inputted from_email \"{}\" is not a valid email, using \"[email protected]\" instead",
- input.from_email
- );
- EmailAddress::from_str("[email protected]").expect("This is a valid email. qed.")
- });
- try_smtp!(
- smtp_transport
- .command(MailCommand::new(Some(from_email), vec![],))
- .await,
- smtp_transport,
- input.to_email,
- host,
- port
- );
-
- Ok(smtp_transport)
-}
-
-/// Description of the deliverability information we can gather from
-/// communicating with the SMTP server.
-struct Deliverability {
- /// Is this email account's inbox full?
- has_full_inbox: bool,
- /// Can we send an email to this address?
- is_deliverable: bool,
- /// Is the email blocked or disabled by the provider?
- is_disabled: bool,
-}
-
-/// Check if `to_email` exists on host SMTP server. This is the core logic of
-/// this tool.
-async fn email_deliverable(
- smtp_transport: &mut SmtpTransport,
- to_email: &EmailAddress,
-) -> Result<Deliverability, SmtpError> {
- // "RCPT TO: <target email>"
- // FIXME Do not clone `to_email`?
- match smtp_transport
- .command(RcptCommand::new(to_email.clone(), vec![]))
- .await
- {
- Ok(_) => {
- // According to RFC 5321, `RCPT TO` command succeeds with 250 and
- // 251 codes only (no 3xx codes at all):
- // https://tools.ietf.org/html/rfc5321#page-56
- //
- // Where the 251 code is used for forwarding, which is not our case,
- // because we always deliver to the SMTP server hosting the address
- // itself.
- //
- // So, if `response.is_positive()` (which is a condition for
- // returning `Ok` from the `command()` method above), then delivery
- // succeeds, accordingly to RFC 5321.
- Ok(Deliverability {
- has_full_inbox: false,
- is_deliverable: true, // response.is_positive()
- is_disabled: false,
- })
- }
- Err(err) => {
- // We cast to lowercase, because our matched strings below are all
- // lowercase.
- let err_string = err.to_string().to_lowercase();
-
- // Check if the email account has been disabled or blocked.
- if parser::is_disabled_account(err_string.as_str()) {
- return Ok(Deliverability {
- has_full_inbox: false,
- is_deliverable: false,
- is_disabled: true,
- });
- }
-
- // Check if the email account has a full inbox.
- if parser::is_full_inbox(err_string.as_str()) {
- return Ok(Deliverability {
- has_full_inbox: true,
- is_deliverable: false,
- is_disabled: false,
- });
- }
-
- // Check error messages that say that user can actually receive
- // emails.
- // 4.2.1 The user you are trying to contact is receiving mail at a rate that
- if err_string
- .contains("the user you are trying to contact is receiving mail at a rate that")
- {
- return Ok(Deliverability {
- has_full_inbox: false,
- is_deliverable: true,
- is_disabled: false,
- });
- }
-
- // Check that the mailbox doesn't exist.
- if parser::is_invalid(err_string.as_str(), to_email) {
- return Ok(Deliverability {
- has_full_inbox: false,
- is_deliverable: false,
- is_disabled: false,
- });
- }
-
- // Return all unparsable errors,.
- Err(SmtpError::SmtpError(err))
- }
- }
-}
-
-/// Verify the existence of a catch-all on the domain.
-async fn smtp_is_catch_all(
- smtp_transport: &mut SmtpTransport,
- domain: &str,
-) -> Result<bool, SmtpError> {
- // Create a random 15-char alphanumerical string.
- let mut rng = SmallRng::from_entropy();
- let random_email: String = iter::repeat(())
- .map(|()| rng.sample(Alphanumeric))
- .map(char::from)
- .take(15)
- .collect();
- let random_email = EmailAddress::new(format!("{}@{}", random_email, domain));
-
- email_deliverable(
- smtp_transport,
- &random_email.expect("Email is correctly constructed. qed."),
- )
- .await
- .map(|deliverability| deliverability.is_deliverable)
-}
-
-async fn create_smtp_future(
- to_email: &EmailAddress,
- host: &Name,
- port: u16,
- domain: &str,
- input: &CheckEmailInput,
-) -> Result<(bool, Deliverability), SmtpError> {
- // FIXME If the SMTP is not connectable, we should actually return an
- // Ok(SmtpDetails { can_connect_smtp: false, ... }).
- let mut smtp_transport = connect_to_host(host, port, input).await?;
-
- let is_catch_all = smtp_is_catch_all(&mut smtp_transport, domain)
- .await
- .unwrap_or(false);
- let deliverability = if is_catch_all {
- Deliverability {
- has_full_inbox: false,
- is_deliverable: true,
- is_disabled: false,
- }
- } else {
- let mut result = email_deliverable(&mut smtp_transport, to_email).await;
-
- // Some SMTP servers automatically close the connection after an error,
- // so we should reconnect to perform a next command.
- //
- // Unfortunately `smtp_transport.is_connected()` doesn't report about this,
- // so we can only check for "io: incomplete" SMTP error being returned.
- // https://github.com/async-email/async-smtp/issues/37
- if let Err(e) = &result {
- if parser::is_err_io_errors(e) {
- log::debug!(
- target: LOG_TARGET,
- "Got `io: incomplete` error, reconnecting."
- );
-
- let _ = smtp_transport.close().await;
- smtp_transport = connect_to_host(host, port, input).await?;
- result = email_deliverable(&mut smtp_transport, to_email).await;
- }
- }
-
- result?
- };
-
- smtp_transport.close().await.map_err(SmtpError::SmtpError)?;
-
- Ok((is_catch_all, deliverability))
-}
-
/// Get all email details we can from one single `EmailAddress`, without
/// retries.
-async fn check_smtp_without_retry(
+pub async fn check_smtp(
to_email: &EmailAddress,
host: &Name,
port: u16,
domain: &str,
input: &CheckEmailInput,
) -> Result<SmtpDetails, SmtpError> {
+ let host_lowercase = host.to_lowercase().to_string();
// FIXME Is this `contains` too lenient?
- if input.yahoo_use_api && domain.to_lowercase().contains("yahoo") {
+ if input.yahoo_use_api && host_lowercase.contains("yahoo") {
return yahoo::check_yahoo(to_email, input)
.await
.map_err(|err| err.into());
}
#[cfg(feature = "headless")]
- if input.hotmail_use_headless && host.to_lowercase().to_string().contains("outlook") {
- return hotmail::check_password_recovery(to_email).map_err(|err| err.into());
- }
-
- let fut = create_smtp_future(to_email, host, port, domain, input);
- let (is_catch_all, deliverability) = if let Some(smtp_timeout) = input.smtp_timeout {
- future::timeout(smtp_timeout, fut).await??
- } else {
- fut.await?
- };
-
- Ok(SmtpDetails {
- can_connect_smtp: true,
- has_full_inbox: deliverability.has_full_inbox,
- is_catch_all,
- is_deliverable: deliverability.is_deliverable,
- is_disabled: deliverability.is_disabled,
- })
-}
-
-/// Get all email details we can from one single `EmailAddress`.
-/// Retry the SMTP connection, in particular to avoid greylisting.
-#[async_recursion]
-async fn retry(
- to_email: &EmailAddress,
- host: &Name,
- port: u16,
- domain: &str,
- input: &CheckEmailInput,
- count: usize,
-) -> Result<SmtpDetails, SmtpError> {
- log::debug!(
- target: LOG_TARGET,
- "[email={}] Check SMTP [attempt={}] on [host={}:{}]",
- input.to_email,
- input.retries - count + 1,
- host,
- port
- );
-
- let result = check_smtp_without_retry(to_email, host, port, domain, input).await;
-
- log::debug!(
- target: LOG_TARGET,
- "[email={}] Got result for [attempt={}] on [host={}:{}], [result={:?}]",
- input.to_email,
- input.retries - count + 1,
- host,
- port,
- result
- );
-
- match &result {
- // Only retry if the error was unknown.
- Err(err) if err.get_description().is_none() => {
- if count <= 1 {
- result
- } else {
- log::debug!(
- target: LOG_TARGET,
- "[email={}] Potential greylisting detected, retrying.",
- input.to_email,
- );
- retry(to_email, host, port, domain, input, count - 1).await
- }
+ if let Some(webdriver) = &input.hotmail_use_headless {
+ if host_lowercase.contains("outlook") {
+ return hotmail::check_password_recovery(to_email, webdriver)
+ .await
+ .map_err(|err| err.into());
}
- _ => result,
}
-}
-/// Get all email details we can from one single `EmailAddress`, without
-/// retries.
-pub async fn check_smtp(
- to_email: &EmailAddress,
- host: &Name,
- port: u16,
- domain: &str,
- input: &CheckEmailInput,
-) -> Result<SmtpDetails, SmtpError> {
- retry(to_email, host, port, domain, input, input.retries).await
+ check_smtp_with_retry(to_email, host, port, domain, input, input.retries).await
}
#[cfg(test)]
diff --git a/core/src/smtp/parser.rs b/core/src/smtp/parser.rs
index a6c01c50..a0de1bf2 100644
--- a/core/src/smtp/parser.rs
+++ b/core/src/smtp/parser.rs
@@ -181,6 +181,8 @@ pub fn is_err_ip_blacklisted(e: &SmtpError) -> bool {
|| e.contains("dnsbl")
// smtp-fw-9107.amazon.com; SBRS score too low: http://www.senderbase.org/ (on @amazon.com)
|| e.contains("sbrs score too low")
+ // https://www.spamhaus.org/sbl/query/SBLCSShttps://www.spamhaus.org/query/ip/3.238.201.74 (on @knollridges.com.ph)
+ || e.contains("spamhaus")
// Transient errors
diff --git a/core/src/util/input_output.rs b/core/src/util/input_output.rs
index 008e75bc..ead265e4 100644
--- a/core/src/util/input_output.rs
+++ b/core/src/util/input_output.rs
@@ -92,10 +92,12 @@ pub struct CheckEmailInput {
pub yahoo_use_api: bool,
/// For Hotmail/Outlook email addresses, use a headless navigator
/// connecting to the password recovery page instead of the SMTP server.
+ /// This assumes you have a WebDriver compatible process running, then pass
+ /// its endpoint, usually http://localhost:4444.
///
- /// Defaults to false.
+ /// Defaults to None.
#[cfg(feature = "headless")]
- pub hotmail_use_headless: bool,
+ pub hotmail_use_headless: Option<String>,
/// Number of retries of SMTP connections to do.
///
/// Defaults to 2 to avoid greylisting.
@@ -113,7 +115,7 @@ impl Default for CheckEmailInput {
from_email: "[email protected]".into(),
hello_name: "localhost".into(),
#[cfg(feature = "headless")]
- hotmail_use_headless: false,
+ hotmail_use_headless: None,
proxy: None,
smtp_port: 25,
smtp_security: SmtpSecurity::Opportunistic,
@@ -226,13 +228,15 @@ impl CheckEmailInput {
self
}
- /// Set whether to use a headless navigator to navigate to Hotmail's
- /// password recovery page to check whether an email exists or not. If set
- /// to true, make sure you have Chrome/Chromium installed locally before
- /// verifying the email.
- /// Defaults to false.
+ /// Set whether or not to use a headless navigator to navigate to Hotmail's
+ /// password recovery page to check if an email exists. If set to
+ /// `Some(<endpoint>)`, this endpoint must point to a WebDriver process,
+ /// usually listening on http://localhost:4444. Defaults to None.
#[cfg(feature = "headless")]
- pub fn set_hotmail_use_headless(&mut self, use_headless: bool) -> &mut CheckEmailInput {
+ pub fn set_hotmail_use_headless(
+ &mut self,
+ use_headless: Option<String>,
+ ) -> &mut CheckEmailInput {
self.hotmail_use_headless = use_headless;
self
}
diff --git a/docker.sh b/docker.sh
new file mode 100755
index 00000000..f42ba237
--- /dev/null
+++ b/docker.sh
@@ -0,0 +1,5 @@
+#!/bin/ash
+
+# https://docs.docker.com/config/containers/multi-service_container/
+MOZ_HEADLESS=1 geckodriver &
+./reacher_backend