summaryrefslogtreecommitdiff
path: root/app/src/main/java/de/blinkt/openvpn/core
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2014-11-04 20:45:42 +0100
committerParménides GV <parmegv@sdf.org>2014-11-04 20:45:42 +0100
commit5304543ebd60778ad46123cd63142e27627fa150 (patch)
treeb07723b530e20b23ae83de822387f6551ea7f9f4 /app/src/main/java/de/blinkt/openvpn/core
parent713c3a98f53a6bd1ad94e90f28d3e37d20abfab9 (diff)
Update ics-openvpn to rev 906.
Diffstat (limited to 'app/src/main/java/de/blinkt/openvpn/core')
-rw-r--r--app/src/main/java/de/blinkt/openvpn/core/CIDRIP.java5
-rw-r--r--app/src/main/java/de/blinkt/openvpn/core/ConfigParser.java12
-rw-r--r--app/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java5
-rw-r--r--app/src/main/java/de/blinkt/openvpn/core/ICSOpenVPNApplication.java5
-rw-r--r--app/src/main/java/de/blinkt/openvpn/core/NativeUtils.java5
-rw-r--r--app/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java5
-rw-r--r--app/src/main/java/de/blinkt/openvpn/core/OpenVPNManagement.java5
-rw-r--r--app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java62
-rw-r--r--app/src/main/java/de/blinkt/openvpn/core/OpenVPNThread.java30
-rw-r--r--app/src/main/java/de/blinkt/openvpn/core/OpenVpnManagementThread.java5
-rw-r--r--app/src/main/java/de/blinkt/openvpn/core/PRNGFixes.java5
-rw-r--r--app/src/main/java/de/blinkt/openvpn/core/ProfileManager.java21
-rw-r--r--app/src/main/java/de/blinkt/openvpn/core/ProxyDetection.java5
-rw-r--r--app/src/main/java/de/blinkt/openvpn/core/VPNLaunchHelper.java7
-rw-r--r--app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java5
-rw-r--r--app/src/main/java/de/blinkt/openvpn/core/X509Utils.java5
16 files changed, 150 insertions, 37 deletions
diff --git a/app/src/main/java/de/blinkt/openvpn/core/CIDRIP.java b/app/src/main/java/de/blinkt/openvpn/core/CIDRIP.java
index 960e7d11..ac9a8ccb 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/CIDRIP.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/CIDRIP.java
@@ -1,3 +1,8 @@
+/*
+ * Copyright (c) 2012-2014 Arne Schwabe
+ * Distributed under the GNU GPL v2. For full terms see the file doc/LICENSE.txt
+ */
+
package de.blinkt.openvpn.core;
import java.util.Locale;
diff --git a/app/src/main/java/de/blinkt/openvpn/core/ConfigParser.java b/app/src/main/java/de/blinkt/openvpn/core/ConfigParser.java
index 9c3621e0..0d8230b7 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/ConfigParser.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/ConfigParser.java
@@ -1,3 +1,8 @@
+/*
+ * Copyright (c) 2012-2014 Arne Schwabe
+ * Distributed under the GNU GPL v2. For full terms see the file doc/LICENSE.txt
+ */
+
package de.blinkt.openvpn.core;
import java.io.BufferedReader;
@@ -553,8 +558,13 @@ public class ConfigParser {
noauthtypeset=false;
}
+ Vector<String> cryptoapicert = getOption("cryptoapicert",1,1);
+ if(cryptoapicert!=null) {
+ np.mAuthenticationType = VpnProfile.TYPE_KEYSTORE;
+ noauthtypeset=false;
+ }
- Vector<String> compatnames = getOption("compat-names",1,2);
+ Vector<String> compatnames = getOption("compat-names",1,2);
Vector<String> nonameremapping = getOption("no-name-remapping",1,1);
Vector<String> tlsremote = getOption("tls-remote",1,1);
if(tlsremote!=null){
diff --git a/app/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java b/app/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java
index 0126d08e..0d75ae51 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/DeviceStateReceiver.java
@@ -1,3 +1,8 @@
+/*
+ * Copyright (c) 2012-2014 Arne Schwabe
+ * Distributed under the GNU GPL v2. For full terms see the file doc/LICENSE.txt
+ */
+
package de.blinkt.openvpn.core;
import android.content.BroadcastReceiver;
diff --git a/app/src/main/java/de/blinkt/openvpn/core/ICSOpenVPNApplication.java b/app/src/main/java/de/blinkt/openvpn/core/ICSOpenVPNApplication.java
index 485e5369..83e760ca 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/ICSOpenVPNApplication.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/ICSOpenVPNApplication.java
@@ -1,3 +1,8 @@
+/*
+ * Copyright (c) 2012-2014 Arne Schwabe
+ * Distributed under the GNU GPL v2. For full terms see the file doc/LICENSE.txt
+ */
+
package de.blinkt.openvpn.core;
import android.app.Application;
diff --git a/app/src/main/java/de/blinkt/openvpn/core/NativeUtils.java b/app/src/main/java/de/blinkt/openvpn/core/NativeUtils.java
index a2c4796d..6d7ffdf2 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/NativeUtils.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/NativeUtils.java
@@ -1,3 +1,8 @@
+/*
+ * Copyright (c) 2012-2014 Arne Schwabe
+ * Distributed under the GNU GPL v2. For full terms see the file doc/LICENSE.txt
+ */
+
package de.blinkt.openvpn.core;
import java.security.InvalidKeyException;
diff --git a/app/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java b/app/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java
index 8c6cb1f5..35f46513 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java
@@ -1,3 +1,8 @@
+/*
+ * Copyright (c) 2012-2014 Arne Schwabe
+ * Distributed under the GNU GPL v2. For full terms see the file doc/LICENSE.txt
+ */
+
package de.blinkt.openvpn.core;
import android.os.Build;
diff --git a/app/src/main/java/de/blinkt/openvpn/core/OpenVPNManagement.java b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNManagement.java
index a5a3e9f4..e90c16d1 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/OpenVPNManagement.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNManagement.java
@@ -1,3 +1,8 @@
+/*
+ * Copyright (c) 2012-2014 Arne Schwabe
+ * Distributed under the GNU GPL v2. For full terms see the file doc/LICENSE.txt
+ */
+
package de.blinkt.openvpn.core;
public interface OpenVPNManagement {
diff --git a/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
index 743e7cc5..ada065ba 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
@@ -1,3 +1,8 @@
+/*
+ * Copyright (c) 2012-2014 Arne Schwabe
+ * Distributed under the GNU GPL v2. For full terms see the file doc/LICENSE.txt
+ */
+
package de.blinkt.openvpn.core;
import android.Manifest.permission;
@@ -19,6 +24,7 @@ import android.os.Message;
import android.os.ParcelFileDescriptor;
import android.preference.PreferenceManager;
import android.text.TextUtils;
+import android.util.Log;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -309,26 +315,32 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac
return START_REDELIVER_INTENT;
}
- String UUID = "UUID";
+ /* The intent is null when the service has been restarted */
if (intent == null) {
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
- android.util.Log.d("bitmaskclient", "UUID is " + prefs.getString(UUID, ""));
- mProfile = ProfileManager.get(this, prefs.getString(UUID, ""));
- android.util.Log.d("bitmaskclient", "mProfile is null? " + (mProfile == null));
- if(mProfile != null)
- intent = mProfile.prepareIntent(getBaseContext());
- else
+ mProfile = ProfileManager.getLastConnectedProfile(this, false);
+
+ /* Got no profile, just stop */
+ if (mProfile==null) {
+ Log.d("OpenVPN", "Got no last connected profile on null intent. Stopping");
+ stopSelf(startId);
return START_NOT_STICKY;
- }
- if(mProfile != null)
- android.util.Log.d("bitmaskclient", "mProfile != null");
+ }
+ /* Do the asynchronous keychain certificate stuff */
+ mProfile.checkForRestart(this);
+
+ /* Recreate the intent */
+ intent = mProfile.getStartServiceIntent(this);
+
+ } else {
+ String profileUUID = intent.getStringExtra(getPackageName() + ".profileUUID");
+ mProfile = ProfileManager.get(this, profileUUID);
+ }
+
+
// Extract information from the intent.
String prefix = getPackageName();
String[] argv = intent.getStringArrayExtra(prefix + ".ARGV");
- String nativelibdir = intent.getStringExtra(prefix + ".nativelib");
- String profileUUID = intent.getStringExtra(prefix + ".profileUUID");
-
- mProfile = ProfileManager.get(this, profileUUID);
+ String nativeLibraryDirectory = intent.getStringExtra(prefix + ".nativelib");
String startTitle = getString(R.string.start_vpn_title, mProfile.mName);
String startTicker = getString(R.string.start_vpn_ticker, mProfile.mName);
@@ -361,13 +373,12 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac
// Start a new session by creating a new thread.
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
-
+
mOvpn3 = prefs.getBoolean("ovpn3", false);
if (!"ovpn3".equals(BuildConfig.FLAVOR))
mOvpn3 = false;
- prefs.edit().putString(UUID, profileUUID).commit();
// Open the Management Interface
if (!mOvpn3) {
@@ -395,7 +406,7 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac
} else {
HashMap<String, String> env = new HashMap<String, String>();
- processThread = new OpenVPNThread(this, argv, env, nativelibdir);
+ processThread = new OpenVPNThread(this, argv, env, nativeLibraryDirectory);
}
synchronized (mProcessLock) {
@@ -409,11 +420,12 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac
ProfileManager.setConnectedVpnProfile(this, mProfile);
+ /* TODO: At the moment we have no way to handle asynchronous PW input
+ * Fixing will also allow to handle challenge/responsee authentication */
+ if (mProfile.needUserPWInput(true) != 0)
+ return START_NOT_STICKY;
- if (mProfile.mPersistTun)
- return START_STICKY;
- else
- return START_NOT_STICKY;
+ return START_STICKY;
}
private OpenVPNManagement instantiateOpenVPN3Core() {
@@ -517,7 +529,7 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac
if ((Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT && !release.startsWith("4.4.3")
&& !release.startsWith("4.4.4") && !release.startsWith("4.4.5") && !release.startsWith("4.4.6"))
&& mMtu < 1280) {
- VpnStatus.logInfo(String.format("Forcing MTU to 1280 instead of %d to workaround Android Bug #70916", mMtu));
+ VpnStatus.logInfo(String.format(Locale.US, "Forcing MTU to 1280 instead of %d to workaround Android Bug #70916", mMtu));
builder.setMtu(1280);
} else {
builder.setMtu(mMtu);
@@ -690,7 +702,7 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac
VpnStatus.logWarning(R.string.ip_not_cidr, local, netmask, mode);
}
}
- if (("p2p".equals(mode)) && mLocalIP.len < 32 || "net30".equals("net30") && mLocalIP.len < 30) {
+ if (("p2p".equals(mode) && mLocalIP.len < 32) || ("net30".equals(mode) && mLocalIP.len < 30)) {
VpnStatus.logWarning(R.string.ip_looks_like_subnet, local, netmask, mode);
}
@@ -738,7 +750,7 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac
String ticker = msg;
showNotification(msg, ticker, lowpriority , 0, level);
return;
- } else {
+ } else {
mDisplayBytecount = false;
}
diff --git a/app/src/main/java/de/blinkt/openvpn/core/OpenVPNThread.java b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNThread.java
index 5fa2ab9e..e3c60854 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/OpenVPNThread.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNThread.java
@@ -1,3 +1,8 @@
+/*
+ * Copyright (c) 2012-2014 Arne Schwabe
+ * Distributed under the GNU GPL v2. For full terms see the file doc/LICENSE.txt
+ */
+
package de.blinkt.openvpn.core;
import android.util.Log;
@@ -25,6 +30,7 @@ import de.blinkt.openvpn.core.VpnStatus.LogItem;
public class OpenVPNThread implements Runnable {
private static final String DUMP_PATH_STRING = "Dump path: ";
+ private static final String BROKEN_PIE_SUPPORT = "/data/data/de.blinkt.openvpn/cache/pievpn[1]: syntax error:";
private static final String TAG = "OpenVPN";
public static final int M_FATAL = (1 << 4);
public static final int M_NONFATAL = (1 << 5);
@@ -36,8 +42,9 @@ public class OpenVPNThread implements Runnable {
private OpenVPNService mService;
private String mDumpPath;
private Map<String, String> mProcessEnv;
+ private boolean mBrokenPie=false;
- public OpenVPNThread(OpenVPNService service,String[] argv, Map<String,String> processEnv, String nativelibdir)
+ public OpenVPNThread(OpenVPNService service,String[] argv, Map<String,String> processEnv, String nativelibdir)
{
mArgv = argv;
mNativeDir = nativelibdir;
@@ -68,8 +75,22 @@ public class OpenVPNThread implements Runnable {
} catch (InterruptedException ie) {
VpnStatus.logError("InterruptedException: " + ie.getLocalizedMessage());
}
- if( exitvalue != 0)
- VpnStatus.logError("Process exited with exit value " + exitvalue);
+ if( exitvalue != 0) {
+ VpnStatus.logError("Process exited with exit value " + exitvalue);
+ if (mBrokenPie) {
+ String[] noPieArgv = VpnProfile.replacePieWithNoPie(mArgv);
+
+ // We are already noPIE, nothing to gain
+ if (!noPieArgv.equals(mArgv)) {
+ mArgv = noPieArgv;
+ VpnStatus.logInfo("PIE Version could not be executed. Trying no PIE version");
+ run();
+ return;
+ }
+
+ }
+
+ }
VpnStatus.updateStateString("NOPROCESS", "No process running.", R.string.state_noprocess, ConnectionStatus.LEVEL_NOTCONNECTED);
if(mDumpPath!=null) {
@@ -123,6 +144,9 @@ public class OpenVPNThread implements Runnable {
if (logline.startsWith(DUMP_PATH_STRING))
mDumpPath = logline.substring(DUMP_PATH_STRING.length());
+
+ if (logline.startsWith(BROKEN_PIE_SUPPORT))
+ mBrokenPie = true;
// 1380308330.240114 18000002 Send to HTTP proxy: 'X-Online-Host: bla.blabla.com'
diff --git a/app/src/main/java/de/blinkt/openvpn/core/OpenVpnManagementThread.java b/app/src/main/java/de/blinkt/openvpn/core/OpenVpnManagementThread.java
index e200f210..37094a1b 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/OpenVpnManagementThread.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/OpenVpnManagementThread.java
@@ -1,3 +1,8 @@
+/*
+ * Copyright (c) 2012-2014 Arne Schwabe
+ * Distributed under the GNU GPL v2. For full terms see the file doc/LICENSE.txt
+ */
+
package de.blinkt.openvpn.core;
import android.content.Context;
diff --git a/app/src/main/java/de/blinkt/openvpn/core/PRNGFixes.java b/app/src/main/java/de/blinkt/openvpn/core/PRNGFixes.java
index dd420371..bca0a4ab 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/PRNGFixes.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/PRNGFixes.java
@@ -1,3 +1,8 @@
+/*
+ * Copyright (c) 2012-2014 Arne Schwabe
+ * Distributed under the GNU GPL v2. For full terms see the file doc/LICENSE.txt
+ */
+
package de.blinkt.openvpn.core;/*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will Google be held liable for any damages
diff --git a/app/src/main/java/de/blinkt/openvpn/core/ProfileManager.java b/app/src/main/java/de/blinkt/openvpn/core/ProfileManager.java
index 4cfbcc8e..2a26152e 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/ProfileManager.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/ProfileManager.java
@@ -1,3 +1,8 @@
+/*
+ * Copyright (c) 2012-2014 Arne Schwabe
+ * Distributed under the GNU GPL v2. For full terms see the file doc/LICENSE.txt
+ */
+
package de.blinkt.openvpn.core;
import java.io.FileNotFoundException;
@@ -23,7 +28,7 @@ public class ProfileManager {
- private static final String ONBOOTPROFILE = "onBootProfile";
+ private static final String LAST_CONNECTED_PROFILE = "lastConnectedProfile";
@@ -65,7 +70,7 @@ public class ProfileManager {
public static void setConntectedVpnProfileDisconnected(Context c) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(c);
Editor prefsedit = prefs.edit();
- prefsedit.putString(ONBOOTPROFILE, null);
+ prefsedit.putString(LAST_CONNECTED_PROFILE, null);
prefsedit.apply();
}
@@ -74,21 +79,23 @@ public class ProfileManager {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(c);
Editor prefsedit = prefs.edit();
- prefsedit.putString(ONBOOTPROFILE, connectedrofile.getUUIDString());
+ prefsedit.putString(LAST_CONNECTED_PROFILE, connectedrofile.getUUIDString());
prefsedit.apply();
mLastConnectedVpn=connectedrofile;
}
- public static VpnProfile getOnBootProfile(Context c) {
+ public static VpnProfile getLastConnectedProfile(Context c, boolean onBoot) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(c);
boolean useStartOnBoot = prefs.getBoolean("restartvpnonboot", false);
+ if (onBoot && !useStartOnBoot)
+ return null;
- String mBootProfileUUID = prefs.getString(ONBOOTPROFILE,null);
- if(useStartOnBoot && mBootProfileUUID!=null)
- return get(c, mBootProfileUUID);
+ String lastConnectedProfile = prefs.getString(LAST_CONNECTED_PROFILE, null);
+ if(lastConnectedProfile!=null)
+ return get(c, lastConnectedProfile);
else
return null;
}
diff --git a/app/src/main/java/de/blinkt/openvpn/core/ProxyDetection.java b/app/src/main/java/de/blinkt/openvpn/core/ProxyDetection.java
index 47d88279..cf953863 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/ProxyDetection.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/ProxyDetection.java
@@ -1,3 +1,8 @@
+/*
+ * Copyright (c) 2012-2014 Arne Schwabe
+ * Distributed under the GNU GPL v2. For full terms see the file doc/LICENSE.txt
+ */
+
package de.blinkt.openvpn.core;
import java.net.InetSocketAddress;
diff --git a/app/src/main/java/de/blinkt/openvpn/core/VPNLaunchHelper.java b/app/src/main/java/de/blinkt/openvpn/core/VPNLaunchHelper.java
index 57a94ee7..40f9742b 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/VPNLaunchHelper.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/VPNLaunchHelper.java
@@ -1,3 +1,8 @@
+/*
+ * Copyright (c) 2012-2014 Arne Schwabe
+ * Distributed under the GNU GPL v2. For full terms see the file doc/LICENSE.txt
+ */
+
package de.blinkt.openvpn.core;
import android.content.Context;
@@ -70,7 +75,7 @@ public class VPNLaunchHelper {
VpnStatus.logInfo(R.string.building_configration);
- Intent startVPN = startprofile.prepareIntent(context);
+ Intent startVPN = startprofile.prepareStartService(context);
if(startVPN!=null)
context.startService(startVPN);
diff --git a/app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java b/app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java
index c19daeb0..25558f13 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java
@@ -1,3 +1,8 @@
+/*
+ * Copyright (c) 2012-2014 Arne Schwabe
+ * Distributed under the GNU GPL v2. For full terms see the file doc/LICENSE.txt
+ */
+
package de.blinkt.openvpn.core;
import android.annotation.SuppressLint;
diff --git a/app/src/main/java/de/blinkt/openvpn/core/X509Utils.java b/app/src/main/java/de/blinkt/openvpn/core/X509Utils.java
index 35e53c08..ff383e0f 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/X509Utils.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/X509Utils.java
@@ -1,3 +1,8 @@
+/*
+ * Copyright (c) 2012-2014 Arne Schwabe
+ * Distributed under the GNU GPL v2. For full terms see the file doc/LICENSE.txt
+ */
+
package de.blinkt.openvpn.core;
import android.content.Context;