android: Import excluded subnets from profile file
authorTobias Brunner <tobias@strongswan.org>
Wed, 21 Jun 2017 16:23:33 +0000 (18:23 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 3 Jul 2017 08:27:52 +0000 (10:27 +0200)
src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileImportActivity.java
src/frontends/android/app/src/main/res/values-de/strings.xml
src/frontends/android/app/src/main/res/values-pl/strings.xml
src/frontends/android/app/src/main/res/values-ru/strings.xml
src/frontends/android/app/src/main/res/values-ua/strings.xml
src/frontends/android/app/src/main/res/values-zh-rCN/strings.xml
src/frontends/android/app/src/main/res/values-zh-rTW/strings.xml
src/frontends/android/app/src/main/res/values/strings.xml

index 679e419..16f3530 100644 (file)
@@ -55,6 +55,7 @@ import org.strongswan.android.logic.TrustedCertificateManager;
 import org.strongswan.android.security.TrustedCertificateEntry;
 import org.strongswan.android.ui.widget.TextInputLayoutHelper;
 import org.strongswan.android.utils.Constants;
+import org.strongswan.android.utils.IPRangeSet;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -489,6 +490,16 @@ 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);
+                       }
                        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;
index 0bb73cb..941c163 100644 (file)
@@ -88,6 +88,7 @@
     <string name="profile_import_failed_not_found">Datei nicht gefunden</string>
     <string name="profile_import_failed_host">Host unbekannt</string>
     <string name="profile_import_failed_tls">TLS-Handshake fehlgeschlagen</string>
+    <string name="profile_import_failed_value">Ungültiger Wert in \"%1$s\"</string>
     <string name="profile_import_exists">Dieses VPN Profil existiert bereits, die bestehenden Einstellungen werden ersetzt.</string>
     <string name="profile_cert_import">Zertifikat aus VPN Profil importieren</string>
     <string name="profile_cert_alias">Zertifikat für \"%1$s\"</string>
index 36cdff6..08d11c6 100644 (file)
@@ -88,6 +88,7 @@
     <string name="profile_import_failed_not_found">File not found</string>
     <string name="profile_import_failed_host">Host unknown</string>
     <string name="profile_import_failed_tls">TLS handshake failed</string>
+    <string name="profile_import_failed_value">Invalid value in \"%1$s\"</string>
     <string name="profile_import_exists">This VPN profile already exists, its current settings will be replaced.</string>
     <string name="profile_cert_import">Import certificate from VPN profile</string>
     <string name="profile_cert_alias">Certificate for \"%1$s\"</string>
index 6f336fd..092d734 100644 (file)
@@ -85,6 +85,7 @@
     <string name="profile_import_failed_not_found">File not found</string>
     <string name="profile_import_failed_host">Host unknown</string>
     <string name="profile_import_failed_tls">TLS handshake failed</string>
+    <string name="profile_import_failed_value">Invalid value in \"%1$s\"</string>
     <string name="profile_import_exists">This VPN profile already exists, its current settings will be replaced.</string>
     <string name="profile_cert_import">Import certificate from VPN profile</string>
     <string name="profile_cert_alias">Certificate for \"%1$s\"</string>
index e8cdc53..b1b7103 100644 (file)
@@ -86,6 +86,7 @@
     <string name="profile_import_failed_not_found">File not found</string>
     <string name="profile_import_failed_host">Host unknown</string>
     <string name="profile_import_failed_tls">TLS handshake failed</string>
+    <string name="profile_import_failed_value">Invalid value in \"%1$s\"</string>
     <string name="profile_import_exists">This VPN profile already exists, its current settings will be replaced.</string>
     <string name="profile_cert_import">Import certificate from VPN profile</string>
     <string name="profile_cert_alias">Certificate for \"%1$s\"</string>
index 591aea4..e9ad8e0 100644 (file)
@@ -85,6 +85,7 @@
     <string name="profile_import_failed_not_found">文件未找到</string>
     <string name="profile_import_failed_host">未知主机</string>
     <string name="profile_import_failed_tls">TLS握手失败</string>
+    <string name="profile_import_failed_value">Invalid value in \"%1$s\"</string>
     <string name="profile_import_exists">此VPN配置已经存在,当前设定将被覆盖。</string>
     <string name="profile_cert_import">从VPN配置导入证书</string>
     <string name="profile_cert_alias">\"%1$s\" 所对应的证书</string>
index 79eb301..3be4a6d 100644 (file)
@@ -85,6 +85,7 @@
     <string name="profile_import_failed_not_found">沒有找到檔案</string>
     <string name="profile_import_failed_host">不明主機</string>
     <string name="profile_import_failed_tls">TLS連線失敗</string>
+    <string name="profile_import_failed_value">Invalid value in \"%1$s\"</string>
     <string name="profile_import_exists">這個VPN設定檔已經存在,當前設定檔會被覆蓋。</string>
     <string name="profile_cert_import">從VPN設定檔匯入憑證</string>
     <string name="profile_cert_alias">\"%1$s\" 對應的憑證</string>
index 3577d97..1e9a0ee 100644 (file)
@@ -88,6 +88,7 @@
     <string name="profile_import_failed_not_found">File not found</string>
     <string name="profile_import_failed_host">Host unknown</string>
     <string name="profile_import_failed_tls">TLS handshake failed</string>
+    <string name="profile_import_failed_value">Invalid value in \"%1$s\"</string>
     <string name="profile_import_exists">This VPN profile already exists, its current settings will be replaced.</string>
     <string name="profile_cert_import">Import certificate from VPN profile</string>
     <string name="profile_cert_alias">Certificate for \"%1$s\"</string>