summaryrefslogtreecommitdiff
path: root/src/de/blinkt/openvpn/OpenVpnService.java
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2012-05-13 01:16:27 +0200
committerArne Schwabe <arne@rfc2549.org>2012-05-13 01:16:27 +0200
commitd0a2ac4569bb15c097ba2c542ae1748ba1edbdc1 (patch)
treef2733212c02f8816a6188c70fd0e358876b90d0e /src/de/blinkt/openvpn/OpenVpnService.java
parenta18032550d38b3530b6488c7c845bda3132b5075 (diff)
Config Import useable (closes issue #14)
Correct save/restore state in Basic Settings (closes issue #17)
Diffstat (limited to 'src/de/blinkt/openvpn/OpenVpnService.java')
-rw-r--r--src/de/blinkt/openvpn/OpenVpnService.java56
1 files changed, 1 insertions, 55 deletions
diff --git a/src/de/blinkt/openvpn/OpenVpnService.java b/src/de/blinkt/openvpn/OpenVpnService.java
index fb60d84c..8a884fcc 100644
--- a/src/de/blinkt/openvpn/OpenVpnService.java
+++ b/src/de/blinkt/openvpn/OpenVpnService.java
@@ -20,6 +20,7 @@ import java.io.IOException;
import java.util.List;
import java.util.Vector;
+
import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.app.PendingIntent;
@@ -54,61 +55,6 @@ public class OpenVpnService extends VpnService implements Handler.Callback {
- class CIDRIP{
- String mIp;
- int len;
- public CIDRIP(String ip, String mask){
- mIp=ip;
- String[] ipt = mask.split("\\.");
- long netmask=0;
-
- netmask += Long.parseLong(ipt[0])<< 24;
- netmask += Integer.parseInt(ipt[1])<< 16;
- netmask += Integer.parseInt(ipt[2])<< 8;
- netmask += Integer.parseInt(ipt[3]);
-
- // Add 33. bit to ensure the loop terminates
- netmask += 1l << 32;
-
- int lenZeros = 0;
- while((netmask & 0x1) == 0) {
- lenZeros++;
- netmask = netmask >> 1;
- }
- // Check if rest of netmask is only 1s
- if(netmask != (0x1ffffffffl >> lenZeros)) {
- // Asume no CIDR, set /32
- len=32;
- } else {
- len =32 -lenZeros;
- }
-
- }
- @Override
- public String toString() {
- return String.format("%s/%d",mIp,len);
- }
-
- public boolean normalise(){
- long ip=0;
-
- String[] ipt = mIp.split("\\.");
-
- ip += Long.parseLong(ipt[0])<< 24;
- ip += Integer.parseInt(ipt[1])<< 16;
- ip += Integer.parseInt(ipt[2])<< 8;
- ip += Integer.parseInt(ipt[3]);
-
- long newip = ip & (0xffffffffl << (32 -len));
- if (newip != ip){
- mIp = String.format("%d.%d.%d.%d", (newip & 0xff000000) >> 24,(newip & 0xff0000) >> 16, (newip & 0xff00) >> 8 ,newip & 0xff);
- return true;
- } else {
- return false;
- }
- }
- }
-
@Override
public void onRevoke() {
OpenVpnManagementThread.stopOpenVPN();