Skip to content

Commit

Permalink
Merge tag 'v0.7.51'
Browse files Browse the repository at this point in the history
  • Loading branch information
dzolnai committed Jun 7, 2024
2 parents 9563cc8 + 4ef3bb1 commit 3520bde
Show file tree
Hide file tree
Showing 21 changed files with 168 additions and 81 deletions.
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ androidx-annotation = "1.7.0"
androidx-appcompat = "1.6.1"
android-view-material = "1.10.0"
androidx-core-ktx = "1.12.0"
androidx-fragment-ktx = "1.6.1"
androidx-fragment-ktx = "1.6.2"
androidx-preference-ktx = "1.2.1"
androidx-webkit = "1.8.0"
androidx-webkit = "1.9.0"
androidx-lifecycle-viewmodel-ktx = "2.6.2"
androidx-lifecycle-runtime-ktx = "2.6.2"
androidx-security-crypto = "1.1.0-alpha06"
androidx-constraintlayout = "2.1.4"
androidx-cardview = "1.0.0"
androidx-recyclerview = "1.3.1"
bouncycastle = "1.49"
androidx-recyclerview = "1.3.2"
bouncycastle = "1.67"
mpandroidchart = "v3.1.0"
kotlin = "1.9.0"
square-okhttp = "4.10.0"
Expand Down
6 changes: 4 additions & 2 deletions main/src/main/java/de/blinkt/openvpn/LaunchVPN.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package de.blinkt.openvpn;

import static de.blinkt.openvpn.core.OpenVPNService.EXTRA_START_REASON;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
Expand Down Expand Up @@ -73,7 +75,7 @@ public class LaunchVPN extends Activity {
public static final String EXTRA_KEY = "de.blinkt.openvpn.shortcutProfileUUID";
public static final String EXTRA_NAME = "de.blinkt.openvpn.shortcutProfileName";
public static final String EXTRA_HIDELOG = "de.blinkt.openvpn.showNoLogWindow";
public static final String EXTRA_START_REASON = "de.blinkt.openvpn.start_reason";

public static final String CLEARLOG = "clearlogconnect";


Expand Down Expand Up @@ -255,7 +257,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (!mhideLog && showLogWindow)
showLogWindow();
ProfileManager.updateLRU(this, mSelectedProfile);
VPNLaunchHelper.startOpenVpn(mSelectedProfile, getBaseContext(), mSelectedProfileReason);
VPNLaunchHelper.startOpenVpn(mSelectedProfile, getBaseContext(), mSelectedProfileReason, true);
finish();
}
} else if (resultCode == Activity.RESULT_CANCELED) {
Expand Down
2 changes: 1 addition & 1 deletion main/src/main/java/de/blinkt/openvpn/OnBootReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public void onReceive(Context context, Intent intent) {
}

void launchVPN(VpnProfile profile, Context context) {
VPNLaunchHelper.startOpenVpn(profile, context.getApplicationContext(), "on Boot receiver");
VPNLaunchHelper.startOpenVpn(profile, context.getApplicationContext(), "on Boot receiver", false);
}
}
20 changes: 10 additions & 10 deletions main/src/main/java/de/blinkt/openvpn/VpnProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package de.blinkt.openvpn;

import static de.blinkt.openvpn.core.OpenVPNService.EXTRA_DO_NOT_REPLACE_RUNNING_VPN;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
Expand All @@ -31,20 +33,16 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Serializable;
import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.*;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.MGF1ParameterSpec;
import java.security.spec.PSSParameterSpec;
import java.util.Collection;
Expand All @@ -67,6 +65,8 @@ public class VpnProfile implements Serializable, Cloneable {
transient public static final long MAX_EMBED_FILE_SIZE = 2048 * 1024; // 2048kB
// Don't change this, not all parts of the program use this constant
public static final String EXTRA_PROFILEUUID = "de.blinkt.openvpn.profileUUID";
public static final String EXTRA_PROFILE_VERSION = "de.blinkt.openvpn.profileVersion";

public static final String INLINE_TAG = "[[INLINE]]";
public static final String DISPLAYNAME_TAG = "[[NAME]]";
public static final int MAXLOGLEVEL = 4;
Expand Down Expand Up @@ -816,14 +816,14 @@ public void writeConfigFileOutput(Context context, OutputStream out) throws IOEx
cfg.close();
}

