From fe2a2cda3a50eddda813a8c21bb99e4389496119 Mon Sep 17 00:00:00 2001 From: K <127317849+cafedetal@users.noreply.github.com> Date: Thu, 30 Mar 2023 08:44:44 +0100 Subject: [PATCH] fix(fallback): report interface down/up logic (#31) Reverse the logic when checking if a recorded interface still exists in the new list to avoid reporting all interfaces as down and then up in the same `resync()`. --- CHANGELOG.md | 9 +++++++++ Cargo.toml | 2 +- src/fallback.rs | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c86b11..173ab91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.0.1] + +### Fixed + +- For all architectures running the fallback option (e.g. Android) reverse the logic when checking if a recorded interface still exists in the new list to avoid reporting all interfaces as down and then up in the same resync(). + See [PR 31]. + +[PR 31]: https://github.com/mxinden/if-watch/pull/31 + ## [3.0.0] ### Changed diff --git a/Cargo.toml b/Cargo.toml index abf8224..6d1a7b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "if-watch" -version = "3.0.0" +version = "3.0.1" authors = ["David Craven ", "Parity Technologies Limited "] edition = "2021" keywords = ["asynchronous", "routing"] diff --git a/src/fallback.rs b/src/fallback.rs index c4d5e52..5c6fca6 100644 --- a/src/fallback.rs +++ b/src/fallback.rs @@ -50,7 +50,7 @@ impl IfWatcher { fn resync(&mut self) -> Result<()> { let addrs = if_addrs::get_if_addrs()?; for old_addr in self.addrs.clone() { - if addrs.iter().any(|addr| addr.ip() == old_addr.addr()) { + if !addrs.iter().any(|addr| addr.ip() == old_addr.addr()) { self.addrs.remove(&old_addr); self.queue.push_back(IfEvent::Down(old_addr)); }