Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/rust/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,9 @@ pub struct Args {
pub segmentonkeyonly: bool,
/// Read the input via UDP (listening in the specified port)
/// instead of reading a file.
/// Host can be a
/// hostname or IPv4 address. If host is not specified
/// then listens on the local host.
#[arg(long, value_name="[host:]port", verbatim_doc_comment, help_heading=NETWORK_SUPPORT)]
/// Host and src can be a hostname or IPv4 address.
/// If host is not specified then listens on the local host.
#[arg(long, value_name="[[src@]host:]port", verbatim_doc_comment, help_heading=NETWORK_SUPPORT)]
pub udp: Option<String>,
/// Can be a hostname or IPv4 address.
#[arg(long, value_name="port", verbatim_doc_comment, help_heading=NETWORK_SUPPORT)]
Expand Down
34 changes: 22 additions & 12 deletions src/rust/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1321,23 +1321,33 @@ impl OptionsExt for Options {

// Network stuff
if let Some(ref udp) = args.udp {
if let Some(at) = udp.find('@') {
let addr = &udp[0..at];
let port = &udp[at + 1..];
let mut remaining_udp = udp.as_str();

self.udpsrc = Some(udp.clone());
self.udpaddr = Some(addr.to_owned());
self.udpport = port.parse().unwrap();
} else if let Some(colon) = udp.find(':') {
let addr = &udp[0..colon];
let port = get_atoi_hex(&udp[colon + 1..]);
if let Some(at) = remaining_udp.find('@') {
let src = &remaining_udp[0..at];
self.udpsrc = Some(src.to_owned());

remaining_udp = &remaining_udp[at + 1..];
}

if let Some(colon) = remaining_udp.find(':') {
let addr = &remaining_udp[0..colon];
let port = get_atoi_hex(&remaining_udp[colon + 1..]);

self.udpsrc = Some(udp.clone());
self.udpaddr = Some(addr.to_owned());
self.udpport = port;
} else {
self.udpaddr = None;
self.udpport = udp.parse().unwrap();
match remaining_udp.parse() {
Ok(port) => {
self.udpport = port;
}
Err(_) => {
fatal!(
cause = ExitCause::MalformedParameter;
"Invalid UDP parameter\n"
);
}
}
}

self.input_source = DataSource::Network;
Expand Down
Loading