aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2017-06-22 12:01:42 +0200
committerTobias Brunner <tobias@strongswan.org>2017-07-03 10:27:53 +0200
commit4a04bd3da5fc3d73b83c924a87db867dc899ec2f (patch)
treeb7e1bf118b772e09b4d49439c3bf06318371d425
parent4471a934818f998841a4a8f5798049520d9c5628 (diff)
downloadstrongswan-4a04bd3da5fc3d73b83c924a87db867dc899ec2f.tar.bz2
strongswan-4a04bd3da5fc3d73b83c924a87db867dc899ec2f.tar.xz
android: Import custom subnets from profile file
-rw-r--r--src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileImportActivity.java29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileImportActivity.java b/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileImportActivity.java
index 16f3530ff..1e9505205 100644
--- a/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileImportActivity.java
+++ b/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileImportActivity.java
@@ -490,16 +490,10 @@ public class VpnProfileImportActivity extends AppCompatActivity
JSONObject split = obj.optJSONObject("split-tunneling");
if (split != null)
{
- String excluded = split.optString("excluded", null);
- if (excluded != null && !excluded.isEmpty())
- {
- if (IPRangeSet.fromString(excluded) == null)
- {
- throw new JSONException(getString(R.string.profile_import_failed_value,
- "split-tunneling.excluded"));
- }
- profile.setExcludedSubnets(excluded);
- }
+ String included = getSubnets(split, "subnets");
+ profile.setIncludedSubnets(included != null ? included : null);
+ String excluded = getSubnets(split, "excluded");
+ profile.setExcludedSubnets(excluded != null ? excluded : null);
int st = 0;
st |= split.optBoolean("block-ipv4") ? VpnProfile.SPLIT_TUNNELING_BLOCK_IPV4 : 0;
st |= split.optBoolean("block-ipv6") ? VpnProfile.SPLIT_TUNNELING_BLOCK_IPV6 : 0;
@@ -514,6 +508,21 @@ public class VpnProfileImportActivity extends AppCompatActivity
return res < min || res > max ? null : res;
}
+ private String getSubnets(JSONObject split, String key) throws JSONException
+ {
+ String subnets = split.optString(key, null);
+ if (subnets != null && !subnets.isEmpty())
+ {
+ if (IPRangeSet.fromString(subnets) == null)
+ {
+ throw new JSONException(getString(R.string.profile_import_failed_value,
+ "split-tunneling." + key));
+ }
+ return subnets;
+ }
+ return null;
+ }
+
/**
* Save or update the profile depending on whether we actually have a
* profile object or not (this was created in updateProfileData)