aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/app/src/main/java/com/wireguard/android/backend
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-01-08 19:46:51 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2018-01-08 19:46:51 +0100
commiteb37b3a5ccc527936ef495e893655fca60115e2e (patch)
tree6e7ff0de24f3113077b9308baf0e69fcbc21ece4 /app/src/main/java/com/wireguard/android/backend
parentPort over remaining error handling (diff)
downloadwireguard-android-eb37b3a5ccc527936ef495e893655fca60115e2e.tar.xz
wireguard-android-eb37b3a5ccc527936ef495e893655fca60115e2e.zip
RootShell: multiplex commands
Diffstat (limited to 'app/src/main/java/com/wireguard/android/backend')
-rw-r--r--app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java b/app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java
index 5eaf437d..ab6a6199 100644
--- a/app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java
+++ b/app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java
@@ -52,8 +52,12 @@ public final class WgQuickBackend implements Backend {
public Set<String> enumerate() {
final List<String> output = new ArrayList<>();
// Don't throw an exception here or nothing will show up in the UI.
- if (rootShell.run(output, "wg show interfaces") != 0 || output.isEmpty())
+ try {
+ if (rootShell.run(output, "wg show interfaces") != 0 || output.isEmpty())
+ return Collections.emptySet();
+ } catch (Exception e) {
return Collections.emptySet();
+ }
// wg puts all interface names on the same line. Split them into separate elements.
return Stream.of(output.get(0).split(" ")).collect(Collectors.toUnmodifiableSet());
}
@@ -86,11 +90,8 @@ public final class WgQuickBackend implements Backend {
} else {
result = rootShell.run(null, String.format("wg-quick down '%s'", tunnel.getName()));
}
- if (result != 0) {
- final String message = result == OsConstants.EACCES ?
- "Root access unavailable" : "wg-quick failed";
- throw new Exception(message);
- }
+ if (result != 0)
+ throw new Exception("wg-quick failed");
return getState(tunnel);
}
}