summaryrefslogtreecommitdiffhomepage
path: root/talpid-core/src
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2019-05-29 19:13:25 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2019-06-10 21:42:33 +0000
commit361811fde05c8d7d948b4ce1ffd33ae34934fb60 (patch)
tree4ff0be9492d6da31411e453c4b591bafb90253e2 /talpid-core/src
parent23db4f86469cc58f4b7d7631f0693b71ef4f13a1 (diff)
downloadmullvadvpn-361811fde05c8d7d948b4ce1ffd33ae34934fb60.tar.xz
mullvadvpn-361811fde05c8d7d948b4ce1ffd33ae34934fb60.zip
Update `ping_monitor` to support Android
Diffstat (limited to 'talpid-core/src')
-rw-r--r--talpid-core/src/tunnel/wireguard/ping_monitor.rs39
1 files changed, 21 insertions, 18 deletions
diff --git a/talpid-core/src/tunnel/wireguard/ping_monitor.rs b/talpid-core/src/tunnel/wireguard/ping_monitor.rs
index 69f22fc83f..89b13ee637 100644
--- a/talpid-core/src/tunnel/wireguard/ping_monitor.rs
+++ b/talpid-core/src/tunnel/wireguard/ping_monitor.rs
@@ -48,30 +48,29 @@ fn ping_cmd(
interface: &str,
exit_on_first_reply: bool,
) -> duct::Expression {
- let interface_flag = if cfg!(target_os = "linux") {
- "-I"
- } else {
- "-b"
- };
- let timeout_flag = if cfg!(target_os = "linux") {
+ let mut args = vec!["-n", "-i", "1"];
+
+ let timeout_flag = if cfg!(target_os = "linux") || cfg!(target_os = "android") {
"-w"
} else {
"-t"
};
-
let timeout_secs = timeout_secs.to_string();
- let ip = ip.to_string();
- let mut args = vec![
- "-n",
- "-i",
- "1",
- &interface_flag,
- &interface,
- timeout_flag,
- &timeout_secs,
- &ip,
- ];
+ args.extend_from_slice(&[timeout_flag, &timeout_secs]);
+
+ let interface_flag = if cfg!(target_os = "linux") {
+ Some("-I")
+ } else if cfg!(target_os = "macos") {
+ Some("-b")
+ } else {
+ None
+ };
+
+ if let Some(interface_flag) = interface_flag {
+ args.extend_from_slice(&[interface_flag, interface]);
+ }
+
if exit_on_first_reply {
if cfg!(target_os = "macos") {
args.push("-o");
@@ -79,6 +78,10 @@ fn ping_cmd(
args.extend_from_slice(&["-c", "1"])
}
}
+
+ let ip = ip.to_string();
+ args.push(&ip);
+
duct::cmd("ping", args)
.stdin_null()
.stdout_null()