Skip to content

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

Add telnet

Amaury Martiny7f7bd31c50de
diff --git a/Cargo.lock b/Cargo.lock
index a6bc0e03..5f8e32bf 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -103,6 +103,7 @@ dependencies = [
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "telnet 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"trust-dns-resolver 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -548,6 +549,11 @@ name = "strsim"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+[[package]]
+name = "telnet"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
[[package]]
name = "termcolor"
version = "1.0.2"
@@ -984,6 +990,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum socket2 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "962a516af4d3a7c272cb3a1d50a8cc4e5b41802e4ad54cfb7bee8ba61d37d703"
"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8"
"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
+"checksum telnet 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e9506962f23f9c0fd5353e7e690c296fe7693e4c0ec361c7e8ef30e19caae9d3"
"checksum termcolor 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3390f44f1f706d8870297b6a2c4f92d9ab65a37c265fbbc6ac4ee72bcc2f3698"
"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
"checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6"
diff --git a/Cargo.toml b/Cargo.toml
index 9cc29bb5..425057db 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,4 +7,5 @@ authors = ["Amaury Martiny <[email protected]>"]
clap = {version = "2.32", features = ["yaml"]}
env_logger = "0.5.13"
log = "0.4"
+telnet = "0.1.2"
trust-dns-resolver = "0.9.1"
diff --git a/src/main.rs b/src/main.rs
index 341bd720..f6d9c645 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -6,7 +6,8 @@ extern crate log;
use clap::App;
-pub mod mx_hosts;
+mod mx_hosts;
+mod telnet;
fn main() {
env_logger::init();
@@ -34,4 +35,6 @@ fn main() {
for host in hosts.iter() {
println!("{}", host.exchange())
}
+
+ telnet::connect();
}
diff --git a/src/telnet.rs b/src/telnet.rs
new file mode 100644
index 00000000..8e1bd0d9
--- /dev/null
+++ b/src/telnet.rs
@@ -0,0 +1,26 @@
+extern crate telnet;
+
+use self::telnet::{Telnet, TelnetEvent};
+use std::str::from_utf8;
+
+pub fn connect() {
+ let mut connection = Telnet::connect(("gmail-smtp-in.l.google.com.", 25), 256)
+ .expect("Couldn't connect to the server...");
+
+ loop {
+ let event = connection.read().expect("Read Error");
+ match event {
+ TelnetEvent::Data(read_buffer) => {
+ // Debug: print the data buffer
+ println!("{}", from_utf8(&read_buffer).unwrap());
+
+ // Buffer to write to telnet
+ let write_buffer = "HELO Hi".as_bytes(); // TODO Define buffer depending on read_buffer
+ connection
+ .write(&write_buffer)
+ .expect("Error while writing");
+ }
+ _ => {}
+ }
+ }
+}