]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Make NAT-T keepalive interval configurable in the GUI
authorTobias Brunner <tobias@strongswan.org>
Wed, 28 Jun 2017 16:44:45 +0000 (18:44 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 3 Jul 2017 08:33:29 +0000 (10:33 +0200)
src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileDetailActivity.java
src/frontends/android/app/src/main/java/org/strongswan/android/utils/Constants.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 0bae6142d916642b75759ff8539e6716756899d7..1b1494be8f0cf856fd426dd93dd4fb84a6a12d56 100644 (file)
@@ -113,6 +113,8 @@ public class VpnProfileDetailActivity extends AppCompatActivity
        private TextInputLayoutHelper mMTUWrap;
        private EditText mPort;
        private TextInputLayoutHelper mPortWrap;
+       private EditText mNATKeepalive;
+       private TextInputLayoutHelper mNATKeepaliveWrap;
        private EditText mIncludedSubnets;
        private TextInputLayoutHelper mIncludedSubnetsWrap;
        private EditText mExcludedSubnets;
@@ -163,6 +165,8 @@ public class VpnProfileDetailActivity extends AppCompatActivity
                mMTUWrap = (TextInputLayoutHelper) findViewById(R.id.mtu_wrap);
                mPort = (EditText)findViewById(R.id.port);
                mPortWrap = (TextInputLayoutHelper) findViewById(R.id.port_wrap);
+               mNATKeepalive = (EditText)findViewById(R.id.nat_keepalive);
+               mNATKeepaliveWrap = (TextInputLayoutHelper) findViewById(R.id.nat_keepalive_wrap);
                mIncludedSubnets = (EditText)findViewById(R.id.included_subnets);
                mIncludedSubnetsWrap = (TextInputLayoutHelper)findViewById(R.id.included_subnets_wrap);
                mExcludedSubnets = (EditText)findViewById(R.id.excluded_subnets);
@@ -528,7 +532,7 @@ public class VpnProfileDetailActivity extends AppCompatActivity
                {
                        Integer st = mProfile.getSplitTunneling();
                        show = mProfile.getRemoteId() != null || mProfile.getMTU() != null ||
-                                  mProfile.getPort() != null || (st != null && st != 0) ||
+                                  mProfile.getPort() != null || mProfile.getNATKeepAlive() != null || (st != null && st != 0) ||
                                   mProfile.getIncludedSubnets() != null || mProfile.getExcludedSubnets() != null ||
                                   mProfile.getSelectedAppsHandling() != SelectedAppsHandling.SELECTED_APPS_DISABLE;
                }
@@ -618,6 +622,12 @@ public class VpnProfileDetailActivity extends AppCompatActivity
                        mPortWrap.setError(String.format(getString(R.string.alert_text_out_of_range), 1, 65535));
                        valid = false;
                }
+               if (!validateInteger(mNATKeepalive, Constants.NAT_KEEPALIVE_MIN, Constants.NAT_KEEPALIVE_MAX))
+               {
+                       mNATKeepaliveWrap.setError(String.format(getString(R.string.alert_text_out_of_range),
+                                                                                                        Constants.NAT_KEEPALIVE_MIN, Constants.NAT_KEEPALIVE_MAX));
+                       valid = false;
+               }
                return valid;
        }
 
@@ -650,6 +660,7 @@ public class VpnProfileDetailActivity extends AppCompatActivity
                mProfile.setRemoteId(remote_id.isEmpty() ? null : remote_id);
                mProfile.setMTU(getInteger(mMTU));
                mProfile.setPort(getInteger(mPort));
+               mProfile.setNATKeepAlive(getInteger(mNATKeepalive));
                String included = mIncludedSubnets.getText().toString().trim();
                mProfile.setIncludedSubnets(included.isEmpty() ? null : included);
                String excluded = mExcludedSubnets.getText().toString().trim();
@@ -685,6 +696,7 @@ public class VpnProfileDetailActivity extends AppCompatActivity
                                mRemoteId.setText(mProfile.getRemoteId());
                                mMTU.setText(mProfile.getMTU() != null ? mProfile.getMTU().toString() : null);
                                mPort.setText(mProfile.getPort() != null ? mProfile.getPort().toString() : null);
+                               mNATKeepalive.setText(mProfile.getNATKeepAlive() != null ? mProfile.getNATKeepAlive().toString() : null);
                                mIncludedSubnets.setText(mProfile.getIncludedSubnets());
                                mExcludedSubnets.setText(mProfile.getExcludedSubnets());
                                mBlockIPv4.setChecked(mProfile.getSplitTunneling() != null && (mProfile.getSplitTunneling() & VpnProfile.SPLIT_TUNNELING_BLOCK_IPV4) != 0);
