]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Make DNS servers configurable in the GUI
authorTobias Brunner <tobias@strongswan.org>
Tue, 5 Mar 2019 16:53:57 +0000 (17:53 +0100)
committerTobias Brunner <tobias@strongswan.org>
Tue, 5 Mar 2019 17:17:56 +0000 (18:17 +0100)
src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileDetailActivity.java
src/frontends/android/app/src/main/res/layout/profile_detail_view.xml
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 75618b5648f1bda8ee3d79f67c30b0c4ecf88c9c..ce7877e5a127ae291324462d87de58512a9daaca 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012-2017 Tobias Brunner
+ * Copyright (C) 2012-2019 Tobias Brunner
  * Copyright (C) 2012 Giuliano Grassi
  * Copyright (C) 2012 Ralf Sager
  * HSR Hochschule fuer Technik Rapperswil
@@ -72,6 +72,8 @@ import org.strongswan.android.utils.Constants;
 import org.strongswan.android.utils.IPRangeSet;
 import org.strongswan.android.utils.Utils;
 
+import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.security.cert.X509Certificate;
 import java.util.ArrayList;
 import java.util.SortedSet;
@@ -138,6 +140,8 @@ public class VpnProfileDetailActivity extends AppCompatActivity
        private EditText mEspProposal;
        private TextView mProfileIdLabel;
        private TextView mProfileId;
+       private MultiAutoCompleteTextView mDnsServers;
+       private TextInputLayoutHelper mDnsServersWrap;
 
        @Override
        public void onCreate(Bundle savedInstanceState)
@@ -176,6 +180,8 @@ public class VpnProfileDetailActivity extends AppCompatActivity
 
                mRemoteId = (MultiAutoCompleteTextView)findViewById(R.id.remote_id);
                mRemoteIdWrap = (TextInputLayoutHelper) findViewById(R.id.remote_id_wrap);
+               mDnsServers = (MultiAutoCompleteTextView)findViewById(R.id.dns_servers);
+               mDnsServersWrap = (TextInputLayoutHelper) findViewById(R.id.dns_servers_wrap);
                mMTU = (EditText)findViewById(R.id.mtu);
                mMTUWrap = (TextInputLayoutHelper) findViewById(R.id.mtu_wrap);
                mPort = (EditText)findViewById(R.id.port);
@@ -573,7 +579,8 @@ public class VpnProfileDetailActivity extends AppCompatActivity
                                   (flags != null && flags != 0) || (st != null && st != 0) ||
                                   mProfile.getIncludedSubnets() != null || mProfile.getExcludedSubnets() != null ||
                                   mProfile.getSelectedAppsHandling() != SelectedAppsHandling.SELECTED_APPS_DISABLE ||
-                                  mProfile.getIkeProposal() != null || mProfile.getEspProposal() != null;
+                                  mProfile.getIkeProposal() != null || mProfile.getEspProposal() != null ||
+                                  mProfile.getDnsServers() != null;
                }
                mShowAdvanced.setVisibility(!show ? View.VISIBLE : View.GONE);
                mAdvancedSettings.setVisibility(show ? View.VISIBLE : View.GONE);
@@ -683,6 +690,11 @@ public class VpnProfileDetailActivity extends AppCompatActivity
                        mEspProposalWrap.setError(getString(R.string.alert_text_no_proposal));
                        valid = false;
                }
+               if (!validateAddresses(mDnsServers))
+               {
+                       mDnsServersWrap.setError(getString(R.string.alert_text_no_ips));
+                       valid = false;
+               }
                return valid;
        }
 
@@ -737,6 +749,8 @@ public class VpnProfileDetailActivity extends AppCompatActivity
                mProfile.setIkeProposal(ike.isEmpty() ? null : ike);
                String esp = mEspProposal.getText().toString().trim();
                mProfile.setEspProposal(esp.isEmpty() ? null : esp);
