mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-02-04 05:44:53 +00:00
[FIX] Rust: fix unsetting source udp address when not specified by the user (#1750)
* Rust: fix unsetting source udp address when not specified by the user * Rust: Fix `--udp [[src@]host:]port` parameter
This commit is contained in:
@@ -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)]
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user