mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Do not notify when a device's vendor is first deduced
Treat an empty->non-empty vendor transition as not a change, so first deducing a vendor for a device that previously had none no longer raises a "vendor changed" notification. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
561fbdb548
commit
ef420ad360
@@ -12,7 +12,7 @@
|
|||||||
- [x] Add a data set (json) to store maps from vendors -> device type; modify the device creation so that it uses it automatically
|
- [x] Add a data set (json) to store maps from vendors -> device type; modify the device creation so that it uses it automatically
|
||||||
- [x] Add an mDNS/Bonjour scanner
|
- [x] Add an mDNS/Bonjour scanner
|
||||||
- [x] Extract the select_interface method and interface logic from ARP scanner to a centralized utility file
|
- [x] Extract the select_interface method and interface logic from ARP scanner to a centralized utility file
|
||||||
- [ ] Figure out if we can univocally identify devices that mask their MAC address (like apple)
|
- [x] Figure out if we can univocally identify devices that mask their MAC address (like apple)
|
||||||
- [ ] Add the scanner that triggered the event to the device_events table
|
- [ ] Add the scanner that triggered the event to the device_events table
|
||||||
|
|
||||||
## Frontend
|
## Frontend
|
||||||
|
|||||||
@@ -26,9 +26,10 @@ fn display_name(device: &Device) -> &str {
|
|||||||
|
|
||||||
// Whether a re-sighting represents a real vendor change. A scanner that cannot deduce a vendor
|
// Whether a re-sighting represents a real vendor change. A scanner that cannot deduce a vendor
|
||||||
// reports an empty string; that is not a change (db::devices::update keeps the known vendor), so
|
// reports an empty string; that is not a change (db::devices::update keeps the known vendor), so
|
||||||
// it must not raise a "vendor changed" notification either.
|
// it must not raise a "vendor changed" notification either. Likewise, first deducing a vendor for a
|
||||||
|
// device that previously had none is not a change worth notifying about.
|
||||||
fn vendor_changed(existing: &str, new: &str) -> bool {
|
fn vendor_changed(existing: &str, new: &str) -> bool {
|
||||||
!new.is_empty() && existing != new
|
!existing.is_empty() && !new.is_empty() && existing != new
|
||||||
}
|
}
|
||||||
|
|
||||||
// Private helper function to deliver messages
|
// Private helper function to deliver messages
|
||||||
@@ -216,7 +217,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn newly_deduced_vendor_from_empty_is_a_change() {
|
fn newly_deduced_vendor_from_empty_is_not_a_change() {
|
||||||
assert!(vendor_changed("", "Apple, Inc."));
|
assert!(!vendor_changed("", "Apple, Inc."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user