aboutsummaryrefslogtreecommitdiff
path: root/src/pinger.rs
diff options
context:
space:
mode:
authorache <ache@ache.one>2026-08-06 06:55:55 +0200
committerache <ache@ache.one>2026-08-06 06:55:55 +0200
commit368f4c99ed22ca9c30e60f7cc86a77553d745117 (patch)
treeb03e763e74c4ff4895e70e056687c57bfe8ef3fd /src/pinger.rs
parentFix green background (diff)
Remove ttl and add main loop
Diffstat (limited to 'src/pinger.rs')
-rw-r--r--src/pinger.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/pinger.rs b/src/pinger.rs
index 12cad5d..2170ead 100644
--- a/src/pinger.rs
+++ b/src/pinger.rs
@@ -8,19 +8,20 @@ pub enum PingResult {
Ping { rtt: u64, id: u32 },
}
-pub fn spawn_ping(target: IpAddr, tx: Sender<PingResult>, id: u32) {
+pub fn spawn_ping(target: IpAddr, tx: Sender<PingResult>, id: u32, ttl: u32) {
task::spawn_blocking(move || {
- let result = do_ping(target, id);
+ let result = do_ping(target, id, ttl);
let _ = tx.try_send(result);
});
}
-fn do_ping(target: IpAddr, id: u32) -> PingResult {
+fn do_ping(target: IpAddr, id: u32, ttl: u32) -> PingResult {
let payload: [u8; 24] = [0u8; 24];
let result = ping::new(target)
.timeout(Duration::from_secs(3))
.payload(&payload)
+ .ttl(ttl)
.send();
match result {