summaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-04-30 17:37:34 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-04-30 17:37:34 +0200
commit05b4e395a988c23f78fe7e90fa1b550fcde2112b (patch)
tree28ffa1da885eea7eb3a876651d57bbb72573f8d0 /app
parent65ca5979d2d20f5439b9d1cdb63e9ac4c2a8a250 (diff)
Tunnel importer: stricter file filters
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java b/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java
index 683a8b6d..719960af 100644
--- a/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java
+++ b/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java
@@ -96,6 +96,8 @@ public class TunnelListFragment extends BaseFragment {
boolean isZip = name.toLowerCase().endsWith(".zip");
if (name.toLowerCase().endsWith(".conf"))
name = name.substring(0, name.length() - ".conf".length());
+ else if (!isZip)
+ throw new IllegalArgumentException("File must be .conf or .zip");
if (isZip) {
ZipInputStream zip = new ZipInputStream(contentResolver.openInputStream(uri));
@@ -128,8 +130,12 @@ public class TunnelListFragment extends BaseFragment {
futureTunnels.add(tunnelManager.create(name, Config.from(contentResolver.openInputStream(uri))).toCompletableFuture());
}
- if (futureTunnels.isEmpty() && throwables.size() == 1)
- throw throwables.get(0);
+ if (futureTunnels.isEmpty()) {
+ if (throwables.size() == 1)
+ throw throwables.get(0);
+ else if (throwables.isEmpty())
+ throw new IllegalArgumentException("No configurations found");
+ }
return CompletableFuture.allOf(futureTunnels.toArray(new CompletableFuture[futureTunnels.size()]));
}).whenComplete((future, exception) -> {