diff --git a/src/features/network/updater.rs b/src/features/network/updater.rs index 5e6e8c6..ae6f310 100644 --- a/src/features/network/updater.rs +++ b/src/features/network/updater.rs @@ -70,20 +70,21 @@ fn essid() -> Option { } fn ip_address(address_type: &IpAddress) -> Option { - let command = process::Command::new("dig", &[ + let mut command = process::Command::new("dig", &[ // decrease time and tries because commands are executed synchronously // TODO: make asychronous "+time=3", // default: 5 seconds "+tries=1", // default: 3 "@resolver1.opendns.com", - match address_type { - IpAddress::V4 => "A", - IpAddress::V6 => "AAAA", - }, "myip.opendns.com", "+short", ]); + command.args(match address_type { + IpAddress::V4 => ["A", "-4"], + IpAddress::V6 => ["AAAA", "-6"], + }); + let output = command.output().wrap_error( FEATURE_NAME, format!("ip address {} could not be fetched", address_type), diff --git a/src/wrapper/process.rs b/src/wrapper/process.rs index 9d8ff7c..7665846 100644 --- a/src/wrapper/process.rs +++ b/src/wrapper/process.rs @@ -26,6 +26,14 @@ impl Command { Self { command } } + pub(crate) fn args(&mut self, args: I) + where + I: IntoIterator, + S: AsRef, + { + self.command.args(args); + } + pub(crate) fn output(mut self) -> Result { self.command .output()