mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Added main loop to run continuously and relevant configuration options
This commit is contained in:
@@ -1,7 +1,11 @@
|
|||||||
|
[networking]
|
||||||
|
interface = "eno1" # Network interface to use for scans
|
||||||
|
|
||||||
[log]
|
[log]
|
||||||
level = "info" # off, error, warn, info, debug, trace
|
level = "info" # off, error, warn, info, debug, trace
|
||||||
|
|
||||||
[timings]
|
[timings]
|
||||||
|
wait_between_scans="30"
|
||||||
arp_sender_timeout="30"
|
arp_sender_timeout="30"
|
||||||
arp_scan_duration="60"
|
arp_scan_duration="60"
|
||||||
|
|
||||||
|
|||||||
+6
-2
@@ -1,9 +1,13 @@
|
|||||||
|
[networking]
|
||||||
|
interface = "eno1" # Network interface to use for scans
|
||||||
|
|
||||||
[log]
|
[log]
|
||||||
level = "info" # off, error, warn, info, debug, trace
|
level = "info" # off, error, warn, info, debug, trace
|
||||||
|
|
||||||
[timings]
|
[timings]
|
||||||
arp_sender_timeout="30"
|
wait_between_scans="900" # Wait time between scans (in seconds). This does not include the scan time
|
||||||
arp_scan_duration="60"
|
arp_sender_timeout="60" # If the ARP sender process takes longer than this (in seconds) it will be stopped (for a class C network - 254 IPs - it should take less than a minute)
|
||||||
|
arp_scan_duration="300" # How long to wait (in seconds) for response packets on each scan (300 to 600 seconds is a good timeframe for a class B or C network)
|
||||||
|
|
||||||
[notifications]
|
[notifications]
|
||||||
method="pushover" # For now just pushover, you can set this to "none" to avoid sending notifications (it will just log)
|
method="pushover" # For now just pushover, you can set this to "none" to avoid sending notifications (it will just log)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use pnet::{
|
|||||||
};
|
};
|
||||||
use tokio::time::{Duration, timeout};
|
use tokio::time::{Duration, timeout};
|
||||||
|
|
||||||
pub async fn find(interface: &str) -> Result<Vec<Device>, String> {
|
pub async fn find(interface: String) -> Result<Vec<Device>, String> {
|
||||||
debug!("Looking up devices via ARP using interface {}", interface);
|
debug!("Looking up devices via ARP using interface {}", interface);
|
||||||
|
|
||||||
// Get the network device to use
|
// Get the network device to use
|
||||||
|
|||||||
+10
-7
@@ -1,7 +1,7 @@
|
|||||||
|
use crate::settings::CONFIG;
|
||||||
use log::{LevelFilter, debug, info};
|
use log::{LevelFilter, debug, info};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
use tokio::time::{Duration, sleep};
|
||||||
use crate::settings::CONFIG;
|
|
||||||
|
|
||||||
mod db;
|
mod db;
|
||||||
mod device_finders;
|
mod device_finders;
|
||||||
@@ -33,8 +33,9 @@ async fn main() -> Result<(), String> {
|
|||||||
// Get database connection - thread protected
|
// Get database connection - thread protected
|
||||||
let db_conn = Arc::new(Mutex::new(db::init_db().unwrap()));
|
let db_conn = Arc::new(Mutex::new(db::init_db().unwrap()));
|
||||||
|
|
||||||
|
loop {
|
||||||
// Find online devices via ARP
|
// Find online devices via ARP
|
||||||
let devices = device_finders::arp::find("eno1").await.unwrap();
|
let devices = device_finders::arp::find(CONFIG.networking.interface.to_string()).await?;
|
||||||
|
|
||||||
info!("Done with ARP probes");
|
info!("Done with ARP probes");
|
||||||
info!("Found {} online devices", devices.iter().count());
|
info!("Found {} online devices", devices.iter().count());
|
||||||
@@ -73,8 +74,10 @@ async fn main() -> Result<(), String> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
info!(
|
||||||
info!("Exiting");
|
"Scan finished. Sleeping for {} seconds",
|
||||||
|
CONFIG.timings.wait_between_scans
|
||||||
Ok(())
|
);
|
||||||
|
sleep(Duration::from_secs(CONFIG.timings.wait_between_scans)).await;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,12 @@ use serde::Deserialize;
|
|||||||
|
|
||||||
// -----------------------------------------------------------
|
// -----------------------------------------------------------
|
||||||
// Configuration structure
|
// Configuration structure
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Clone)]
|
||||||
|
pub struct Networking {
|
||||||
|
pub interface: String,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone)]
|
#[derive(Debug, Deserialize, Clone)]
|
||||||
pub struct Log {
|
pub struct Log {
|
||||||
pub level: String,
|
pub level: String,
|
||||||
@@ -12,6 +18,7 @@ pub struct Log {
|
|||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone)]
|
#[derive(Debug, Deserialize, Clone)]
|
||||||
pub struct Timings {
|
pub struct Timings {
|
||||||
|
pub wait_between_scans: u64,
|
||||||
pub arp_sender_timeout: u64,
|
pub arp_sender_timeout: u64,
|
||||||
pub arp_scan_duration: u64,
|
pub arp_scan_duration: u64,
|
||||||
}
|
}
|
||||||
@@ -30,6 +37,7 @@ pub struct Notifications {
|
|||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone)]
|
#[derive(Debug, Deserialize, Clone)]
|
||||||
pub struct Settings {
|
pub struct Settings {
|
||||||
|
pub networking: Networking,
|
||||||
pub log: Log,
|
pub log: Log,
|
||||||
pub timings: Timings,
|
pub timings: Timings,
|
||||||
pub notifications: Notifications,
|
pub notifications: Notifications,
|
||||||
|
|||||||
Reference in New Issue
Block a user