summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorKeuin <[email protected]>2023-07-29 11:52:36 +0800
committerKeuin <[email protected]>2023-07-29 11:52:36 +0800
commite42024f9b399c211a105ff53cf10ecad0efd1ce4 (patch)
treec6536607606c6af624eb24ea7a13522c901b15c1 /src/main.rs
parent6293c70e346ec9b94372ee44d3bdd312ee918e90 (diff)
update dynamic `sendto` parameter adaptivelyHEADmaster
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs
index d45fe8a..b5c4e69 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,13 +1,11 @@
use std::io;
use std::net::{SocketAddr, ToSocketAddrs};
-
use std::time::{Duration, SystemTime, SystemTimeError};
use clap::{arg, Parser};
use tokio::net::UdpSocket;
use tracing::{debug, error};
-
use crate::Destination::{Address, SockAddr};
const TTL: Duration = Duration::from_secs(300);
@@ -52,8 +50,8 @@ async fn main() {
let local = args.local.parse().expect("failed to parse local address");
let mut sendto = Destination::None;
let args_sendto: String;
- if let Some(s) = args.sendto {
- args_sendto = s;
+ if let Some(s) = &args.sendto {
+ args_sendto = s.clone();
sendto = Address(&args_sendto);
}
let mut addr_sendto: Option<SocketAddr> = None;
@@ -71,8 +69,9 @@ async fn main() {
i = 0;
}
}
- if sendto == Destination::None && addr != local {
- // assume the packet is coming from target
+ if args.sendto == None && addr != local {
+ // sendto is not defined by user and is determined dynamically
+ // we simply assume the last packet's sender is the target
// update missing sendto parameter
sendto = SockAddr(addr);
}