Check if an email address exists without sending any email, written in Rust. Comes with a ⚙️ HTTP backend.
Rust emailemail-validationemail-validation-apiemail-verificationemail-verification-apiemail-verifierhacktoberfest
feat: Add back RabbitMQ-based worker (#1513)
Amauryde75eceef32c
diff --git a/.dockerignore b/.dockerignoreindex b81aba98..7638b544 100644--- a/.dockerignore+++ b/.dockerignore@@ -3,5 +3,6 @@.vscodecitarget/-Dockerfile-fly.toml\ No newline at end of file+Dockerfile.*+docs/+.envdiff --git a/.env.example b/.env.exampleindex c72e58fa..80239078 100644--- a/.env.example+++ b/.env.example@@ -1,10 +1,10 @@# Copy this file to .env# ```bash-# cp .env.example+# cp .env.example .env# ```## Then tweak the values to match your desired config.RUST_LOG=reacher=info-SQLX_OFFLINE=1+SQLX_OFFLINE=trueRCH_WEBDRIVER_ADDR=http://localhost:9515diff --git a/.github/workflows/deploy_backend.yml b/.github/workflows/deploy_backend.ymlindex d654843b..754bcf20 100644--- a/.github/workflows/deploy_backend.yml+++ b/.github/workflows/deploy_backend.yml@@ -1,4 +1,4 @@-name: tag+name: deploy_backendon:push:@@ -19,6 +19,7 @@ jobs:uses: elgohr/Publish-Docker-Github-Action@v5with:name: reacherhq/backend+ dockerfile: docker/Dockerfile.backendusername: ${{ secrets.DOCKER_USERNAME }}password: ${{ secrets.DOCKER_PASSWORD }}tags: "${{ steps.vars.outputs.GITHUB_TAG }},beta"diff --git a/.github/workflows/deploy_cli.yml b/.github/workflows/deploy_cli.ymlindex f28c59b0..5dc1586a 100644--- a/.github/workflows/deploy_cli.yml+++ b/.github/workflows/deploy_cli.yml@@ -1,10 +1,10 @@+name: deploy_cli+on:push:- # Sequence of patterns matched against refs/tagstags:- - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10+ - "cli/v*"-name: deploy_clienv:# TODO: Rename to your binaryBIN: check_if_email_existsdiff --git a/.github/workflows/deploy_worker.yml b/.github/workflows/deploy_worker.ymlnew file mode 100644index 00000000..080d546d--- /dev/null+++ b/.github/workflows/deploy_worker.yml@@ -0,0 +1,25 @@+name: deploy_worker++on:+ push:+ tags:+ - "worker/v*.*.*"++jobs:+ docker-publish:+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@master+ - name: Set GITHUB_TAG arg+ id: vars+ run: echo ::set-output name=GITHUB_TAG::${GITHUB_REF:17} # Remove /refs/head/worker/+ - name: Print version+ run: echo "Publishing reacherhq/worker:${{ steps.vars.outputs.GITHUB_TAG }}"+ - name: Publish to Registry+ uses: elgohr/Publish-Docker-Github-Action@v5+ with:+ name: reacherhq/worker+ dockerfile: docker/Dockerfile.worker+ username: ${{ secrets.DOCKER_USERNAME }}+ password: ${{ secrets.DOCKER_PASSWORD }}+ tags: "${{ steps.vars.outputs.GITHUB_TAG }},beta"diff --git a/.github/workflows/pr_cli.yml b/.github/workflows/pr_cli.ymlindex 86cfd625..7fce4ea6 100644--- a/.github/workflows/pr_cli.yml+++ b/.github/workflows/pr_cli.yml@@ -63,6 +63,7 @@ jobs:# - x86_64-apple-ioswindows:+ if: false # Disable Windows tests for now, because Reacher Worker is not supported on Windowsruns-on: windows-latestneeds: install-crosssteps:diff --git a/.sqlx/query-030e82770e9458ee745aa647eba42da57167a810dd708d991e3dfdff32217273.json b/.sqlx/query-030e82770e9458ee745aa647eba42da57167a810dd708d991e3dfdff32217273.jsonnew file mode 100644index 00000000..98395822--- /dev/null+++ b/.sqlx/query-030e82770e9458ee745aa647eba42da57167a810dd708d991e3dfdff32217273.json@@ -0,0 +1,24 @@+{+ "db_name": "PostgreSQL",+ "query": "\n\t\t\t\tINSERT INTO reacher_results (payload, worker, result)\n\t\t\t\tVALUES ($1, $2, $3)\n\t\t\t\tRETURNING id\n\t\t\t\t",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "id",+ "type_info": "Int4"+ }+ ],+ "parameters": {+ "Left": [+ "Jsonb",+ "Text",+ "Jsonb"+ ]+ },+ "nullable": [+ false+ ]+ },+ "hash": "030e82770e9458ee745aa647eba42da57167a810dd708d991e3dfdff32217273"+}diff --git a/.sqlx/query-a1f7a67d3708b8cf74361c33bfdd1dcbe9938a78b6c4ff550336ee4d16eb3ff3.json b/.sqlx/query-a1f7a67d3708b8cf74361c33bfdd1dcbe9938a78b6c4ff550336ee4d16eb3ff3.jsonnew file mode 100644index 00000000..6658bc74--- /dev/null+++ b/.sqlx/query-a1f7a67d3708b8cf74361c33bfdd1dcbe9938a78b6c4ff550336ee4d16eb3ff3.json@@ -0,0 +1,24 @@+{+ "db_name": "PostgreSQL",+ "query": "\n\t\t\t\tINSERT INTO reacher_results (payload, worker, error)\n\t\t\t\tVALUES ($1, $2, $3)\n\t\t\t\tRETURNING id\n\t\t\t\t",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "id",+ "type_info": "Int4"+ }+ ],+ "parameters": {+ "Left": [+ "Jsonb",+ "Text",+ "Text"+ ]+ },+ "nullable": [+ false+ ]+ },+ "hash": "a1f7a67d3708b8cf74361c33bfdd1dcbe9938a78b6c4ff550336ee4d16eb3ff3"+}diff --git a/Cargo.lock b/Cargo.lockindex 5537fe66..e4da53b6 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -17,6 +17,17 @@ version = "1.0.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"+[[package]]+name = "aes"+version = "0.8.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"+dependencies = [+ "cfg-if",+ "cipher",+ "cpufeatures",+]+[[package]]name = "ahash"version = "0.8.11"@@ -45,6 +56,54 @@ version = "0.2.18"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"+[[package]]+name = "amq-protocol"+version = "7.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e3a41c091e49edfcc098b4f90d4d7706a8cf9158034e84ebfee7ff346092f67c"+dependencies = [+ "amq-protocol-tcp",+ "amq-protocol-types",+ "amq-protocol-uri",+ "cookie-factory",+ "nom",+ "serde",+]++[[package]]+name = "amq-protocol-tcp"+version = "7.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3ed7a4a662472f88823ed2fc81babb0b00562f2c54284e3e7bffc02b6df649bf"+dependencies = [+ "amq-protocol-uri",+ "tcp-stream",+ "tracing",+]++[[package]]+name = "amq-protocol-types"+version = "7.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bd6484fdc918c1b6e2ae8eda2914d19a5873e1975f93ad8d33d6a24d1d98df05"+dependencies = [+ "cookie-factory",+ "nom",+ "serde",+ "serde_json",+]++[[package]]+name = "amq-protocol-uri"+version = "7.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7f7f2da69e0e1182765bf33407cd8a843f20791b5af2b57a2645818c4776c56c"+dependencies = [+ "amq-protocol-types",+ "percent-encoding",+ "url",+]+[[package]]name = "android-tzdata"version = "0.1.1"@@ -127,6 +186,155 @@ version = "0.9.3"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "71938f30533e4d95a6d17aa530939da3842c2ab6f4f84b9dae68447e4129f74a"+[[package]]+name = "asn1-rs"+version = "0.6.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5493c3bedbacf7fd7382c6346bbd66687d12bbaad3a89a2d2c303ee6cf20b048"+dependencies = [+ "asn1-rs-derive",+ "asn1-rs-impl",+ "displaydoc",+ "nom",+ "num-traits",+ "rusticata-macros",+ "thiserror",+ "time",+]++[[package]]+name = "asn1-rs-derive"+version = "0.5.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "965c2d33e53cb6b267e148a4cb0760bc01f4904c1cd4bb4002a085bb016d1490"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.66",+ "synstructure",+]++[[package]]+name = "asn1-rs-impl"+version = "0.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.66",+]++[[package]]+name = "async-channel"+version = "2.3.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "89b47800b0be77592da0afd425cc03468052844aff33b84e33cc696f64e77b6a"+dependencies = [+ "concurrent-queue",+ "event-listener-strategy",+ "futures-core",+ "pin-project-lite",+]++[[package]]+name = "async-executor"+version = "1.13.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "30ca9a001c1e8ba5149f91a74362376cc6bc5b919d92d988668657bd570bdcec"+dependencies = [+ "async-task",+ "concurrent-queue",+ "fastrand 2.1.0",+ "futures-lite 2.3.0",+ "slab",+]++[[package]]+name = "async-global-executor"+version = "2.4.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c"+dependencies = [+ "async-channel",+ "async-executor",+ "async-io 2.3.3",+ "async-lock 3.4.0",+ "blocking",+ "futures-lite 2.3.0",+ "once_cell",+]++[[package]]+name = "async-global-executor-trait"+version = "2.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "33dd14c5a15affd2abcff50d84efd4009ada28a860f01c14f9d654f3e81b3f75"+dependencies = [+ "async-global-executor",+ "async-trait",+ "executor-trait",+]++[[package]]+name = "async-io"+version = "1.13.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af"+dependencies = [+ "async-lock 2.8.0",+ "autocfg",+ "cfg-if",+ "concurrent-queue",+ "futures-lite 1.13.0",+ "log",+ "parking",+ "polling 2.8.0",+ "rustix 0.37.27",+ "slab",+ "socket2 0.4.10",+ "waker-fn",+]++[[package]]+name = "async-io"+version = "2.3.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0d6baa8f0178795da0e71bc42c9e5d13261aac7ee549853162e66a241ba17964"+dependencies = [+ "async-lock 3.4.0",+ "cfg-if",+ "concurrent-queue",+ "futures-io",+ "futures-lite 2.3.0",+ "parking",+ "polling 3.7.2",+ "rustix 0.38.34",+ "slab",+ "tracing",+ "windows-sys 0.52.0",+]++[[package]]+name = "async-lock"+version = "2.8.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b"+dependencies = [+ "event-listener 2.5.3",+]++[[package]]+name = "async-lock"+version = "3.4.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18"+dependencies = [+ "event-listener 5.3.1",+ "event-listener-strategy",+ "pin-project-lite",+]+[[package]]name = "async-native-tls"version = "0.4.0"@@ -139,6 +347,18 @@ dependencies = ["url",]+[[package]]+name = "async-reactor-trait"+version = "1.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7a6012d170ad00de56c9ee354aef2e358359deb1ec504254e0e5a3774771de0e"+dependencies = [+ "async-io 1.13.0",+ "async-trait",+ "futures-core",+ "reactor-trait",+]+[[package]]name = "async-recursion"version = "1.1.1"@@ -174,6 +394,12 @@ dependencies = ["tokio",]+[[package]]+name = "async-task"+version = "4.7.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de"+[[package]]name = "async-trait"version = "0.1.80"@@ -280,6 +506,28 @@ dependencies = ["generic-array",]+[[package]]+name = "block-padding"+version = "0.3.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93"+dependencies = [+ "generic-array",+]++[[package]]+name = "blocking"+version = "1.6.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "703f41c54fc768e63e091340b424302bb1c29ef4aa0c7f10fe849dfb114d29ea"+dependencies = [+ "async-channel",+ "async-task",+ "futures-io",+ "futures-lite 2.3.0",+ "piper",+]+[[package]]name = "bufstream"version = "0.1.4"@@ -304,6 +552,15 @@ version = "1.6.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9"+[[package]]+name = "cbc"+version = "0.1.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6"+dependencies = [+ "cipher",+]+[[package]]name = "cc"version = "1.0.99"@@ -374,6 +631,16 @@ dependencies = ["windows-targets 0.52.5",]+[[package]]+name = "cipher"+version = "0.4.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"+dependencies = [+ "crypto-common",+ "inout",+]+[[package]]name = "clap"version = "3.2.25"@@ -413,18 +680,88 @@ dependencies = ["os_str_bytes",]+[[package]]+name = "cms"+version = "0.2.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7b77c319abfd5219629c45c34c89ba945ed3c5e49fcde9d16b6c3885f118a730"+dependencies = [+ "const-oid",+ "der",+ "spki",+ "x509-cert",+]+[[package]]name = "colorchoice"version = "1.0.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0"+[[package]]+name = "concurrent-queue"+version = "2.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973"+dependencies = [+ "crossbeam-utils",+]++[[package]]+name = "config"+version = "0.14.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7328b20597b53c2454f0b1919720c25c7339051c02b72b7e05409e00b14132be"+dependencies = [+ "async-trait",+ "convert_case",+ "json5",+ "lazy_static",+ "nom",+ "pathdiff",+ "ron",+ "rust-ini",+ "serde",+ "serde_json",+ "toml",+ "yaml-rust",+]+[[package]]name = "const-oid"version = "0.9.6"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8"+[[package]]+name = "const-random"+version = "0.1.18"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359"+dependencies = [+ "const-random-macro",+]++[[package]]+name = "const-random-macro"+version = "0.1.16"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e"+dependencies = [+ "getrandom",+ "once_cell",+ "tiny-keccak",+]++[[package]]+name = "convert_case"+version = "0.6.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca"+dependencies = [+ "unicode-segmentation",+]+[[package]]name = "cookie"version = "0.16.2"@@ -446,6 +783,12 @@ dependencies = ["version_check",]+[[package]]+name = "cookie-factory"+version = "0.3.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9885fa71e26b8ab7855e2ec7cae6e9b380edff76cd052e07c683a0319d51b3a2"+[[package]]name = "core-foundation"version = "0.9.4"@@ -501,6 +844,12 @@ version = "0.8.20"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"+[[package]]+name = "crunchy"+version = "0.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"+[[package]]name = "crypto-common"version = "0.1.6"@@ -590,10 +939,37 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0"dependencies = ["const-oid",+ "der_derive",+ "flagset","pem-rfc7468","zeroize",]+[[package]]+name = "der-parser"+version = "9.0.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5cd0a5c643689626bec213c4d8bd4d96acc8ffdb4ad4bb6bc16abf27d5f4b553"+dependencies = [+ "asn1-rs",+ "displaydoc",+ "nom",+ "num-bigint",+ "num-traits",+ "rusticata-macros",+]++[[package]]+name = "der_derive"+version = "0.7.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8034092389675178f570469e6c3b0465d3d30b4505c294a6550db47f3c17ad18"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.66",+]+[[package]]name = "deranged"version = "0.3.11"@@ -628,6 +1004,15 @@ dependencies = ["syn 1.0.109",]+[[package]]+name = "des"+version = "0.8.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ffdd80ce8ce993de27e9f063a444a4d53ce8e8db4c1f00cc03af5ad5a9867a1e"+dependencies = [+ "cipher",+]+[[package]]name = "digest"version = "0.10.7"@@ -651,6 +1036,21 @@ dependencies = ["syn 2.0.66",]+[[package]]+name = "dlv-list"+version = "0.5.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "442039f5147480ba31067cb00ada1adae6892028e40e45fc5de7b7df6dcc1b5f"+dependencies = [+ "const-random",+]++[[package]]+name = "doc-comment"+version = "0.3.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"+[[package]]name = "dotenv"version = "0.15.0"@@ -749,6 +1149,36 @@ version = "2.5.3"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0"+[[package]]+name = "event-listener"+version = "5.3.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba"+dependencies = [+ "concurrent-queue",+ "parking",+ "pin-project-lite",+]++[[package]]+name = "event-listener-strategy"+version = "0.5.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1"+dependencies = [+ "event-listener 5.3.1",+ "pin-project-lite",+]++[[package]]+name = "executor-trait"+version = "2.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1a1052dd43212a7777ec6a69b117da52f5e52f07aec47d00c1a2b33b85d06b08"+dependencies = [+ "async-trait",+]+[[package]]name = "fantoccini"version = "0.21.2"@@ -810,12 +1240,27 @@ dependencies = ["ascii_utils",]+[[package]]+name = "fastrand"+version = "1.9.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be"+dependencies = [+ "instant",+]+[[package]]name = "fastrand"version = "2.1.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a"+[[package]]+name = "flagset"+version = "0.4.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b3ea1ec5f8307826a5b71094dd91fc04d4ae75d5709b20ad351c7fb4815c86ec"+[[package]]name = "flume"version = "0.11.0"@@ -916,6 +1361,34 @@ version = "0.3.30"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1"+[[package]]+name = "futures-lite"+version = "1.13.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce"+dependencies = [+ "fastrand 1.9.0",+ "futures-core",+ "futures-io",+ "memchr",+ "parking",+ "pin-project-lite",+ "waker-fn",+]++[[package]]+name = "futures-lite"+version = "2.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5"+dependencies = [+ "fastrand 2.1.0",+ "futures-core",+ "futures-io",+ "parking",+ "pin-project-lite",+]+[[package]]name = "futures-macro"version = "0.3.30"@@ -1028,6 +1501,12 @@ version = "0.12.3"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"+[[package]]+name = "hashbrown"+version = "0.13.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"+[[package]]name = "hashbrown"version = "0.14.5"@@ -1095,6 +1574,12 @@ version = "0.3.9"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"+[[package]]+name = "hermit-abi"+version = "0.4.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc"+[[package]]name = "hex"version = "0.4.3"@@ -1275,7 +1760,7 @@ dependencies = ["httpdate","itoa","pin-project-lite",- "socket2",+ "socket2 0.5.7","tokio","tower-service","tracing",@@ -1361,7 +1846,7 @@ dependencies = ["http-body 1.0.0","hyper 1.3.1","pin-project-lite",- "socket2",+ "socket2 0.5.7","tokio","tower","tower-service",@@ -1557,13 +2042,43 @@ dependencies = ["hashbrown 0.14.5",]+[[package]]+name = "inout"+version = "0.1.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5"+dependencies = [+ "block-padding",+ "generic-array",+]++[[package]]+name = "instant"+version = "0.1.13"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222"+dependencies = [+ "cfg-if",+]++[[package]]+name = "io-lifetimes"+version = "1.0.11"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2"+dependencies = [+ "hermit-abi 0.3.9",+ "libc",+ "windows-sys 0.48.0",+]+[[package]]name = "ipconfig"version = "0.3.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f"dependencies = [- "socket2",+ "socket2 0.5.7","widestring","windows-sys 0.48.0","winreg 0.50.0",@@ -1596,6 +2111,39 @@ dependencies = ["wasm-bindgen",]+[[package]]+name = "json5"+version = "0.4.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "96b0db21af676c1ce64250b5f40f3ce2cf27e4e47cb91ed91eb6fe9350b430c1"+dependencies = [+ "pest",+ "pest_derive",+ "serde",+]++[[package]]+name = "lapin"+version = "2.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "209b09a06f4bd4952a0fd0594f90d53cf4496b062f59acc838a2823e1bb7d95c"+dependencies = [+ "amq-protocol",+ "async-global-executor-trait",+ "async-reactor-trait",+ "async-trait",+ "executor-trait",+ "flume",+ "futures-core",+ "futures-io",+ "parking_lot",+ "pinky-swear",+ "reactor-trait",+ "serde",+ "tracing",+ "waker-fn",+]+[[package]]name = "lazy_static"version = "1.4.0"@@ -1640,6 +2188,12 @@ version = "0.5.6"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"+[[package]]+name = "linux-raw-sys"+version = "0.3.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519"+[[package]]name = "linux-raw-sys"version = "0.4.14"@@ -1812,6 +2366,16 @@ dependencies = ["winapi",]+[[package]]+name = "num-bigint"+version = "0.4.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9"+dependencies = [+ "num-integer",+ "num-traits",+]+[[package]]name = "num-bigint-dig"version = "0.8.4"@@ -1884,6 +2448,15 @@ dependencies = ["memchr",]+[[package]]+name = "oid-registry"+version = "0.7.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a8d8034d9489cdaf79228eb9f6a3b8d7bb32ba00d6645ebd48eef4077ceb5bd9"+dependencies = [+ "asn1-rs",+]+[[package]]name = "once_cell"version = "1.19.0"@@ -1944,6 +2517,16 @@ dependencies = ["vcpkg",]+[[package]]+name = "ordered-multimap"+version = "0.6.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4ed8acf08e98e744e5384c8bc63ceb0364e68a6854187221c18df61c4797690e"+dependencies = [+ "dlv-list",+ "hashbrown 0.13.2",+]+[[package]]name = "os_str_bytes"version = "6.6.1"@@ -1956,6 +2539,34 @@ version = "0.1.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"+[[package]]+name = "p12-keystore"+version = "0.1.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "df7b60d0b2dcace322e6e8c4499c4c8bdf331c1bae046a54be5e4191c3610286"+dependencies = [+ "cbc",+ "cms",+ "der",+ "des",+ "hex",+ "hmac",+ "pkcs12",+ "pkcs5",+ "rand",+ "rc2",+ "sha1 0.10.6",+ "sha2",+ "thiserror",+ "x509-parser",+]++[[package]]+name = "parking"+version = "2.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba"+[[package]]name = "parking_lot"version = "0.12.3"@@ -1985,6 +2596,22 @@ version = "1.0.15"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"+[[package]]+name = "pathdiff"+version = "0.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd"++[[package]]+name = "pbkdf2"+version = "0.12.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2"+dependencies = [+ "digest",+ "hmac",+]+[[package]]name = "pem-rfc7468"version = "0.7.0"@@ -2000,6 +2627,51 @@ version = "2.3.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"+[[package]]+name = "pest"+version = "2.7.13"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fdbef9d1d47087a895abd220ed25eb4ad973a5e26f6a4367b038c25e28dfc2d9"+dependencies = [+ "memchr",+ "thiserror",+ "ucd-trie",+]++[[package]]+name = "pest_derive"+version = "2.7.13"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4d3a6e3394ec80feb3b6393c725571754c6188490265c61aaf260810d6b95aa0"+dependencies = [+ "pest",+ "pest_generator",+]++[[package]]+name = "pest_generator"+version = "2.7.13"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "94429506bde1ca69d1b5601962c73f4172ab4726571a59ea95931218cb0e930e"+dependencies = [+ "pest",+ "pest_meta",+ "proc-macro2",+ "quote",+ "syn 2.0.66",+]++[[package]]+name = "pest_meta"+version = "2.7.13"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ac8a071862e93690b6e34e9a5fb8e33ff3734473ac0245b27232222c4906a33f"+dependencies = [+ "once_cell",+ "pest",+ "sha2",+]+[[package]]name = "pin-project"version = "1.1.5"@@ -2032,6 +2704,29 @@ version = "0.1.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"+[[package]]+name = "pinky-swear"+version = "6.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6cfae3ead413ca051a681152bd266438d3bfa301c9bdf836939a14c721bb2a21"+dependencies = [+ "doc-comment",+ "flume",+ "parking_lot",+ "tracing",+]++[[package]]+name = "piper"+version = "0.2.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "96c8c490f422ef9a4efd2cb5b42b76c8613d7e7dfc1caf667b8a3350a5acc066"+dependencies = [+ "atomic-waker",+ "fastrand 2.1.0",+ "futures-io",+]+[[package]]name = "pkcs1"version = "0.7.5"@@ -2043,6 +2738,36 @@ dependencies = ["spki",]+[[package]]+name = "pkcs12"+version = "0.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "695b3df3d3cc1015f12d70235e35b6b79befc5fa7a9b95b951eab1dd07c9efc2"+dependencies = [+ "cms",+ "const-oid",+ "der",+ "digest",+ "spki",+ "x509-cert",+ "zeroize",+]++[[package]]+name = "pkcs5"+version = "0.7.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e847e2c91a18bfa887dd028ec33f2fe6f25db77db3619024764914affe8b69a6"+dependencies = [+ "aes",+ "cbc",+ "der",+ "pbkdf2",+ "scrypt",+ "sha2",+ "spki",+]+[[package]]name = "pkcs8"version = "0.10.2"@@ -2059,6 +2784,37 @@ version = "0.3.30"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"+[[package]]+name = "polling"+version = "2.8.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce"+dependencies = [+ "autocfg",+ "bitflags 1.3.2",+ "cfg-if",+ "concurrent-queue",+ "libc",+ "log",+ "pin-project-lite",+ "windows-sys 0.48.0",+]++[[package]]+name = "polling"+version = "3.7.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a3ed00ed3fbf728b5816498ecd316d1716eecaced9c0c8d2c5a6740ca214985b"+dependencies = [+ "cfg-if",+ "concurrent-queue",+ "hermit-abi 0.4.0",+ "pin-project-lite",+ "rustix 0.38.34",+ "tracing",+ "windows-sys 0.52.0",+]+[[package]]name = "powerfmt"version = "0.2.0"@@ -2164,6 +2920,15 @@ dependencies = ["getrandom",]+[[package]]+name = "rc2"+version = "0.8.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "62c64daa8e9438b84aaae55010a93f396f8e60e3911590fcba770d04643fc1dd"+dependencies = [+ "cipher",+]+[[package]]name = "reacher_backend"version = "0.7.0"@@ -2185,6 +2950,40 @@ dependencies = ["warp",]+[[package]]+name = "reacher_worker"+version = "0.1.0"+dependencies = [+ "async-smtp",+ "check-if-email-exists",+ "config",+ "futures-lite 2.3.0",+ "lapin",+ "openssl",+ "reqwest 0.12.5",+ "sentry",+ "serde",+ "serde_json",+ "sqlx",+ "sqlxmq",+ "tokio",+ "tokio-executor-trait",+ "tokio-reactor-trait",+ "tracing",+ "tracing-subscriber",+]++[[package]]+name = "reactor-trait"+version = "1.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "438a4293e4d097556730f4711998189416232f009c137389e0f961d2bc0ddc58"+dependencies = [+ "async-trait",+ "futures-core",+ "futures-io",+]+[[package]]name = "redox_syscall"version = "0.4.1"@@ -2341,6 +3140,18 @@ dependencies = ["windows-sys 0.52.0",]+[[package]]+name = "ron"+version = "0.8.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94"+dependencies = [+ "base64 0.21.7",+ "bitflags 2.5.0",+ "serde",+ "serde_derive",+]+[[package]]name = "rsa"version = "0.9.6"@@ -2361,6 +3172,16 @@ dependencies = ["zeroize",]+[[package]]+name = "rust-ini"+version = "0.19.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7e2a3bcec1f113553ef1c88aae6c020a369d03d55b58de9869a0908930385091"+dependencies = [+ "cfg-if",+ "ordered-multimap",+]+[[package]]name = "rustc-demangle"version = "0.1.24"@@ -2376,6 +3197,29 @@ dependencies = ["semver",]+[[package]]+name = "rusticata-macros"+version = "4.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "faf0c4a6ece9950b9abdb62b1cfcf2a68b3b67a10ba445b3bb85be2a293d0632"+dependencies = [+ "nom",+]++[[package]]+name = "rustix"+version = "0.37.27"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2"+dependencies = [+ "bitflags 1.3.2",+ "errno",+ "io-lifetimes",+ "libc",+ "linux-raw-sys 0.3.8",+ "windows-sys 0.48.0",+]+[[package]]name = "rustix"version = "0.38.34"@@ -2385,7 +3229,7 @@ dependencies = ["bitflags 2.5.0","errno","libc",- "linux-raw-sys",+ "linux-raw-sys 0.4.14","windows-sys 0.52.0",]@@ -2396,12 +3240,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "05cff451f60db80f490f3c182b77c35260baace73209e9cdbbe526bfe3a4d402"dependencies = ["once_cell",+ "ring","rustls-pki-types","rustls-webpki","subtle","zeroize",]+[[package]]+name = "rustls-connector"+version = "0.20.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2a980454b497c439c274f2feae2523ed8138bbd3d323684e1435fec62f800481"+dependencies = [+ "log",+ "rustls",+ "rustls-native-certs",+ "rustls-pki-types",+ "rustls-webpki",+]++[[package]]+name = "rustls-native-certs"+version = "0.7.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e5bfb394eeed242e909609f56089eecfe5fda225042e8b171791b9c95f5931e5"+dependencies = [+ "openssl-probe",+ "rustls-pemfile 2.1.2",+ "rustls-pki-types",+ "schannel",+ "security-framework",+]+[[package]]name = "rustls-pemfile"version = "1.0.4"@@ -2444,6 +3315,15 @@ version = "1.0.18"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"+[[package]]+name = "salsa20"+version = "0.10.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213"+dependencies = [+ "cipher",+]+[[package]]name = "schannel"version = "0.1.23"@@ -2465,6 +3345,17 @@ version = "1.2.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"+[[package]]+name = "scrypt"+version = "0.11.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0516a385866c09368f0b5bcd1caff3366aace790fcd46e2bb032697bb172fd1f"+dependencies = [+ "pbkdf2",+ "salsa20",+ "sha2",+]+[[package]]name = "security-framework"version = "2.11.0"@@ -2607,6 +3498,15 @@ dependencies = ["serde",]+[[package]]+name = "serde_spanned"+version = "0.6.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1"+dependencies = [+ "serde",+]+[[package]]name = "serde_urlencoded"version = "0.7.1"@@ -2699,6 +3599,16 @@ version = "1.13.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"+[[package]]+name = "socket2"+version = "0.4.10"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d"+dependencies = [+ "libc",+ "winapi",+]+[[package]]name = "socket2"version = "0.5.7"@@ -2771,7 +3681,7 @@ dependencies = ["crc","crossbeam-queue","either",- "event-listener",+ "event-listener 2.5.3","futures-channel","futures-core","futures-intrusive",@@ -3077,6 +3987,18 @@ dependencies = ["libc",]+[[package]]+name = "tcp-stream"+version = "0.28.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "495b0abdce3dc1f8fd27240651c9e68890c14e9d9c61527b1ce44d8a5a7bd3d5"+dependencies = [+ "cfg-if",+ "p12-keystore",+ "rustls-connector",+ "rustls-pemfile 2.1.2",+]+[[package]]name = "tempfile"version = "3.10.1"@@ -3084,8 +4006,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1"dependencies = ["cfg-if",- "fastrand",- "rustix",+ "fastrand 2.1.0",+ "rustix 0.38.34","windows-sys 0.52.0",]@@ -3165,6 +4087,15 @@ dependencies = ["time-core",]+[[package]]+name = "tiny-keccak"+version = "2.0.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237"+dependencies = [+ "crunchy",+]+[[package]]name = "tinystr"version = "0.7.6"@@ -3204,11 +4135,22 @@ dependencies = ["parking_lot","pin-project-lite","signal-hook-registry",- "socket2",+ "socket2 0.5.7","tokio-macros","windows-sys 0.48.0",]+[[package]]+name = "tokio-executor-trait"+version = "2.1.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "802ccf58e108fe16561f35348fabe15ff38218968f033d587e399a84937533cc"+dependencies = [+ "async-trait",+ "executor-trait",+ "tokio",+]+[[package]]name = "tokio-macros"version = "2.3.0"@@ -3230,6 +4172,20 @@ dependencies = ["tokio",]+[[package]]+name = "tokio-reactor-trait"+version = "1.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e9481a72f36bd9cbb8d6dd349227c4783e234e4332cfe806225bc929c4b92486"+dependencies = [+ "async-trait",+ "futures-core",+ "futures-io",+ "reactor-trait",+ "tokio",+ "tokio-stream",+]+[[package]]name = "tokio-rustls"version = "0.26.0"@@ -3289,6 +4245,40 @@ dependencies = ["tokio",]+[[package]]+name = "toml"+version = "0.8.19"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e"+dependencies = [+ "serde",+ "serde_spanned",+ "toml_datetime",+ "toml_edit",+]++[[package]]+name = "toml_datetime"+version = "0.6.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41"+dependencies = [+ "serde",+]++[[package]]+name = "toml_edit"+version = "0.22.20"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d"+dependencies = [+ "indexmap 2.2.6",+ "serde",+ "serde_spanned",+ "toml_datetime",+ "winnow",+]+[[package]]name = "tower"version = "0.4.13"@@ -3405,6 +4395,12 @@ version = "1.17.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"+[[package]]+name = "ucd-trie"+version = "0.1.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971"+[[package]]name = "uname"version = "0.1.1"@@ -3547,6 +4543,12 @@ version = "0.9.4"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"+[[package]]+name = "waker-fn"+version = "1.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "317211a0dc0ceedd78fb2ca9a44aed3d7b9b26f81870d485c07122b4350673b7"+[[package]]name = "want"version = "0.3.1"@@ -3888,6 +4890,15 @@ version = "0.52.5"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"+[[package]]+name = "winnow"+version = "0.6.20"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b"+dependencies = [+ "memchr",+]+[[package]]name = "winreg"version = "0.50.0"@@ -3920,6 +4931,43 @@ version = "0.5.5"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51"+[[package]]+name = "x509-cert"+version = "0.2.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1301e935010a701ae5f8655edc0ad17c44bad3ac5ce8c39185f75453b720ae94"+dependencies = [+ "const-oid",+ "der",+ "spki",+]++[[package]]+name = "x509-parser"+version = "0.16.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fcbc162f30700d6f3f82a24bf7cc62ffe7caea42c0b2cba8bf7f3ae50cf51f69"+dependencies = [+ "asn1-rs",+ "data-encoding",+ "der-parser",+ "lazy_static",+ "nom",+ "oid-registry",+ "rusticata-macros",+ "thiserror",+ "time",+]++[[package]]+name = "yaml-rust"+version = "0.4.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85"+dependencies = [+ "linked-hash-map",+]+[[package]]name = "yoke"version = "0.7.4"diff --git a/Cargo.toml b/Cargo.tomlindex 861920f1..9f2b30d7 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -1,2 +1,2 @@[workspace]-members = ["backend", "cli", "core"]+members = ["backend", "cli", "core", "worker"]diff --git a/backend/.env.example b/backend/.env.examplenew file mode 100644index 00000000..fd3aaae5--- /dev/null+++ b/backend/.env.example@@ -0,0 +1,8 @@+# Copy this file to .env+# ```bash+# cp .env.example .env+# ```+#+# Then tweak the values to match your desired config.++DATABASE_URL=postgresql://localhost:5432/reacherdbdiff --git a/docker-compose.yaml b/docker-compose.yamlnew file mode 100644index 00000000..3402f5c0--- /dev/null+++ b/docker-compose.yaml@@ -0,0 +1,52 @@+version: "3.8"++services:+ rabbitmq:+ image: rabbitmq:4.0-management+ container_name: rabbitmq+ ports:+ - "5672:5672"+ - "15672:15672"+ environment:+ RABBITMQ_DEFAULT_USER: guest+ RABBITMQ_DEFAULT_PASS: guest++ postgres:+ image: postgres:17+ container_name: postgres+ ports:+ - "5432:5432"+ environment:+ POSTGRES_USER: postgres+ POSTGRES_PASSWORD: postgres+ POSTGRES_DB: reacher_worker_db++ worker1:+ build:+ context: .+ dockerfile: docker/Dockerfile.worker+ container_name: worker1+ depends_on:+ - postgres+ - rabbitmq+ environment:+ RCH_NAME: worker1+ RCH_RABBITMQ_URL: amqp://guest:guest@rabbitmq:5672+ RCH_RABBITMQ_QUEUE: check.Headless.*+ RCH_DB_URL: postgres://postgres:postgres@postgres:5432/reacher_worker_db+ restart: always++ worker2:+ build:+ context: .+ dockerfile: docker/Dockerfile.worker+ container_name: worker2+ depends_on:+ - postgres+ - rabbitmq+ environment:+ RCH_NAME: worker2+ RCH_RABBITMQ_URL: amqp://guest:guest@rabbitmq:5672+ RCH_RABBITMQ_QUEUE: check.*+ RCH_DB_URL: postgres://postgres:postgres@postgres:5432/reacher_worker_db+ restart: alwaysdiff --git a/Dockerfile b/docker/Dockerfile.backendsimilarity index 88%rename from Dockerfilerename to docker/Dockerfile.backendindex 384b1544..7ddbfc21 100644--- a/Dockerfile+++ b/docker/Dockerfile.backend@@ -31,10 +31,11 @@ USER rootRUN apk add --no-cache chromium-chromedriverCOPY --from=cargo-build /usr/src/reacher/target/x86_64-unknown-linux-musl/release/reacher_backend .-COPY --from=cargo-build /usr/src/reacher/docker.sh .+COPY --from=cargo-build /usr/src/reacher/docker/backend.sh .+COPY --from=cargo-build /usr/src/reacher/docker/wait-for-it.sh .RUN chown chrome:chrome reacher_backend-RUN chown chrome:chrome docker.sh+RUN chown chrome:chrome backend.sh# User chrome was created in zenika/alpine-chromeUSER chrome@@ -50,4 +51,4 @@ EXPOSE 8080# https://stackoverflow.com/questions/40122152/how-to-remove-entrypoint-from-parent-image-on-dockerfileENTRYPOINT []-CMD ["./docker.sh"]+CMD ["./backend.sh"]diff --git a/docker/Dockerfile.worker b/docker/Dockerfile.workernew file mode 100644index 00000000..f2fc39b1--- /dev/null+++ b/docker/Dockerfile.worker@@ -0,0 +1,54 @@+# From https://shaneutt.com/blog/rust-fast-small-docker-image-builds/++# ------------------------------------------------------------------------------+# Cargo Build Stage+# ------------------------------------------------------------------------------++FROM messense/rust-musl-cross:x86_64-musl as cargo-build++WORKDIR /usr/src/reacher++RUN rm -f target/x86_64-unknown-linux-musl/release/deps/reacher*++COPY . .++ENV SQLX_OFFLINE=true++RUN cargo build --bin reacher_worker --release --target=x86_64-unknown-linux-musl++# ------------------------------------------------------------------------------+# Final Stage+# ------------------------------------------------------------------------------++FROM zenika/alpine-chrome++WORKDIR /home/reacher/++USER root++# Install chromedriver+# https://github.com/Zenika/alpine-chrome/blob/master/with-chromedriver/Dockerfile+RUN apk add --no-cache chromium-chromedriver++COPY --from=cargo-build /usr/src/reacher/target/x86_64-unknown-linux-musl/release/reacher_worker .+COPY --from=cargo-build /usr/src/reacher/docker/worker.sh .+COPY --from=cargo-build /usr/src/reacher/worker/worker_config.toml .++RUN chown chrome:chrome reacher_worker+RUN chown chrome:chrome worker.sh++# User chrome was created in zenika/alpine-chrome+USER chrome++ENV RUST_LOG=reacher=info+ENV RCH_HTTP_HOST=0.0.0.0+ENV PORT=8080+ENV RCH_WEBDRIVER_ADDR=http://localhost:9515++EXPOSE 8080++# Remove entrypoint from parent Docker file+# https://stackoverflow.com/questions/40122152/how-to-remove-entrypoint-from-parent-image-on-dockerfile+ENTRYPOINT []++CMD ["./worker.sh"]diff --git a/docker.sh b/docker/backend.shsimilarity index 100%rename from docker.shrename to docker/backend.shdiff --git a/docker/worker.sh b/docker/worker.shnew file mode 100755index 00000000..ba37a5b2--- /dev/null+++ b/docker/worker.sh@@ -0,0 +1,7 @@+#!/bin/ash++# This is the Dockerfile's entrypoint script.++# https://docs.docker.com/config/containers/multi-service_container/+chromedriver &+./reacher_workerdiff --git a/worker/.env.example b/worker/.env.examplenew file mode 100644index 00000000..41ef7540--- /dev/null+++ b/worker/.env.example@@ -0,0 +1,8 @@+# Copy this file to .env+# ```bash+# cp .env.example .env+# ```+#+# Then tweak the values to match your desired config.++DATABASE_URL=postgresql://localhost:5432/reacher_worker_dbdiff --git a/worker/Cargo.toml b/worker/Cargo.tomlnew file mode 100644index 00000000..0338010e--- /dev/null+++ b/worker/Cargo.toml@@ -0,0 +1,30 @@+[package]+name = "reacher_worker"+version = "0.1.0"+edition = "2021"++[dependencies]+config = { version = "0.14.0", features = ["toml"] }+futures-lite = "2.3.0"+lapin = { version = "2.3.1" }+tokio-executor-trait = { version = "2.1.1" }+tokio-reactor-trait = { version = "1.1.0" }+async-smtp = "0.6"+check-if-email-exists = { path = "../core", features = ["headless", "sentry"] }+openssl = { version = "0.10.64", features = ["vendored"] }+reqwest = { version = "0.12.5", features = ["json", "socks"] }+sentry = "0.23"+serde = { version = "1.0", features = ["derive"] }+serde_json = "1.0"+sqlx = { version = "0.7", features = [+ "runtime-tokio-native-tls",+ "postgres",+ "uuid",+ "chrono",+ "json",+ "migrate",+] }+sqlxmq = "0.5"+tokio = { version = "1.35", features = ["macros"] }+tracing = "0.1.40"+tracing-subscriber = "0.3.18"diff --git a/worker/README.md b/worker/README.mdnew file mode 100644index 00000000..1bd732aa--- /dev/null+++ b/worker/README.md@@ -0,0 +1,28 @@+[](https://hub.docker.com/r/reacherhq/worker)+[](https://github.com/reacherhq/check-if-email-exists/actions)++<br /><br />++<p align="center"><img align="center" src="https://storage.googleapis.com/saasify-uploads-prod/696e287ad79f0e0352bc201b36d701849f7d55e7.svg" height="96" alt="reacher" /></p>+<h1 align="center">⚙️ Reacher Task Queue</h1>+<h4 align="center">Architecture for distributing tasks from a queue to multiple Reacher workers.</h4>++<br /><br />++## Get Started++The easiest way to get started is with Docker Compose. This setup runs one queue and two Reacher Workers. From the **root** folder, run:++```bash+docker compose up --build+# Wait for everything to run correctly+```++Then, publish some email verification requests to the RabbitMQ queue:++```bash+cd worker+cargo run -p reacher_worker --bin publish_message <email1> <email2> ...+```++The Docker Compose logs will show the two workers sharing the email verifications. You may ask [email protected] about other methods for publishing messages to this queue (JavaScript, Python...).diff --git a/worker/migrations/20240929230957_init.sql b/worker/migrations/20240929230957_init.sqlnew file mode 100644index 00000000..479f6dbf--- /dev/null+++ b/worker/migrations/20240929230957_init.sql@@ -0,0 +1,9 @@+-- Add migration script here+CREATE TABLE reacher_results (+ id SERIAL NOT NULL PRIMARY KEY,+ payload jsonb NOT NULL,+ worker TEXT NOT NULL,+ result jsonb,+ error TEXT,+ created_at TIMESTAMPTZ DEFAULT NOW()+);diff --git a/worker/migrations/README.md b/worker/migrations/README.mdnew file mode 100644index 00000000..c7b70443--- /dev/null+++ b/worker/migrations/README.md@@ -0,0 +1,11 @@+# Database and Migrations++## Migrations++All migrations in this folder are embedded directly in the `reacher_backend` binary, so you don't need to run the migrations manually.++## Advanced Usage++For more advanced usage (such as reverting to an old state), please use the `sqlx` CLI command.++See https://github.com/launchbadge/sqlx/blob/main/sqlx-cli/README.mddiff --git a/worker/src/bin/publish_message.rs b/worker/src/bin/publish_message.rsnew file mode 100644index 00000000..3855cfd9--- /dev/null+++ b/worker/src/bin/publish_message.rs@@ -0,0 +1,40 @@+use check_if_email_exists::CheckEmailInput;+use lapin::{options::*, BasicProperties};+use reacher_worker::check_email::WorkerPayload;+use reacher_worker::config::load_config;+use reacher_worker::worker::setup_rabbit_mq;+use std::env;++#[tokio::main]+async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {+ let worker_config = load_config()?;+ let channel = setup_rabbit_mq(&worker_config).await?;++ let payloads: Vec<WorkerPayload> = env::args()+ .skip(1) // Path to the binary+ .map(|s| WorkerPayload {+ input: CheckEmailInput {+ to_email: s,+ ..Default::default()+ },+ extra: None,+ })+ .collect();++ for payload in payloads {+ let payload_bz = serde_json::to_vec(&payload)?;+ channel+ .basic_publish(+ "",+ "check.*",+ BasicPublishOptions::default(),+ &payload_bz,+ BasicProperties::default(),+ )+ .await?;++ println!("Published message: {:?}", payload.input.to_email);+ }++ Ok(())+}diff --git a/worker/src/check_email.rs b/worker/src/check_email.rsnew file mode 100644index 00000000..5dab15be--- /dev/null+++ b/worker/src/check_email.rs@@ -0,0 +1,124 @@+// Reacher - Email Verification+// Copyright (C) 2018-2023 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 crate::config::WorkerConfig;+use crate::db::save_to_db;+use check_if_email_exists::{check_email, CheckEmailInput, CheckEmailOutput};+use check_if_email_exists::{Reachable, LOG_TARGET};+use lapin::message::Delivery;+use lapin::{options::*, BasicProperties, Channel};+use serde::{Deserialize, Serialize};+use sqlx::PgPool;+use std::fmt::Debug;+use std::sync::Arc;+use tracing::{debug, info};++#[derive(Debug, Deserialize, Serialize)]+pub struct WorkerPayload {+ pub input: CheckEmailInput,+ pub extra: Option<serde_json::Value>,+}++#[derive(Debug, Serialize)]+struct WebhookOutput<'a> {+ output: &'a CheckEmailOutput,+ extra: &'a Option<serde_json::Value>,+}++/// Processes the check email task asynchronously.+pub async fn process_queue_message(+ payload: &WorkerPayload,+ delivery: Delivery,+ channel: Arc<Channel>,+ pg_pool: PgPool,+ config: WorkerConfig,+) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {+ let worker_output = process_check_email(&payload, delivery, channel, config.clone()).await;+ save_to_db(pg_pool, config, payload, worker_output).await+}++async fn process_check_email(+ payload: &WorkerPayload,+ delivery: Delivery,+ channel: Arc<Channel>,+ config: WorkerConfig,+) -> Result<CheckEmailOutput, Box<dyn std::error::Error + Send + Sync>> {+ info!(target: LOG_TARGET, email=payload.input.to_email, "Start email verification");++ let output = check_email(&payload.input).await;+ let reply_payload = serde_json::to_string(&output)?;+ let reply_payload = reply_payload.as_bytes();++ // Send reply by following this guide:+ // https://www.rabbitmq.com/tutorials/tutorial-six-javascript.html+ if let (Some(reply_to), Some(correlation_id)) = (+ delivery.properties.reply_to(),+ delivery.properties.correlation_id(),+ ) {+ let properties = BasicProperties::default()+ .with_correlation_id(correlation_id.to_owned())+ .with_content_type("application/json".into());++ channel+ .basic_publish(+ "",+ reply_to.as_str(),+ BasicPublishOptions::default(),+ reply_payload,+ properties,+ )+ .await?+ .await?;++ debug!(target: LOG_TARGET, reply_to=?reply_to, correlation_id=?correlation_id, "Sent reply")+ }++ // Check if we have a webhook to send the output to.+ if let Some(webhook_url) = &config.webhook.url {+ let webhook_output = WebhookOutput {+ output: &output,+ extra: &payload.extra,+ };++ let client = reqwest::Client::new();+ let res = client+ .post(webhook_url)+ .json(&webhook_output)+ .header("x-reacher-secret", std::env::var("RCH_HEADER_SECRET")?)+ .send()+ .await?+ .text()+ .await?;+ debug!(target: LOG_TARGET, email=?webhook_output.output.input,res=?res, "Received webhook response");+ }++ let is_reachable = output.is_reachable.to_owned();++ // If is_reachable is unknown, then we requeue the message, but only once.+ // We might want to add a requeue counter in the future, see:+ // https://stackoverflow.com/questions/25226080/rabbitmq-how-to-requeue-message-with-counter+ if is_reachable == Reachable::Unknown && !delivery.redelivered {+ delivery+ .reject(BasicRejectOptions { requeue: true })+ .await?;+ info!(target: LOG_TARGET, email=?&payload.input.to_email, "Requeued message");+ } else {+ delivery.ack(BasicAckOptions::default()).await?;+ info!(target: LOG_TARGET, email=output.input, is_reachable=?output.is_reachable, "Done check");+ }++ Ok(output)+}diff --git a/worker/src/config.rs b/worker/src/config.rsnew file mode 100644index 00000000..3ae5e80d--- /dev/null+++ b/worker/src/config.rs@@ -0,0 +1,160 @@+use config::Config;+use serde::de::{self, Deserializer, Visitor};+use serde::Deserialize;+use std::fmt;++#[derive(Debug, Deserialize, Clone)]+pub struct WorkerConfig {+ /// Name of the worker.+ pub name: String,+ pub rabbitmq: RabbitMQConfig,+ pub throttle: ThrottleConfig,+ pub db: DBConfig,+ pub webhook: WebhookConfig,+}++#[derive(Debug, Deserialize, Clone)]+pub struct RabbitMQConfig {+ pub url: String,+ /// Queue name to consume messages from.+ ///+ /// The queue name MUST be one of the following:+ /// - "check.Smtp.gmail": verifies any Gmail email, using SMTP.+ /// - "check.Smtp.yahoo": verifies any Yahoo email, using SMTP.+ /// - "check.Smtp.hotmail.b2b": verifies any B2B Hotmail email, using SMTP.+ /// - "check.Smtp.hotmail.b2c": verifies any B2C Hotmail email (@outlook, @live, @hotmail), using SMTP.+ /// - "check.Smtp.hotmail.*": verifies any Hotmail email, using SMTP.+ /// - "check.Smtp.*": verifies any email, using SMTP.+ /// - "check.Headless.yahoo": verifies any Yahoo email, using a headless browser.+ /// - "check.Headless.hotmail.b2c": verifies any B2C Hotmail email (@outlook, @live, @hotmail) email, using a headless browser.+ /// - "check.Headless.*": verifies any email, using a headless browser.+ /// - "check.*": verifies any email, using the default method.+ pub queue: Queue,+ pub concurrency: u16,+}++/// Queue names that the worker can consume from.+#[derive(Debug, Clone)]+pub enum Queue {+ /// Verifies any Gmail email, using SMTP.+ SmtpGmail,+ /// Verifies any Yahoo email, using SMTP.+ SmtpYahoo,+ /// Verifies any B2B Hotmail email, using SMTP.+ SmtpHotmailB2B,+ /// Verifies any B2C Hotmail email (@outlook, @live, @hotmail), using SMTP.+ SmtpHotmailB2C,+ /// Verifies any Hotmail email, using SMTP.+ SmtpHotmailAll,+ /// Verifies any email, using SMTP.+ SmtpAll,+ /// Verifies any Yahoo email, using a headless browser.+ HeadlessYahoo,+ /// Verifies any B2C Hotmail email (@outlook, @live, @hotmail) email, using a headless browser.+ HeadlessHotmailB2C,+ /// Verifies any email, using a headless browser.+ HeadlessAll,+ /// Verifies any email, using the default method.+ All,+}++impl fmt::Display for Queue {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ match self {+ Queue::SmtpGmail => write!(f, "check.Smtp.gmail"),+ Queue::SmtpYahoo => write!(f, "check.Smtp.yahoo"),+ Queue::SmtpHotmailB2B => write!(f, "check.Smtp.hotmail.b2b"),+ Queue::SmtpHotmailB2C => write!(f, "check.Smtp.hotmail.b2c"),+ Queue::SmtpHotmailAll => write!(f, "check.Smtp.hotmail.*"),+ Queue::SmtpAll => write!(f, "check.Smtp.*"),+ Queue::HeadlessYahoo => write!(f, "check.Headless.yahoo"),+ Queue::HeadlessHotmailB2C => write!(f, "check.Headless.hotmail.b2c"),+ Queue::HeadlessAll => write!(f, "check.Headless.*"),+ Queue::All => write!(f, "check.*"),+ }+ }+}++// Implement Deserialize for the Queue enum+impl<'de> Deserialize<'de> for Queue {+ fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>+ where+ D: Deserializer<'de>,+ {+ struct QueueVisitor;++ impl<'de> Visitor<'de> for QueueVisitor {+ type Value = Queue;++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {+ formatter.write_str("a valid queue string")+ }++ fn visit_str<E>(self, value: &str) -> Result<Queue, E>+ where+ E: de::Error,+ {+ match value {+ "check.Smtp.gmail" => Ok(Queue::SmtpGmail),+ "check.Smtp.yahoo" => Ok(Queue::SmtpYahoo),+ "check.Smtp.hotmail.b2b" => Ok(Queue::SmtpHotmailB2B),+ "check.Smtp.hotmail.b2c" => Ok(Queue::SmtpHotmailB2C),+ "check.Smtp.hotmail.*" => Ok(Queue::SmtpHotmailAll),+ "check.Smtp.*" => Ok(Queue::SmtpAll),+ "check.Headless.yahoo" => Ok(Queue::HeadlessYahoo),+ "check.Headless.hotmail.b2c" => Ok(Queue::HeadlessHotmailB2C),+ "check.Headless.*" => Ok(Queue::HeadlessAll),+ "check.*" => Ok(Queue::All),+ _ => Err(de::Error::unknown_variant(+ value,+ &[+ "check.Smtp.gmail",+ "check.Smtp.yahoo",+ "check.Smtp.hotmail.b2b",+ "check.Smtp.hotmail.b2c",+ "check.Smtp.hotmail.*",+ "check.Smtp.*",+ "check.Headless.yahoo",+ "check.Headless.hotmail.b2c",+ "check.Headless.*",+ "check.*",+ ],+ )),+ }+ }+ }++ deserializer.deserialize_str(QueueVisitor)+ }+}++#[derive(Debug, Deserialize, Clone)]+pub struct ThrottleConfig {+ pub max_requests_per_second: Option<u32>,+ pub max_requests_per_minute: Option<u32>,+ pub max_requests_per_hour: Option<u32>,+ pub max_requests_per_day: Option<u32>,+}++#[derive(Debug, Deserialize, Clone)]+pub struct DBConfig {+ pub url: String,+}++#[derive(Debug, Deserialize, Clone)]+pub struct WebhookConfig {+ pub url: Option<String>,+}++/// Load the worker configuration from the worker_config.toml file and from the+/// environment.+pub fn load_config() -> Result<WorkerConfig, config::ConfigError> {+ let cfg = Config::builder()+ .add_source(config::File::with_name("worker_config"))+ .add_source(config::Environment::with_prefix("RCH").separator("_"))+ .build()?;++ let cfg = cfg.try_deserialize::<WorkerConfig>()?;++ Ok(cfg)+}diff --git a/worker/src/db.rs b/worker/src/db.rsnew file mode 100644index 00000000..9b5610fa--- /dev/null+++ b/worker/src/db.rs@@ -0,0 +1,82 @@+// Reacher - Email Verification+// Copyright (C) 2018-2023 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 check_if_email_exists::{CheckEmailOutput, LOG_TARGET};+use sqlx::{postgres::PgPoolOptions, PgPool};+use tracing::{debug, info};++use crate::{check_email::WorkerPayload, config::WorkerConfig};++pub async fn save_to_db(+ pg_pool: PgPool,+ config: WorkerConfig,+ payload: &WorkerPayload,+ worker_output: Result<CheckEmailOutput, Box<dyn std::error::Error + Send + Sync>>,+) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {+ let payload_json = serde_json::to_value(payload)?;++ match worker_output {+ Ok(output) => {+ let output_json = serde_json::to_value(output)?;++ sqlx::query!(+ r#"+ INSERT INTO reacher_results (payload, worker, result)+ VALUES ($1, $2, $3)+ RETURNING id+ "#,+ payload_json,+ config.name,+ output_json,+ )+ .fetch_one(&pg_pool)+ .await?;+ }+ Err(err) => {+ sqlx::query!(+ r#"+ INSERT INTO reacher_results (payload, worker, error)+ VALUES ($1, $2, $3)+ RETURNING id+ "#,+ payload_json,+ config.name,+ err.to_string(),+ )+ .fetch_one(&pg_pool)+ .await?;+ }+ }++ debug!(target: LOG_TARGET, email=?payload.input.to_email, "Wrote to DB");++ Ok(())+}++/// Create a DB pool.+pub async fn create_db(config: &WorkerConfig) -> Result<PgPool, sqlx::Error> {+ debug!(target: LOG_TARGET, "Connecting to DB... {db_url}", db_url=config.db.url);+ // create connection pool with database+ // connection pool internally the shared db connection+ // with arc so it can safely be cloned and shared across threads+ let pool = PgPoolOptions::new().connect(&config.db.url).await?;++ sqlx::migrate!("./migrations").run(&pool).await?;++ info!(target: LOG_TARGET, table="email_results", "Connected to DB, Reacher will write results to DB");++ Ok(pool)+}diff --git a/worker/src/lib.rs b/worker/src/lib.rsnew file mode 100644index 00000000..78974b21--- /dev/null+++ b/worker/src/lib.rs@@ -0,0 +1,27 @@+// Reacher - Email Verification+// Copyright (C) 2018-2023 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/>.++//! Main entry point of the `reacher_backend` binary. It has two `main`+//! functions, depending on whether the `bulk` feature is enabled or not.++use std::env;++pub mod check_email;+pub mod config;+pub mod db;+pub mod worker;++pub const CARGO_PKG_VERSION: &str = env!("CARGO_PKG_VERSION");diff --git a/worker/src/main.rs b/worker/src/main.rsnew file mode 100644index 00000000..2ae274c1--- /dev/null+++ b/worker/src/main.rs@@ -0,0 +1,40 @@+// Reacher - Email Verification+// Copyright (C) 2018-2023 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/>.++//! Main entry point of the `reacher_backend` binary. It has two `main`+//! functions, depending on whether the `bulk` feature is enabled or not.++use check_if_email_exists::{setup_sentry, LOG_TARGET};+use reacher_worker::config::load_config;+use reacher_worker::db::create_db;+use reacher_worker::worker::run_worker;+use reacher_worker::CARGO_PKG_VERSION;+use tracing::info;++#[tokio::main]+async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {+ // Initialize logging.+ tracing_subscriber::fmt::init();+ info!(target: LOG_TARGET, version=?CARGO_PKG_VERSION, "Running Reacher Worker");++ // Setup sentry bug tracking.+ let _guard: sentry::ClientInitGuard = setup_sentry();++ let config = load_config()?;+ let pg_pool = create_db(&config).await?;++ run_worker(config, pg_pool).await+}diff --git a/worker/src/worker.rs b/worker/src/worker.rsnew file mode 100644index 00000000..ff2740dd--- /dev/null+++ b/worker/src/worker.rs@@ -0,0 +1,203 @@+use crate::check_email::process_queue_message;+use crate::check_email::WorkerPayload;+use crate::config::WorkerConfig;+use check_if_email_exists::LOG_TARGET;+use futures_lite::stream::StreamExt;+use lapin::{options::*, types::FieldTable, Channel, Connection, ConnectionProperties};+use sqlx::PgPool;+use std::sync::Arc;+use std::time::Duration;+use std::time::Instant;+use tokio::time::sleep;+use tracing::{error, info};++pub async fn setup_rabbit_mq(config: &WorkerConfig) -> Result<Channel, lapin::Error> {+ let options = ConnectionProperties::default()+ // Use tokio executor and reactor.+ .with_executor(tokio_executor_trait::Tokio::current())+ .with_reactor(tokio_reactor_trait::Tokio)+ .with_connection_name(config.name.clone().into());++ let conn = Connection::connect(&config.rabbitmq.url, options).await?;+ let channel = conn.create_channel().await?;++ info!(target: LOG_TARGET, backend=?config.name,state=?conn.status().state(), "Connected to AMQP broker");++ let queue_name = config.rabbitmq.queue.to_string();+ let mut queue_args = FieldTable::default();+ queue_args.insert("x-max-priority".into(), 5.into());++ channel+ .queue_declare(+ &queue_name,+ QueueDeclareOptions {+ durable: true,+ ..Default::default()+ },+ queue_args,+ )+ .await?;++ // Set up prefetch (concurrency) limit using qos+ channel+ .basic_qos(+ config.rabbitmq.concurrency.into(),+ BasicQosOptions::default(),+ )+ .await?;++ info!(target: LOG_TARGET, queue=?queue_name, "Worker will start consuming messages");++ Ok(channel)+}++pub async fn run_worker(+ config: WorkerConfig,+ pg_pool: PgPool,+) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {+ let channel = Arc::new(setup_rabbit_mq(&config).await?);++ let mut consumer = channel+ .basic_consume(+ &config.rabbitmq.queue.to_string(),+ &config.name,+ BasicConsumeOptions::default(),+ FieldTable::default(),+ )+ .await?;++ let mut throttle = Throttle::new();++ // Loop over the incoming messages+ while let Some(delivery) = consumer.next().await {+ let delivery = delivery?;+ let payload = serde_json::from_slice::<WorkerPayload>(&delivery.data)?;+ info!(target: LOG_TARGET, email=payload.input.to_email, "New job");++ // Reset throttle counters if needed+ throttle.reset_if_needed();++ let config_clone = config.clone();+ let channel_clone = channel.clone();+ let pg_pool_clone = pg_pool.clone();++ tokio::spawn(async move {+ if let Err(e) = process_queue_message(+ &payload,+ delivery,+ channel_clone,+ pg_pool_clone,+ config_clone,+ )+ .await+ {+ error!(target: LOG_TARGET, email=payload.input.to_email, error=?e, "Error processing message");+ }+ });++ // Increment throttle counters once we spawn the task+ throttle.increment_counters();++ // Check if we should throttle before fetching the next message+ if let Some(wait_duration) = throttle.should_throttle(&config) {+ info!(target: LOG_TARGET, wait=?wait_duration, "Too many requests, throttling");+ sleep(wait_duration).await;+ continue;+ }+ }++ Ok(())+}++#[derive(Clone)]+struct Throttle {+ requests_per_second: u32,+ requests_per_minute: u32,+ requests_per_hour: u32,+ requests_per_day: u32,+ last_reset_second: Instant,+ last_reset_minute: Instant,+ last_reset_hour: Instant,+ last_reset_day: Instant,+}++impl Throttle {+ fn new() -> Self {+ let now = Instant::now();+ Throttle {+ requests_per_second: 0,+ requests_per_minute: 0,+ requests_per_hour: 0,+ requests_per_day: 0,+ last_reset_second: now,+ last_reset_minute: now,+ last_reset_hour: now,+ last_reset_day: now,+ }+ }++ fn reset_if_needed(&mut self) {+ let now = Instant::now();++ // Reset per-second counter+ if now.duration_since(self.last_reset_second) >= Duration::from_secs(1) {+ self.requests_per_second = 0;+ self.last_reset_second = now;+ }++ // Reset per-minute counter+ if now.duration_since(self.last_reset_minute) >= Duration::from_secs(60) {+ self.requests_per_minute = 0;+ self.last_reset_minute = now;+ }++ // Reset per-hour counter+ if now.duration_since(self.last_reset_hour) >= Duration::from_secs(3600) {+ self.requests_per_hour = 0;+ self.last_reset_hour = now;+ }++ // Reset per-day counter+ if now.duration_since(self.last_reset_day) >= Duration::from_secs(86400) {+ self.requests_per_day = 0;+ self.last_reset_day = now;+ }+ }++ fn increment_counters(&mut self) {+ self.requests_per_second += 1;+ self.requests_per_minute += 1;+ self.requests_per_hour += 1;+ self.requests_per_day += 1;+ }++ fn should_throttle(&self, config: &WorkerConfig) -> Option<Duration> {+ let now = Instant::now();++ if let Some(max_per_second) = config.throttle.max_requests_per_second {+ if self.requests_per_second >= max_per_second {+ return Some(Duration::from_secs(1) - now.duration_since(self.last_reset_second));+ }+ }++ if let Some(max_per_minute) = config.throttle.max_requests_per_minute {+ if self.requests_per_minute >= max_per_minute {+ return Some(Duration::from_secs(60) - now.duration_since(self.last_reset_minute));+ }+ }++ if let Some(max_per_hour) = config.throttle.max_requests_per_hour {+ if self.requests_per_hour >= max_per_hour {+ return Some(Duration::from_secs(3600) - now.duration_since(self.last_reset_hour));+ }+ }++ if let Some(max_per_day) = config.throttle.max_requests_per_day {+ if self.requests_per_day >= max_per_day {+ return Some(Duration::from_secs(86400) - now.duration_since(self.last_reset_day));+ }+ }++ None+ }+}diff --git a/worker/worker_config.toml b/worker/worker_config.tomlnew file mode 100644index 00000000..d1f3edd3--- /dev/null+++ b/worker/worker_config.toml@@ -0,0 +1,35 @@+name = "worker1.reacher.dev"++[rabbitmq]+url = "amqp://guest:guest@localhost:5672"+# Queue name to consume messages from.+#+# The queue name MUST be one of the following:+# - "check.Smtp.gmail": verifies any Gmail email, using SMTP.+# - "check.Smtp.yahoo": verifies any Yahoo email, using SMTP.+# - "check.Smtp.hotmail.b2b": verifies any B2B Hotmail email, using SMTP.+# - "check.Smtp.hotmail.b2c": verifies any B2C Hotmail email (@outlook, @live, @hotmail), using SMTP.+# - "check.Smtp.hotmail.*": verifies any Hotmail email, using SMTP.+# - "check.Smtp.*": verifies any email, using SMTP.+# - "check.Headless.yahoo": verifies any Yahoo email, using a headless browser.+# - "check.Headless.hotmail.b2c": verifies any B2C Hotmail email (@outlook, @live, @hotmail) email, using a headless browser.+# - "check.Headless.*": verifies any email, using a headless browser.+# - "check.*": verifies any email, using the default method.+queue = "check.*"+concurrency = 20++# Throttle the maximum number of requests per second, per minute, per hour, an+# per day for this worker.+# All fields are optional, comment them out to disable the limit.+[throttle]+# max_requests_per_second = 20+max_requests_per_minute = 100+# max_requests_per_hour = 1000+max_requests_per_day = 20000++[db]+url = "postgresql://localhost/reacher_worker_db"++# The optional webhook URL to send the results to.+[webhook]+# url = "http://localhost:8080/webhook"