mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Drop redundant use ... as ... aliases in scanner imports
The aliases re-encoded the module path into a name that no longer matched the source identifier (e.g. `use super::finder as mdns`). Use the actual module names at call sites; in the two web_server handlers the local `status` fn collides with the module, so the single call site uses the fully-qualified path instead. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
c12e700c27
commit
f9ad90d015
@@ -1,5 +1,5 @@
|
|||||||
use super::finder;
|
use super::finder;
|
||||||
use super::status as arp_scanner_status;
|
use super::status;
|
||||||
use crate::db;
|
use crate::db;
|
||||||
use crate::events;
|
use crate::events;
|
||||||
use crate::settings::get_settings;
|
use crate::settings::get_settings;
|
||||||
@@ -9,7 +9,7 @@ use tokio::time::{Duration, sleep};
|
|||||||
|
|
||||||
pub async fn scan() -> Result<(), Box<dyn std::error::Error>> {
|
pub async fn scan() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
loop {
|
loop {
|
||||||
arp_scanner_status::set_running();
|
status::set_running();
|
||||||
|
|
||||||
// Find online devices via ARP
|
// Find online devices via ARP
|
||||||
let devices = finder::find(get_settings().networking.interface.clone()).await?;
|
let devices = finder::find(get_settings().networking.interface.clone()).await?;
|
||||||
@@ -59,7 +59,7 @@ pub async fn scan() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
"Scan finished. Sleeping for {}",
|
"Scan finished. Sleeping for {}",
|
||||||
get_settings().arp_scanner.wait_between_scans
|
get_settings().arp_scanner.wait_between_scans
|
||||||
);
|
);
|
||||||
arp_scanner_status::set_waiting(next_scan_at);
|
status::set_waiting(next_scan_at);
|
||||||
sleep(wait).await;
|
sleep(wait).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ use std::time::Duration;
|
|||||||
use chrono::Local;
|
use chrono::Local;
|
||||||
use log::{debug, error, info, warn};
|
use log::{debug, error, info, warn};
|
||||||
|
|
||||||
use super::finder as mdns;
|
use super::finder;
|
||||||
use super::status as mdns_scanner_status;
|
use super::status;
|
||||||
use crate::data::mac_vendor_finder;
|
use crate::data::mac_vendor_finder;
|
||||||
use crate::data::vendor_device_type_finder;
|
use crate::data::vendor_device_type_finder;
|
||||||
use crate::db;
|
use crate::db;
|
||||||
@@ -17,8 +17,8 @@ use crate::settings::get_settings;
|
|||||||
/// pipeline used by the ARP scanner (devices table + events + notifications).
|
/// pipeline used by the ARP scanner (devices table + events + notifications).
|
||||||
pub async fn listen() -> Result<(), Box<dyn std::error::Error>> {
|
pub async fn listen() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let interface = get_settings().networking.interface.clone();
|
let interface = get_settings().networking.interface.clone();
|
||||||
let socket = mdns::open_socket(interface.clone())?;
|
let socket = finder::open_socket(interface.clone())?;
|
||||||
mdns_scanner_status::set_listening();
|
status::set_listening();
|
||||||
info!("mDNS scanner listening for announcements");
|
info!("mDNS scanner listening for announcements");
|
||||||
|
|
||||||
let probe_timeout = Duration::from(get_settings().mdns_scanner.probe_timeout);
|
let probe_timeout = Duration::from(get_settings().mdns_scanner.probe_timeout);
|
||||||
@@ -38,7 +38,7 @@ pub async fn listen() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
IpAddr::V6(_) => continue, // the device model is IPv4-only
|
IpAddr::V6(_) => continue, // the device model is IPv4-only
|
||||||
};
|
};
|
||||||
|
|
||||||
let announcement = mdns::parse_announcement(&buf[..len]);
|
let announcement = finder::parse_announcement(&buf[..len]);
|
||||||
let hostname = match announcement.hostnames.into_iter().next() {
|
let hostname = match announcement.hostnames.into_iter().next() {
|
||||||
Some(host) => host,
|
Some(host) => host,
|
||||||
None => continue,
|
None => continue,
|
||||||
@@ -117,5 +117,5 @@ async fn process_announcement(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mdns_scanner_status::record_discovery();
|
status::record_discovery();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ use log::error;
|
|||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use utoipa::ToSchema;
|
use utoipa::ToSchema;
|
||||||
|
|
||||||
use crate::scanners::arp::status as arp_scanner_status;
|
|
||||||
|
|
||||||
#[derive(Serialize, ToSchema)]
|
#[derive(Serialize, ToSchema)]
|
||||||
pub struct ArpScannerStatusResponse {
|
pub struct ArpScannerStatusResponse {
|
||||||
pub is_running: bool,
|
pub is_running: bool,
|
||||||
@@ -26,7 +24,7 @@ pub struct ArpScannerStatusResponse {
|
|||||||
security(("bearer_auth" = []))
|
security(("bearer_auth" = []))
|
||||||
)]
|
)]
|
||||||
pub async fn status() -> Result<Json<ArpScannerStatusResponse>, StatusCode> {
|
pub async fn status() -> Result<Json<ArpScannerStatusResponse>, StatusCode> {
|
||||||
let snapshot = match arp_scanner_status::get() {
|
let snapshot = match crate::scanners::arp::status::get() {
|
||||||
Some(s) => s,
|
Some(s) => s,
|
||||||
None => {
|
None => {
|
||||||
error!("ARP scanner status not initialized");
|
error!("ARP scanner status not initialized");
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ use log::error;
|
|||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use utoipa::ToSchema;
|
use utoipa::ToSchema;
|
||||||
|
|
||||||
use crate::scanners::mdns::status as mdns_scanner_status;
|
|
||||||
|
|
||||||
#[derive(Serialize, ToSchema)]
|
#[derive(Serialize, ToSchema)]
|
||||||
pub struct MdnsScannerStatusResponse {
|
pub struct MdnsScannerStatusResponse {
|
||||||
pub is_listening: bool,
|
pub is_listening: bool,
|
||||||
@@ -28,7 +26,7 @@ pub struct MdnsScannerStatusResponse {
|
|||||||
security(("bearer_auth" = []))
|
security(("bearer_auth" = []))
|
||||||
)]
|
)]
|
||||||
pub async fn status() -> Result<Json<MdnsScannerStatusResponse>, StatusCode> {
|
pub async fn status() -> Result<Json<MdnsScannerStatusResponse>, StatusCode> {
|
||||||
let snapshot = match mdns_scanner_status::get() {
|
let snapshot = match crate::scanners::mdns::status::get() {
|
||||||
Some(s) => s,
|
Some(s) => s,
|
||||||
None => {
|
None => {
|
||||||
error!("mDNS scanner status not initialized");
|
error!("mDNS scanner status not initialized");
|
||||||
|
|||||||
Reference in New Issue
Block a user