diff options
author | Arne Schwabe <arne@rfc2549.org> | 2014-02-17 19:50:36 +0100 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2014-02-17 19:50:36 +0100 |
commit | b79286ec96f5853ba53a73b62b985b12d87d8af0 (patch) | |
tree | 20c1d22a53ae0624cc19ccd7df91b8e3e2418529 /main/src | |
parent | 0c3f0cae9bcfc862052e9ccc137a63f9587002a2 (diff) |
BigInteger arithmetic is slow as hell. Cache getFirst/Last address
Diffstat (limited to 'main/src')
-rw-r--r-- | main/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java | 10 | ||||
-rwxr-xr-x | main/src/main/res/values/strings.xml | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java b/main/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java index c7d09065..54470962 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java +++ b/main/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java @@ -15,6 +15,8 @@ public class NetworkSpace { public int networkMask; private boolean included; private boolean isV4; + private BigInteger firstaddr; + private BigInteger lastaddr; @Override @@ -55,12 +57,16 @@ public class NetworkSpace { } public BigInteger getLastAddress() { - return getMaskedAddress(true); + if(lastaddr==null) + lastaddr= getMaskedAddress(true); + return lastaddr; } public BigInteger getFirstAddress() { - return getMaskedAddress(false); + if (firstaddr==null) + firstaddr=getMaskedAddress(false); + return firstaddr; } diff --git a/main/src/main/res/values/strings.xml b/main/src/main/res/values/strings.xml index 8c643f6d..3b9b9c0f 100755 --- a/main/src/main/res/values/strings.xml +++ b/main/src/main/res/values/strings.xml @@ -220,7 +220,7 @@ <string name="openvpn_log">OpenVPN Log</string> <string name="import_config">Import OpenVPN configuration</string> <string name="battery_consumption_title">Battery consumption</string> - <string name="baterry_consumption">In my personal tests the main reason for high battery consumption of OpenVPN are the keepalive packets. Most OpenVPN servers have a configuration directive like \'keepalive 10 60\' which causes the client and server to exchange keepalive packets every ten seconds. <p> While these packets are small and do not use much traffic, they keep the mobile radio network busy and increase the energy consumption. (See also <a href="http://developer.android.com/training/efficient-downloads/efficient-network-access.html#RadioStateMachine">The Radio State Machine | Android Developers</a>) <p> This keepalive setting cannot be changed on the client. Only the system administrator of the OpenVPN can change the setting. <p> Unfortunately using a keepalive larger than 60 seconds with UDP can cause some NAT gateways to drop the connection due to an inactivity timeout. Using TCP with a long keepalive timeout works, but tunneling TCP over TCP performs extremely poorly on connections with high packet loss. (See <a href="http://sites.inka.de/bigred/devel/tcp-tcp.html">Why TCP Over TCP Is A Bad Idea</a>)</string> + <string name="baterry_consumption">In my personal tests the main reason for high battery consumption of OpenVPN are the keepalive packets. Most OpenVPN servers have a configuration directive like \'keepalive 10 60\' which causes the client and server to exchange keepalive packets every ten seconds. <p> While these packets are small and do not use much traffic, they keep the mobile radio network busy and increase the energy consumption. (See also <a href="http://developer.android.com/training/efficient-downloads/efficient-network-access.html#RadioStateMachine">The Radio State Machine | Android Developers</a>) <p> This keepalive setting cannot be changed on the client. Only the system administrator of the OpenVPN can change the setting. <p> Unfortunately using a keepalive larger than 60 seconds with UDP can cause some NAT gateways to drop the connection due to an inactivity timeout. Using TCP with a long keep alive timeout works, but tunneling TCP over TCP performs extremely poorly on connections with high packet loss. (See <a href="http://sites.inka.de/bigred/devel/tcp-tcp.html">Why TCP Over TCP Is A Bad Idea</a>)</string> <string name="faq_tethering">The Android Tethering feature (over WiFi, USB or Bluetooth) and the VPNService API (used by this program) do not work together. For more details see the <a href=\"http://code.google.com/p/ics-openvpn/issues/detail?id=34\">issue #34</a></string> <string name="vpn_tethering_title">VPN and Tethering</string> <string name="connection_retries">Connection retries</string> |