diff --git a/Cargo.lock b/Cargo.lock index 8fb8642..bdc6118 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -71,7 +71,7 @@ dependencies = [ [[package]] name = "durnitisp" -version = "0.2.1" +version = "0.2.2" dependencies = [ "anyhow", "gflags", diff --git a/Cargo.toml b/Cargo.toml index ada4a34..5a9d67c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "durnitisp" -version = "0.2.1" +version = "0.2.2" authors = ["Jeremy Wall "] edition = "2018" diff --git a/flake.lock b/flake.lock index b541deb..fc78564 100644 --- a/flake.lock +++ b/flake.lock @@ -36,11 +36,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1639947939, - "narHash": "sha256-pGsM8haJadVP80GFq4xhnSpNitYNQpaXk4cnA796Cso=", + "lastModified": 1671096816, + "narHash": "sha256-ezQCsNgmpUHdZANDCILm3RvtO1xH8uujk/+EqNvzIOg=", "owner": "nix-community", "repo": "naersk", - "rev": "2fc8ce9d3c025d59fee349c1f80be9785049d653", + "rev": "d998160d6a076cfe8f9741e56aeec7e267e3e114", "type": "github" }, "original": { @@ -51,11 +51,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1645937171, - "narHash": "sha256-n9f9GZBNMe8UMhcgmmaXNObkH01jjgp7INMrUgBgcy4=", + "lastModified": 1678724065, + "narHash": "sha256-MjeRjunqfGTBGU401nxIjs7PC9PZZ1FBCZp/bRB3C2M=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "22dc22f8cedc58fcb11afe1acb08e9999e78be9c", + "rev": "b8afc8489dc96f29f69bec50fdc51e27883f89c1", "type": "github" }, "original": { diff --git a/src/icmp.rs b/src/icmp.rs index 2b58d20..fbae32d 100644 --- a/src/icmp.rs +++ b/src/icmp.rs @@ -73,6 +73,7 @@ impl State { fn handle_echo_reply(&mut self, identifier: u16, sequence: u16) -> bool { if let Some((domain_name, dest)) = self.destinations.get(&identifier) { let time_tracker = self.time_tracker.get_mut(&identifier); + let mut result = false; if let Some(Some(send_time)) = time_tracker.as_ref().map(|m| m.get(&sequence)) { let elapsed = Instant::now().sub(send_time.clone()).as_micros() as f64 / 1000.00; // We make a copy here to avoid the borrow above sticking around for too long. @@ -94,7 +95,7 @@ impl State { self.time_tracker .get_mut(&identifier) .and_then(|m| m.remove(&sequence)); - return true; + result = true; } else { error!(sequence, "Discarding unexpected sequence",); }; @@ -114,7 +115,7 @@ impl State { "Dropped" ); self.ping_counter - .with(&prometheus::labels! {"result" => "timeout", "domain" => domain_name}) + .with(&prometheus::labels! {"result" => "dropped", "domain" => domain_name}) .inc(); for_delete.push(*k); } @@ -127,6 +128,7 @@ impl State { .get_mut(&identifier) .and_then(|m| m.remove(&k)); } + return result; } else { warn!(identifier, "Discarding wrong identifier"); }