diff options
author | Keuin <[email protected]> | 2023-07-29 11:52:36 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2023-07-29 11:52:36 +0800 |
commit | e42024f9b399c211a105ff53cf10ecad0efd1ce4 (patch) | |
tree | c6536607606c6af624eb24ea7a13522c901b15c1 /src | |
parent | 6293c70e346ec9b94372ee44d3bdd312ee918e90 (diff) |
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 11 |
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); } |