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 --http-host flag to CLI (#197)
Amaury Martiny55657b251fcc
diff --git a/Cargo.lock b/Cargo.lockindex cf676b79..aaf468a8 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -113,7 +113,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"[[package]]name = "check-if-email-exists"-version = "0.6.0"+version = "0.6.1"dependencies = ["futures 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)","lettre 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",@@ -128,9 +128,9 @@ dependencies = [[[package]]name = "check-if-email-exists-cli"-version = "0.6.0"+version = "0.6.1"dependencies = [- "check-if-email-exists 0.6.0",+ "check-if-email-exists 0.6.1","clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)","env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)","futures-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)",@@ -142,9 +142,9 @@ dependencies = [[[package]]name = "check-if-email-exists-test-suite"-version = "0.6.0"+version = "0.6.1"dependencies = [- "check-if-email-exists 0.6.0",+ "check-if-email-exists 0.6.1","futures 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)","serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)","serde_json 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)",diff --git a/Cargo.toml b/Cargo.tomlindex 7d76eef8..2f2d5d70 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -1,6 +1,6 @@[package]name = "check-if-email-exists-cli"-version = "0.6.0"+version = "0.6.1"default-run = "check_if_email_exists"edition = "2018"publish = falsediff --git a/Dockerfile b/Dockerfileindex f11da0fd..d80ffe33 100644--- a/Dockerfile+++ b/Dockerfile@@ -2,7 +2,7 @@ FROM alpine# `ciee` stands for check-if-email-existsWORKDIR /ciee-ENV CIEE_VERSION 0.6.0+ENV CIEE_VERSION 0.6.1# Install needed librariesRUN apk update && \@@ -13,4 +13,4 @@ RUN apk update && \RUN wget https://github.com/amaurymartiny/check-if-email-exists/releases/download/v${CIEE_VERSION}/check-if-email-exists-v${CIEE_VERSION}-x86_64-unknown-linux-musl.tar.gz \&& tar -xvzf check-if-email-exists-v${CIEE_VERSION}-x86_64-unknown-linux-musl.tar.gz-CMD ["./check_if_email_exists", "--http"]+CMD ["./check_if_email_exists", "--http", "--http-host", "0.0.0.0"]diff --git a/core/Cargo.toml b/core/Cargo.tomlindex d0a883d3..7a2fc07d 100644--- a/core/Cargo.toml+++ b/core/Cargo.toml@@ -1,6 +1,6 @@[package]name = "check-if-email-exists"-version = "0.6.0"+version = "0.6.1"authors = ["Amaury Martiny <[email protected]>"]categories = ["email"]description = "Check if an email address exists without sending any email"diff --git a/src/cli.yml b/src/cli.ymlindex 8882cb0f..de3da940 100644--- a/src/cli.yml+++ b/src/cli.yml@@ -1,5 +1,5 @@name: check_if_email_exists-version: "0.6.0"+version: "0.6.1"author: Amaury Martiny <[email protected]>about: Check if an email address exists without sending any email.args:@@ -11,6 +11,12 @@ args:- HTTP:long: httphelp: Runs a HTTP server+ - HTTP_HOST:+ default_value: "127.0.0.1"+ long: http-host+ help: Sets the host IP address on which the HTTP server should bind. Only used when `--http` flag is on+ takes_value: true+ value_name: HOST- HTTP_PORT:default_value: "3000"long: http-portdiff --git a/src/http.rs b/src/http.rsindex 080f5534..fb57a22e 100644--- a/src/http.rs+++ b/src/http.rs@@ -19,6 +19,7 @@ use futures::stream::TryStreamExt;use hyper::service::{make_service_fn, service_fn};use hyper::{Body, Method, Request, Response, Server, StatusCode};use serde::{Deserialize, Serialize};+use std::net::SocketAddr;/// JSON Request from POST /#[derive(Debug, Deserialize, Serialize)]@@ -86,9 +87,9 @@ async fn req_handler(req: Request<Body>) -> Result<Response<Body>, hyper::Error>}}-pub async fn run(port: u16) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {+pub async fn run(host: &str, port: u16) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {// This is our socket address- let addr = ([127, 0, 0, 1], port).into();+ let addr = SocketAddr::new(host.parse()?, port);let service = make_service_fn(|_| async { Ok::<_, hyper::Error>(service_fn(req_handler)) });let server = Server::bind(&addr).serve(service);diff --git a/src/main.rs b/src/main.rsindex c089c1b6..8f3475c0 100644--- a/src/main.rs+++ b/src/main.rs@@ -54,11 +54,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {// Run the web server if flag is onif matches.is_present("HTTP") {+ let http_host = matches+ .value_of("HTTP_HOST")+ .expect("HTTP_HOST has a default value. qed.");let http_port = matches.value_of("HTTP_PORT").expect("HTTP_PORT has a default value. qed.");- http::run(http_port.parse::<u16>().unwrap()).await?+ http::run(http_host, http_port.parse::<u16>().unwrap()).await?}Ok(())diff --git a/test_suite/Cargo.toml b/test_suite/Cargo.tomlindex 461bb440..11165ee5 100644--- a/test_suite/Cargo.toml+++ b/test_suite/Cargo.toml@@ -1,6 +1,6 @@[package]name = "check-if-email-exists-test-suite"-version = "0.6.0"+version = "0.6.1"edition = "2018"publish = false