summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorToby Vincent <tobyv@tobyvin.dev>2024-04-21 15:13:11 -0500
committerToby Vincent <tobyv@tobyvin.dev>2024-04-21 15:13:11 -0500
commite8cddad2374f8a440c8dbc688a5827af8a938c5b (patch)
tree6b1fec08640e93db5b8b4b6d2cc5abb3fe51c786 /src/main.rs
parentc34b0b3704499279aa675ff920479d84d8131ded (diff)
feat: add ICMP fallback and handle unspecified netnetlink
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index 6f60514..529c1ed 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -15,6 +15,8 @@ use tokio::{
mod config;
+const PAYLOAD: [u8; 8] = [0; 8];
+
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
let config = Config::parse();
@@ -53,7 +55,9 @@ async fn main() -> Result<(), anyhow::Error> {
let cache = Arc::new(Mutex::new(cache));
let names = Arc::new(Mutex::new(names));
- join_set.spawn(sshr::netlink::neighbours(tx.clone()));
+ if config.neigh {
+ join_set.spawn(sshr::netlink::neighbours(tx.clone()));
+ }
if let Some(ip_net) = config.scan {
join_set.spawn(sshr::scanner::scan(tx.clone(), ip_net));
@@ -76,6 +80,8 @@ async fn main() -> Result<(), anyhow::Error> {
if block_in_place(|| TcpStream::connect_timeout(&addr, timeout)).is_err() {
return Ok(());
}
+ } else if surge_ping::ping(ip_addr, &PAYLOAD).await.is_err() {
+ return Ok(());
}
if let Some(s) = config.resolve.then(|| lookup_addr(&ip_addr).ok()).flatten() {