android: Import custom subnets from profile file
This commit is contained in:
+19
-10
@@ -490,16 +490,10 @@ public class VpnProfileImportActivity extends AppCompatActivity
|
|||||||
JSONObject split = obj.optJSONObject("split-tunneling");
|
JSONObject split = obj.optJSONObject("split-tunneling");
|
||||||
if (split != null)
|
if (split != null)
|
||||||
{
|
{
|
||||||
String excluded = split.optString("excluded", null);
|
String included = getSubnets(split, "subnets");
|
||||||
if (excluded != null && !excluded.isEmpty())
|
profile.setIncludedSubnets(included != null ? included : null);
|
||||||
{
|
String excluded = getSubnets(split, "excluded");
|
||||||
if (IPRangeSet.fromString(excluded) == null)
|
profile.setExcludedSubnets(excluded != null ? excluded : null);
|
||||||
{
|
|
||||||
throw new JSONException(getString(R.string.profile_import_failed_value,
|
|
||||||
"split-tunneling.excluded"));
|
|
||||||
}
|
|
||||||
profile.setExcludedSubnets(excluded);
|
|
||||||
}
|
|
||||||
int st = 0;
|
int st = 0;
|
||||||
st |= split.optBoolean("block-ipv4") ? VpnProfile.SPLIT_TUNNELING_BLOCK_IPV4 : 0;
|
st |= split.optBoolean("block-ipv4") ? VpnProfile.SPLIT_TUNNELING_BLOCK_IPV4 : 0;
|
||||||
st |= split.optBoolean("block-ipv6") ? VpnProfile.SPLIT_TUNNELING_BLOCK_IPV6 : 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;
|
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
|
* Save or update the profile depending on whether we actually have a
|
||||||
* profile object or not (this was created in updateProfileData)
|
* profile object or not (this was created in updateProfileData)
|
||||||
|
|||||||
Reference in New Issue
Block a user