mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Factor shared scanner logic into scanners/common
The five scanners (ARP, SNMP, mDNS, SSDP, DHCP) duplicated their
persist-and-notify pipeline, device enrichment, and status state
machines across same-family files. Extract the shared logic so a change
lands in one place instead of three to five.
- scanners/common/pipeline.rs: single record_sighting() persist+notify
path, replacing the per-scanner match blocks. ARP/SNMP now use the
same merge rules as the passive scanners (keep a stored hostname,
never overwrite a known IP with an empty one).
- scanners/common/enrichment.rs: build_device() for vendor/device-type
lookup with the privacy-MAC service fallback.
- scanners/common/{active,passive}_status.rs: the two status state
machines plus their tests, written once. Each scanner status.rs is now
a thin wrapper over its own static.
- utils/network::format_mac(): replaces three identical copies.
- web_server/scanner_status.rs: Active/Passive response types and two
handler helpers, replacing five near-identical structs+handlers. JSON
field names are unchanged so the frontend is unaffected; only OpenAPI
schema names change.
27 files changed, ~900 lines net removed. Build, clippy and all 113
tests (4 new) pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
72dbbe5e9a
commit
5f7a1287a1
@@ -5,12 +5,10 @@ use crate::model::device_events::{DeviceEvent, DeviceEventScanner, DeviceEventTy
|
||||
use crate::model::devices::{Device, DeviceSummary};
|
||||
use crate::model::notifications::{Notification, NotificationType};
|
||||
use crate::settings::get_settings;
|
||||
use crate::web_server::arp_scanner::ArpScannerStatusResponse;
|
||||
use crate::web_server::devices::{RegisterDevicePayload, UpdateDevicePayload};
|
||||
use crate::web_server::dhcp_scanner::DhcpScannerStatusResponse;
|
||||
use crate::web_server::mdns_scanner::MdnsScannerStatusResponse;
|
||||
use crate::web_server::snmp_scanner::SnmpScannerStatusResponse;
|
||||
use crate::web_server::ssdp_scanner::SsdpScannerStatusResponse;
|
||||
use crate::web_server::scanner_status::{
|
||||
ActiveScannerStatusResponse, PassiveScannerStatusResponse,
|
||||
};
|
||||
use axum::Json;
|
||||
use axum::extract::Request;
|
||||
use axum::http::StatusCode;
|
||||
@@ -33,6 +31,7 @@ pub mod devices;
|
||||
pub mod dhcp_scanner;
|
||||
pub mod mdns_scanner;
|
||||
pub mod notifications;
|
||||
pub mod scanner_status;
|
||||
pub mod snmp_scanner;
|
||||
pub mod ssdp_scanner;
|
||||
pub mod utils;
|
||||
@@ -74,11 +73,8 @@ pub mod utils;
|
||||
DeviceEvent,
|
||||
DeviceEventType,
|
||||
DeviceEventScanner,
|
||||
ArpScannerStatusResponse,
|
||||
MdnsScannerStatusResponse,
|
||||
SsdpScannerStatusResponse,
|
||||
DhcpScannerStatusResponse,
|
||||
SnmpScannerStatusResponse,
|
||||
ActiveScannerStatusResponse,
|
||||
PassiveScannerStatusResponse,
|
||||
)),
|
||||
modifiers(&SecurityAddon),
|
||||
tags(
|
||||
|
||||
Reference in New Issue
Block a user