index 413ecae97f35e84a2b4e666255c3b8382171e32a..487ea017bd202eb1d4ab200261c0efe9543e6379 100644 (file)
@@ -37,4 +37,10 @@ public final class Constants
         */
        public static final int MTU_MAX = 1500;
        public static final int MTU_MIN = 1280;
+
+       /**
+        * Limits for NAT-T keepalive
+        */
+       public static final int NAT_KEEPALIVE_MAX = 120;
+       public static final int NAT_KEEPALIVE_MIN = 10;
 }
index 8b153b89a30af6b69b9d0c81d51cdfd2e0ebee36..472efbc83a347f4cff132f47127aa17f0fbe2aa1 100644 (file)
 
             </org.strongswan.android.ui.widget.TextInputLayoutHelper>
 
+            <org.strongswan.android.ui.widget.TextInputLayoutHelper
+                android:id="@+id/nat_keepalive_wrap"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                app:helper_text="@string/profile_nat_keepalive_hint" >
+
+                <android.support.design.widget.TextInputEditText
+                    android:id="@+id/nat_keepalive"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:singleLine="true"
+                    android:inputType="number|textNoSuggestions"
+                    android:hint="@string/profile_nat_keepalive_label" />
+
+            </org.strongswan.android.ui.widget.TextInputLayoutHelper>
+
             <TextView
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
index 5c5a22a64086055bbabb7d579ab467f956036e0d..c7c4160f225c122ffb674fa88bf7fe81ed113783 100644 (file)
@@ -79,6 +79,8 @@
     <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="profile_port_hint">UDP-Port zu dem verbunden wird, falls dieser vom Standard-Port abweicht</string>
+    <string name="profile_nat_keepalive_label">NAT-T Keepalive Intervall</string>
+    <string name="profile_nat_keepalive_hint">Kleine Pakete werden gesendet, um Mappings auf NAT-Routern am Leben zu erhalten, wenn sonst nichts gesendet wird. Um Energie zu sparen, ist das Standardintervall auf 45 Sekunden gesetzt. Hinter NAT-Routern die Mappings früh entfernen, ist dies möglicherweise zu hoch. 20 Sekunden oder weniger können in diesem Fall helfen.</string>
     <string name="profile_split_tunneling_label">Split-Tunneling</string>
     <string name="profile_split_tunneling_intro">Standardmässig leitet der Client allen Netzwerkverkehr durch den VPN Tunnel, ausser der Server schränkt die Subnetze beim Verbindungsaufbau ein, in welchem Fall nur der Verkehr via VPN geleitet wird, den der Server erlaubt (der Rest wird standardmässig behandelt, als ob kein VPN vorhanden wäre).</string>
     <string name="profile_split_tunnelingv4_title">Blockiere IPv4 Verkehr der nicht für das VPN bestimmt ist</string>
index d8965a1e45bde8f751f4a0d364bd9d5dad4877f3..d551909945e4203d9b43d6f7a15cb4e21a963e77 100644 (file)
@@ -79,6 +79,8 @@
     <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="profile_port_hint">UDP port to connect to, if different from the default</string>
+    <string name="profile_nat_keepalive_label">NAT-T keepalive interval</string>
+    <string name="profile_nat_keepalive_hint">Small packets are sent to keep mappings on NAT routers alive if there is no other traffic. In order to save energy the default interval is 45 seconds. Behind NAT routers that remove mappings early this might be too high, try 20 seconds or less in that case.</string>
     <string name="profile_split_tunneling_label">Split tunneling</string>
     <string name="profile_split_tunneling_intro">By default, the client will route all network traffic through the VPN, unless the server narrows the subnets when the connection is established, in which case only traffic the server allows will be routed via VPN (by default, all other traffic is routed as if there was no VPN).</string>
     <string name="profile_split_tunnelingv4_title">Block IPv4 traffic not destined for the VPN</string>
index 7296554d87b242570617e387bb00cd4b0e1861cc..666e5be0834a0661f3b6cc155450a841f6de9a1d 100644 (file)
@@ -76,6 +76,8 @@
     <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="profile_port_hint">UDP port to connect to, if different from the default</string>
+    <string name="profile_nat_keepalive_label">NAT-T keepalive interval</string>
+    <string name="profile_nat_keepalive_hint">Small packets are sent to keep mappings on NAT routers alive if there is no other traffic. In order to save energy the default interval is 45 seconds. Behind NAT routers that remove mappings early this might be too high, try 20 seconds or less in that case.</string>
     <string name="profile_split_tunneling_label">Split tunneling</string>
     <string name="profile_split_tunneling_intro">By default, the client will route all network traffic through the VPN, unless the server narrows the subnets when the connection is established, in which case only traffic the server allows will be routed via VPN (by default, all other traffic is routed as if there was no VPN).</string>
     <string name="profile_split_tunnelingv4_title">Block IPv4 traffic not destined for the VPN</string>
