Tunnel importer: stricter file filters
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
65ca5979d2
commit
05b4e395a9
@ -96,6 +96,8 @@ public class TunnelListFragment extends BaseFragment {
|
|||||||
boolean isZip = name.toLowerCase().endsWith(".zip");
|
boolean isZip = name.toLowerCase().endsWith(".zip");
|
||||||
if (name.toLowerCase().endsWith(".conf"))
|
if (name.toLowerCase().endsWith(".conf"))
|
||||||
name = name.substring(0, name.length() - ".conf".length());
|
name = name.substring(0, name.length() - ".conf".length());
|
||||||
|
else if (!isZip)
|
||||||
|
throw new IllegalArgumentException("File must be .conf or .zip");
|
||||||
|
|
||||||
if (isZip) {
|
if (isZip) {
|
||||||
ZipInputStream zip = new ZipInputStream(contentResolver.openInputStream(uri));
|
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());
|
futureTunnels.add(tunnelManager.create(name, Config.from(contentResolver.openInputStream(uri))).toCompletableFuture());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (futureTunnels.isEmpty() && throwables.size() == 1)
|
if (futureTunnels.isEmpty()) {
|
||||||
throw throwables.get(0);
|
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()]));
|
return CompletableFuture.allOf(futureTunnels.toArray(new CompletableFuture[futureTunnels.size()]));
|
||||||
}).whenComplete((future, exception) -> {
|
}).whenComplete((future, exception) -> {
|
||||||
|
Loading…
Reference in New Issue
Block a user