public Intent getStartServiceIntent(Context context, String startReason) {
String prefix = context.getPackageName();

public Intent getStartServiceIntent(Context context, String startReason, boolean replace_running_vpn) {
Intent intent = new Intent(context, OpenVPNService.class);
intent.putExtra(prefix + ".profileUUID", mUuid.toString());
intent.putExtra(prefix + ".profileVersion", mVersion);
intent.putExtra(EXTRA_PROFILEUUID, mUuid.toString());
intent.putExtra(EXTRA_PROFILE_VERSION, mVersion);
if (startReason != null)
intent.putExtra(prefix + ".startReason", startReason);
intent.putExtra(OpenVPNService.EXTRA_START_REASON, startReason);
if (!replace_running_vpn)
intent.putExtra(EXTRA_DO_NOT_REPLACE_RUNNING_VPN, true);
return intent;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void onClick(DialogInterface dialog, int which) {
} else if (which == DialogInterface.BUTTON_NEUTRAL) {
Intent intent = new Intent(this, LaunchVPN.class);
intent.putExtra(LaunchVPN.EXTRA_KEY, VpnStatus.getLastConnectedVPNProfile());
intent.putExtra(LaunchVPN.EXTRA_START_REASON, "Reconnect button pressed.");
intent.putExtra(OpenVPNService.EXTRA_START_REASON, "Reconnect button pressed.");
intent.setAction(Intent.ACTION_MAIN);
startActivity(intent);
}
Expand Down
8 changes: 8 additions & 0 deletions main/src/main/java/de/blinkt/openvpn/api/AppRestrictions.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ private static void setMiscSettings(Context c, Bundle restrictions) {
editor.putBoolean("screenoff", pauseVPN);
editor.apply();
}
if (restrictions.containsKey("restartvpnonboot"))
{
boolean restartVPNonBoot = restrictions.getBoolean("restartvpnonboot");
SharedPreferences.Editor editor = defaultPrefs.edit();
editor.putBoolean("restartvpnonboot", restartVPNonBoot);
editor.apply();
}
}

private void importVPNProfiles(Context c, Bundle restrictions, Parcelable[] profileList) {
Expand All @@ -155,6 +162,7 @@ private void importVPNProfiles(Context c, Bundle restrictions, Parcelable[] prof
String defaultprofile = restrictions.getString("defaultprofile", null);
boolean defaultprofileProvisioned = false;


ProfileManager pm = ProfileManager.getInstance(c);
for (Parcelable profile : profileList) {
if (!(profile instanceof Bundle)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@
package de.blinkt.openvpn.api;

import android.annotation.TargetApi;
import android.app.PendingIntent;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.VpnService;
import android.os.Binder;
import android.os.Build;
Expand Down Expand Up @@ -146,11 +142,11 @@ private void startProfile(VpnProfile vp)
shortVPNIntent.setClass(getBaseContext(), de.blinkt.openvpn.LaunchVPN.class);
shortVPNIntent.putExtra(de.blinkt.openvpn.LaunchVPN.EXTRA_KEY, vp.getUUIDString());
shortVPNIntent.putExtra(de.blinkt.openvpn.LaunchVPN.EXTRA_HIDELOG, true);
shortVPNIntent.putExtra(de.blinkt.openvpn.LaunchVPN.EXTRA_START_REASON, startReason);
shortVPNIntent.putExtra(de.blinkt.openvpn.core.OpenVPNService.EXTRA_START_REASON, startReason);
shortVPNIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(shortVPNIntent);
} else {
VPNLaunchHelper.startOpenVpn(vp, getBaseContext(), startReason);
VPNLaunchHelper.startOpenVpn(vp, getBaseContext(), startReason, true);
}

}
Expand Down
2 changes: 1 addition & 1 deletion main/src/main/java/de/blinkt/openvpn/api/RemoteAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private void performAction() throws RemoteException {
} else {
Intent startVPN = new Intent(this, LaunchVPN.class);
startVPN.putExtra(LaunchVPN.EXTRA_KEY, profile.getUUID().toString());
startVPN.putExtra(LaunchVPN.EXTRA_START_REASON, ".api.ConnectVPN call");
startVPN.putExtra(OpenVPNService.EXTRA_START_REASON, ".api.ConnectVPN call");
startVPN.setAction(Intent.ACTION_MAIN);
startActivity(startVPN);
}
Expand Down
4 changes: 3 additions & 1 deletion main/src/main/java/de/blinkt/openvpn/core/LogItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import android.os.Parcelable;
import android.text.TextUtils;

import androidx.annotation.StringRes;

import java.io.ByteArrayInputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Array;
Expand Down Expand Up @@ -239,7 +241,7 @@ public LogItem[] newArray(int size) {
}
};

public LogItem(VpnStatus.LogLevel loglevel, int ressourceId, Object... args) {
public LogItem(VpnStatus.LogLevel loglevel, @StringRes int ressourceId, Object... args) {
mRessourceId = ressourceId;
mArgs = args;
mLevel = loglevel;
Expand Down
Loading

0 comments on commit 3520bde

Please sign in to comment.