summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock97
-rw-r--r--Cargo.toml4
-rw-r--r--src/main.rs33
3 files changed, 126 insertions, 8 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 050967e..6e95295 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3,12 +3,37 @@
version = 3
[[package]]
+name = "autocfg"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
+
+[[package]]
+name = "cc"
+version = "1.0.73"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
+
+[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
+name = "chrono"
+version = "0.4.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73"
+dependencies = [
+ "libc",
+ "num-integer",
+ "num-traits",
+ "time",
+ "winapi",
+]
+
+[[package]]
name = "getrandom"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -29,7 +54,28 @@ checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b"
name = "multiping"
version = "0.1.0"
dependencies = [
+ "chrono",
"ping",
+ "sqlite",
+]
+
+[[package]]
+name = "num-integer"
+version = "0.1.45"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
+dependencies = [
+ "autocfg",
+ "num-traits",
+]
+
+[[package]]
+name = "num-traits"
+version = "0.2.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
+dependencies = [
+ "autocfg",
]
[[package]]
@@ -44,6 +90,12 @@ dependencies = [
]
[[package]]
+name = "pkg-config"
+version = "0.3.25"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"
+
+[[package]]
name = "ppv-lite86"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -108,6 +160,36 @@ dependencies = [
]
[[package]]
+name = "sqlite"
+version = "0.26.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3fb1a534c07ec276fbbe0e55a1c00814d8563da3a2f4d9d9d4c802bd1278db6a"
+dependencies = [
+ "libc",
+ "sqlite3-sys",
+]
+
+[[package]]
+name = "sqlite3-src"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a260b07ce75a0644c6f5891f34f46db9869e731838e95293469ab17999abcfa3"
+dependencies = [
+ "cc",
+ "pkg-config",
+]
+
+[[package]]
+name = "sqlite3-sys"
+version = "0.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "04d2f028faeb14352df7934b4771806f60d61ce61be1928ec92396d7492e2e54"
+dependencies = [
+ "libc",
+ "sqlite3-src",
+]
+
+[[package]]
name = "syn"
version = "1.0.93"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -139,6 +221,17 @@ dependencies = [
]
[[package]]
+name = "time"
+version = "0.1.44"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
+dependencies = [
+ "libc",
+ "wasi",
+ "winapi",
+]
+
+[[package]]
name = "unicode-xid"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -146,9 +239,9 @@ checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04"
[[package]]
name = "wasi"
-version = "0.10.2+wasi-snapshot-preview1"
+version = "0.10.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
+checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
[[package]]
name = "winapi"
diff --git a/Cargo.toml b/Cargo.toml
index 17e4f35..458be1a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -4,4 +4,6 @@ version = "0.1.0"
edition = "2021"
[dependencies]
-ping = "0.4.0" \ No newline at end of file
+chrono = "0.4.19"
+ping = "0.4.0"
+sqlite = "0.26.0" \ No newline at end of file
diff --git a/src/main.rs b/src/main.rs
index b125a3e..1777a5c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,12 +1,35 @@
+extern crate chrono;
extern crate ping;
+extern crate sqlite;
+use std::thread;
use std::time::{Duration,Instant};
+use chrono::prelude::*;
fn main() {
- let addr = "8.8.8.8".parse().unwrap();
+ let connection = sqlite::open(":memory:").unwrap();
+
+ connection.execute(
+ "
+ CREATE TABLE pings (ip TEXT, timestamp TEXT, ping REAL);
+ ",
+ ).unwrap();
+
+ let addrstr = "8.8.8.8";
+ let addr = addrstr.parse().unwrap();
let timeout = Duration::from_secs(1);
- let now = Instant::now();
- ping::ping(addr, Some(timeout), Some(166), Some(3), Some(5), None).unwrap();
- let new_now = Instant::now();
- println!("{:?}", new_now.duration_since(now));
+
+ for i in 1..10 {
+ let now = Instant::now();
+ ping::ping(addr, Some(timeout), Some(166), Some(3), Some(i), None).unwrap();
+ let new_now = Instant::now();
+ let local: DateTime<Local> = Local::now();
+
+ connection.execute(
+ format!("INSERT INTO pings VALUES ('{}', '{}', {});", addrstr, local, new_now.duration_since(now).as_micros()),
+ ).unwrap();
+ println!("{} {} {}", addrstr, local, new_now.duration_since(now).as_micros());
+ thread::sleep(Duration::from_secs(1));
+ }
+
}