+               String dns = mDnsServers.getText().toString().trim();
+               mProfile.setDnsServers(dns.isEmpty() ? null : dns);
        }
 
        /**
@@ -772,6 +786,7 @@ public class VpnProfileDetailActivity extends AppCompatActivity
                                mSelectedApps = mProfile.getSelectedAppsSet();
                                mIkeProposal.setText(mProfile.getIkeProposal());
                                mEspProposal.setText(mProfile.getEspProposal());
+                               mDnsServers.setText(mProfile.getDnsServers());
                                mProfileId.setText(mProfile.getUUID().toString());
                                flags = mProfile.getFlags();
                                useralias = mProfile.getUserCertificateAlias();
@@ -884,6 +899,32 @@ public class VpnProfileDetailActivity extends AppCompatActivity
                return value.isEmpty() || IPRangeSet.fromString(value) != null;
        }
 
+       /**
+        * Check that the value in the given text box is a valid list of IP addresses
+        *
+        * @param view text box
+        */
+       private boolean validateAddresses(EditText view)
+       {
+               String value = view.getText().toString().trim();
+               if (value.isEmpty())
+               {
+                       return true;
+               }
+               for (String addr : value.split("\\s+"))
+               {
+                       try
+                       {
+                               InetAddress.getByName(addr);
+                       }
+                       catch (UnknownHostException e)
+                       {
+                               return false;
+                       }
+               }
+               return true;
+       }
+
        /**
         * Check that the value in the given text box is a valid proposal
         *
index 3cf0b552d427a7196c6ede0edcb7615d7425b0ca..671c58d67d000661eea9cb8b3cfac312a01e44f0 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
-    Copyright (C) 2012-2018 Tobias Brunner
+    Copyright (C) 2012-2019 Tobias Brunner
     Copyright (C) 2012 Giuliano Grassi
     Copyright (C) 2012 Ralf Sager
     HSR Hochschule fuer Technik Rapperswil
 
             </org.strongswan.android.ui.widget.TextInputLayoutHelper>
 
+            <org.strongswan.android.ui.widget.TextInputLayoutHelper
+                android:id="@+id/dns_servers_wrap"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="10dp"
+                android:hint="@string/profile_dns_servers_label"
+                app:helper_text="@string/profile_dns_servers_hint" >
+
+                <MultiAutoCompleteTextView
+                    android:id="@+id/dns_servers"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:singleLine="true"
+                    android:inputType="textNoSuggestions"
+                    android:completionThreshold="1" />
+
+            </org.strongswan.android.ui.widget.TextInputLayoutHelper>
+
             <org.strongswan.android.ui.widget.TextInputLayoutHelper
                 android:id="@+id/mtu_wrap"
                 android:layout_width="match_parent"
index 8f1e99a773b953fdacf303c396914b1dfc566cff..f7fc36dc89502612a830c60d68688520f81acc19 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
-    Copyright (C) 2012-2018 Tobias Brunner
+    Copyright (C) 2012-2019 Tobias Brunner
     Copyright (C) 2012 Giuliano Grassi
     Copyright (C) 2012 Ralf Sager
     HSR Hochschule fuer Technik Rapperswil
@@ -85,6 +85,8 @@
     <string name="profile_remote_id_label">Server-Identität</string>
     <string name="profile_remote_id_hint">Standardwert ist der konfigurierte Server. Eigene Werte werden explizit an den Server gesendet und während der Authentifizierung erzwungen</string>
     <string name="profile_remote_id_hint_gateway">Standardwert ist \"%1$s\". Eigene Werte werden explizit an den Server gesendet und während der Authentifizierung erzwungen</string>
+    <string name="profile_dns_servers_label">DNS Server</string>
+    <string name="profile_dns_servers_hint">Benutzerdefinierte DNS Server bei Verbindung zum VPN (mit Leerzeichen getrennt, z.B.. \"8.8.8.8 2001:4860:4860::8888\", standardmässig werden die vom VPN Server erhaltenen Server verwendet)</string>
     <string name="profile_mtu_label">MTU des VPN Tunnel-Device</string>
     <string name="profile_mtu_hint">Falls der Standardwert in einem bestimmten Netzwerk nicht geeignet ist</string>
     <string name="profile_port_label">Server Port</string>
     <string name="alert_text_nocertfound">Bitte wählen Sie eines aus oder aktivieren Sie <i>Automatisch wählen</i></string>
     <string name="alert_text_out_of_range">Bitte geben Sie eine Nummer von %1$d - %2$d ein</string>
     <string name="alert_text_no_subnets">Bitte geben Sie mit Leerzeichen getrennte, gültige Subnetzte und/oder IP-Adressen ein</string>
+    <string name="alert_text_no_ips">Bitte geben Sie mit Leerzeichen getrennte, gültige IP-Adressen ein</string>
     <string name="alert_text_no_proposal">Bitte geben Sie eine mit Bindestrichen getrennte, gültige Liste von Algorithmen ein</string>
     <string name="tnc_notice_title">EAP-TNC kann Ihre Privatsphäre beeinträchtigen</string>
     <string name="tnc_notice_subtitle">Gerätedaten werden an den Server-Betreiber gesendet</string>
index bd80077e615b979d15870fac01cd291bcf600066..b202b6706e3261afad69d82f352f405b92bafa69 100644 (file)
@@ -85,6 +85,8 @@
     <string name="profile_remote_id_label">Server identity</string>
     <string name="profile_remote_id_hint">Defaults to the configured server. Custom values are explicitly sent to the server and enforced during authentication</string>
     <string name="profile_remote_id_hint_gateway">Defaults to \"%1$s\". Custom values are explicitly sent to the server and enforced during authentication</string>
+    <string name="profile_dns_servers_label">DNS servers</string>
+    <string name="profile_dns_servers_hint">Custom DNS servers to use when connected to the VPN (separated by spaces, e.g. \"8.8.8.8 2001:4860:4860::8888\", defaults to those received from the VPN server)</string>
     <string name="profile_mtu_label">MTU of the VPN tunnel device</string>
     <string name="profile_mtu_hint">In case the default value is unsuitable for a particular network</string>
     <string name="profile_port_label">Server port</string>
     <string name="alert_text_nocertfound">Wybierz lub uaktywnij jeden <i>Wybierz automatycznie</i></string>
     <string name="alert_text_out_of_range">Please enter a number in the range from %1$d - %2$d</string>
     <string name="alert_text_no_subnets">Please enter valid subnets and/or IP addresses, separated by spaces</string>
+    <string name="alert_text_no_ips">Please enter valid IP addresses, separated by spaces</string>
     <string name="alert_text_no_proposal">Please enter a valid list of algorithms, separated by hyphens</string>
     <string name="tnc_notice_title">EAP-TNC may affect your privacy</string>
     <string name="tnc_notice_subtitle">Device data is sent to the server operator</string>
index 5f796bdad85d1a3581f9632c5836183e8b0bdf38..1f81587dc87f34a90533ac40f103d9bc343d5a1a 100644 (file)
@@ -82,6 +82,8 @@
     <string name="profile_remote_id_label">Server identity</string>
     <string name="profile_remote_id_hint">Defaults to the configured server. Custom values are explicitly sent to the server and enforced during authentication</string>
     <string name="profile_remote_id_hint_gateway">Defaults to \"%1$s\". Custom values are explicitly sent to the server and enforced during authentication</string>
+    <string name="profile_dns_servers_label">DNS servers</string>
+    <string name="profile_dns_servers_hint">Custom DNS servers to use when connected to the VPN (separated by spaces, e.g. \"8.8.8.8 2001:4860:4860::8888\", defaults to those received from the VPN server)</string>
     <string name="profile_mtu_label">MTU of the VPN tunnel device</string>
     <string name="profile_mtu_hint">In case the default value is unsuitable for a particular network</string>
     <string name="profile_port_label">Server port</string>
     <string name="alert_text_nocertfound">Пожалуйста выберите один <i>Выбрать автоматически</i></string>
     <string name="alert_text_out_of_range">Please enter a number in the range from %1$d - %2$d</string>
     <string name="alert_text_no_subnets">Please enter valid subnets and/or IP addresses, separated by spaces</string>
+    <string name="alert_text_no_ips">Please enter valid IP addresses, separated by spaces</string>
     <string name="alert_text_no_proposal">Please enter a valid list of algorithms, separated by hyphens</string>
     <string name="tnc_notice_title">EAP-TNC may affect your privacy</string>
     <string name="tnc_notice_subtitle">Device data is sent to the server operator</string>
index e385df5e109774355a55209ba515e57663c962fa..95fdd428af0b35eb4de025a8725802768bef663e 100644 (file)
@@ -83,6 +83,8 @@
     <string name="profile_remote_id_label">Server identity</string>
     <string name="profile_remote_id_hint">Defaults to the configured server. Custom values are explicitly sent to the server and enforced during authentication</string>
     <string name="profile_remote_id_hint_gateway">Defaults to \"%1$s\". Custom values are explicitly sent to the server and enforced during authentication</string>
+    <string name="profile_dns_servers_label">DNS servers</string>
+    <string name="profile_dns_servers_hint">Custom DNS servers to use when connected to the VPN (separated by spaces, e.g. \"8.8.8.8 2001:4860:4860::8888\", defaults to those received from the VPN server)</string>
     <string name="profile_mtu_label">MTU of the VPN tunnel device</string>
     <string name="profile_mtu_hint">In case the default value is unsuitable for a particular network</string>
     <string name="profile_port_label">Server port</string>
     <string name="alert_text_nocertfound">Будь ласка виберіть один <i>Вибрати автоматично</i></string>
     <string name="alert_text_out_of_range">Please enter a number in the range from %1$d - %2$d</string>
     <string name="alert_text_no_subnets">Please enter valid subnets and/or IP addresses, separated by spaces</string>
+    <string name="alert_text_no_ips">Please enter valid IP addresses, separated by spaces</string>
     <string name="alert_text_no_proposal">Please enter a valid list of algorithms, separated by hyphens</string>
     <string name="tnc_notice_title">EAP-TNC may affect your privacy</string>
     <string name="tnc_notice_subtitle">Device data is sent to the server operator</string>
index bb6e70d3aacb50c3dca267425ddef8946a126e3d..006ad535901872ac518fe024d87da2224b843b1d 100644 (file)
     <string name="alert_text_nocertfound">请选择一项或激活 <i>自动选择</i></string>
     <string name="alert_text_out_of_range">请输入一个数字范围从%1$d到%2$d</string>
     <string name="alert_text_no_subnets">Please enter valid subnets and/or IP addresses, separated by spaces</string>
+    <string name="alert_text_no_ips">Please enter valid IP addresses, separated by spaces</string>
     <string name="alert_text_no_proposal">Please enter a valid list of algorithms, separated by hyphens</string>
     <string name="tnc_notice_title">EAP-TNC可能会影响您的隐私</string>
     <string name="tnc_notice_subtitle">设备数据已被发送至服务器管理员</string>
index a1777b6422303866ccb693cc53929eaa85a1210a..12666ca55d04216d310a783db3ebe502a0cbe1d8 100644 (file)
@@ -82,6 +82,8 @@
     <string name="profile_remote_id_label">伺服器ID</string>
     <string name="profile_remote_id_hint">預設為已設定的伺服器位置。自訂值會在授權期間送到伺服器</string>
     <string name="profile_remote_id_hint_gateway">預設為 \"%1$s\"。自訂值會在授權期間送到伺服器</string>
+    <string name="profile_dns_servers_label">DNS servers</string>
+    <string name="profile_dns_servers_hint">Custom DNS servers to use when connected to the VPN (separated by spaces, e.g. \"8.8.8.8 2001:4860:4860::8888\", defaults to those received from the VPN server)</string>
     <string name="profile_mtu_label">VPN通道裝置的MTU值</string>
     <string name="profile_mtu_hint">如果在某個網路下預設值不適合</string>
     <string name="profile_port_label">伺服器Port</string>
     <string name="alert_text_nocertfound">請選擇一項或啟動 <i>自動選擇</i></string>
     <string name="alert_text_out_of_range">請輸入一個數字範圍從%1$d到%2$d</string>
     <string name="alert_text_no_subnets">Please enter valid subnets and/or IP addresses, separated by spaces</string>
+    <string name="alert_text_no_ips">Please enter valid IP addresses, separated by spaces</string>
     <string name="alert_text_no_proposal">Please enter a valid list of algorithms, separated by hyphens</string>
     <string name="tnc_notice_title">EAP-TNC可能會影響您的隱私安全</string>
     <string name="tnc_notice_subtitle">裝置資料已經發送給伺服器管理者</string>
index 9797f57a6c7487fafcb14c80afd229774c91fdd9..e86e84b5a606012fc1de8acccf1f608e287be017 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
-    Copyright (C) 2012-2018 Tobias Brunner
+    Copyright (C) 2012-2019 Tobias Brunner
     Copyright (C) 2012 Giuliano Grassi
     Copyright (C) 2012 Ralf Sager
     HSR Hochschule fuer Technik Rapperswil
@@ -85,6 +85,8 @@
     <string name="profile_remote_id_label">Server identity</string>
     <string name="profile_remote_id_hint">Defaults to the configured server. Custom values are explicitly sent to the server and enforced during authentication</string>
     <string name="profile_remote_id_hint_gateway">Defaults to \"%1$s\". Custom values are explicitly sent to the server and enforced during authentication</string>
+    <string name="profile_dns_servers_label">DNS servers</string>
+    <string name="profile_dns_servers_hint">Custom DNS servers to use when connected to the VPN (separated by spaces, e.g. \"8.8.8.8 2001:4860:4860::8888\", defaults to those received from the VPN server)</string>
     <string name="profile_mtu_label">MTU of the VPN tunnel device</string>
     <string name="profile_mtu_hint">In case the default value is unsuitable for a particular network</string>
     <string name="profile_port_label">Server port</string>
     <string name="alert_text_nocertfound">Please select one or activate <i>Select automatically</i></string>
     <string name="alert_text_out_of_range">Please enter a number in the range from %1$d - %2$d</string>
     <string name="alert_text_no_subnets">Please enter valid subnets and/or IP addresses, separated by spaces</string>
+    <string name="alert_text_no_ips">Please enter valid IP addresses, separated by spaces</string>
     <string name="alert_text_no_proposal">Please enter a valid list of algorithms, separated by hyphens</string>
     <string name="tnc_notice_title">EAP-TNC may affect your privacy</string>
     <string name="tnc_notice_subtitle">Device data is sent to the server operator</string>