index 6f30fcf16e4a43df6f6454aceadab0f55a40bab4..2ba7ef86415402309edb88912089d11627081d90 100644 (file)
@@ -77,6 +77,8 @@
     <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="profile_port_hint">UDP port to connect to, if different from the default</string>
+    <string name="profile_nat_keepalive_label">NAT-T keepalive interval</string>
+    <string name="profile_nat_keepalive_hint">Small packets are sent to keep mappings on NAT routers alive if there is no other traffic. In order to save energy the default interval is 45 seconds. Behind NAT routers that remove mappings early this might be too high, try 20 seconds or less in that case.</string>
     <string name="profile_split_tunneling_label">Split tunneling</string>
     <string name="profile_split_tunneling_intro">By default, the client will route all network traffic through the VPN, unless the server narrows the subnets when the connection is established, in which case only traffic the server allows will be routed via VPN (by default, all other traffic is routed as if there was no VPN).</string>
     <string name="profile_split_tunnelingv4_title">Block IPv4 traffic not destined for the VPN</string>
index 415212eab1a3128c4f70dfa410f10456d9b1d940..b8fccadadfd68ee1bab83d4aeafae3f746284a6e 100644 (file)
@@ -76,6 +76,8 @@
     <string name="profile_mtu_hint">假如在某一网络下默认值不合适</string>
     <string name="profile_port_label">服务器端口</string>
     <string name="profile_port_hint">如不同于默认值,则所需连接的UDP端口</string>
+    <string name="profile_nat_keepalive_label">NAT-T keepalive interval</string>
+    <string name="profile_nat_keepalive_hint">Small packets are sent to keep mappings on NAT routers alive if there is no other traffic. In order to save energy the default interval is 45 seconds. Behind NAT routers that remove mappings early this might be too high, try 20 seconds or less in that case.</string>
     <string name="profile_split_tunneling_label">拆分隧道</string>
     <string name="profile_split_tunneling_intro">By default, the client will route all network traffic through the VPN, unless the server narrows the subnets when the connection is established, in which case only traffic the server allows will be routed via VPN (by default, all other traffic is routed as if there was no VPN).</string>
     <string name="profile_split_tunnelingv4_title">屏蔽不通过VPN的IPV4流量</string>
index e1cdf32e54af76a2352fc02a008c09c2ffdc623c..2108a8b304e29947610ee047e78bef319fc1c3b2 100644 (file)
@@ -76,6 +76,8 @@
     <string name="profile_mtu_hint">如果在某個網路下預設值不適合</string>
     <string name="profile_port_label">伺服器Port</string>
     <string name="profile_port_hint">如果和預設值不同,則需要連接的UDP Port</string>
+    <string name="profile_nat_keepalive_label">NAT-T keepalive interval</string>
+    <string name="profile_nat_keepalive_hint">Small packets are sent to keep mappings on NAT routers alive if there is no other traffic. In order to save energy the default interval is 45 seconds. Behind NAT routers that remove mappings early this might be too high, try 20 seconds or less in that case.</string>
     <string name="profile_split_tunneling_label">拆分隧道</string>
     <string name="profile_split_tunneling_intro">By default, the client will route all network traffic through the VPN, unless the server narrows the subnets when the connection is established, in which case only traffic the server allows will be routed via VPN (by default, all other traffic is routed as if there was no VPN).</string>
     <string name="profile_split_tunnelingv4_title">屏蔽不通过VPN的IPV4流量</string>
index fa38753c2d2047b2a527046685a0c4d1c27f8ed0..0f22cc8cf992caa3d043c40cc8e5b56f36a855c9 100644 (file)
@@ -79,6 +79,8 @@
     <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="profile_port_hint">UDP port to connect to, if different from the default</string>
+    <string name="profile_nat_keepalive_label">NAT-T keepalive interval</string>
+    <string name="profile_nat_keepalive_hint">Small packets are sent to keep mappings on NAT routers alive if there is no other traffic. In order to save energy the default interval is 45 seconds. Behind NAT routers that remove mappings early this might be too high, try 20 seconds or less in that case.</string>
     <string name="profile_split_tunneling_label">Split tunneling</string>
     <string name="profile_split_tunneling_intro">By default, the client will route all network traffic through the VPN, unless the server narrows the subnets when the connection is established, in which case only traffic the server allows will be routed via VPN (by default, all other traffic is routed as if there was no VPN).</string>
     <string name="profile_split_tunnelingv4_title">Block IPv4 traffic not destined for the VPN</string>