diff options
author | cyBerta <cyberta@riseup.net> | 2024-06-17 02:52:06 +0200 |
---|---|---|
committer | cyBerta <cyberta@riseup.net> | 2024-06-17 02:52:06 +0200 |
commit | cd2e002c9e0f10079d8c1ec7af1d4be54a9de9e0 (patch) | |
tree | a9d514efbc47f2f47d8ac700996e4ef11d2f614c /app/src/main/java/de/blinkt/openvpn | |
parent | 3b3500e82fef981769cc6fff1dddc58cbe66ed48 (diff) |
update obfsvpn to version 1.0.0, this is a breaking API change. Obfsvpn requires openvpn in UDP as inner transport protocol from now on
Diffstat (limited to 'app/src/main/java/de/blinkt/openvpn')
5 files changed, 20 insertions, 119 deletions
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 ff27a5a2..6a5b016e 100644 --- a/app/src/main/java/de/blinkt/openvpn/core/ConfigParser.java +++ b/app/src/main/java/de/blinkt/openvpn/core/ConfigParser.java @@ -5,8 +5,6 @@ package de.blinkt.openvpn.core; -import static de.blinkt.openvpn.core.connection.Connection.TransportType.PT; - import android.os.Build; import android.text.TextUtils; @@ -27,9 +25,8 @@ import java.util.Vector; import de.blinkt.openvpn.VpnProfile; import de.blinkt.openvpn.core.connection.Connection; import de.blinkt.openvpn.core.connection.Obfs4Connection; -import de.blinkt.openvpn.core.connection.Obfs4HopConnection; import de.blinkt.openvpn.core.connection.OpenvpnConnection; -import se.leap.bitmaskclient.pluggableTransports.Obfs4Options; +import se.leap.bitmaskclient.pluggableTransports.models.Obfs4Options; //! Openvpn Config FIle Parser, probably not 100% accurate but close enough @@ -808,12 +805,10 @@ public class ConfigParser { } else { switch (transportType) { + case OBFS4_HOP: case OBFS4: conn = new Obfs4Connection(obfs4Options); break; - case OBFS4_HOP: - conn = new Obfs4HopConnection(obfs4Options); - break; case OPENVPN: conn = new OpenvpnConnection(); break; 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 9e778fae..c8ac965f 100644 --- a/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java +++ b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java @@ -10,7 +10,6 @@ import static de.blinkt.openvpn.core.ConnectionStatus.LEVEL_CONNECTED; import static de.blinkt.openvpn.core.ConnectionStatus.LEVEL_WAITING_FOR_USER_INPUT; import static de.blinkt.openvpn.core.NetworkSpace.IpAddress; import static se.leap.bitmaskclient.base.models.Constants.PROVIDER_PROFILE; -import static se.leap.bitmaskclient.base.utils.BuildConfigHelper.useObfsVpn; import android.Manifest.permission; import android.app.Notification; @@ -53,9 +52,7 @@ import se.leap.bitmaskclient.R; import se.leap.bitmaskclient.eip.EipStatus; import se.leap.bitmaskclient.eip.VpnNotificationManager; import se.leap.bitmaskclient.firewall.FirewallManager; -import se.leap.bitmaskclient.pluggableTransports.PtClientBuilder; -import se.leap.bitmaskclient.pluggableTransports.PtClientInterface; -import se.leap.bitmaskclient.pluggableTransports.ShapeshifterClient; +import se.leap.bitmaskclient.pluggableTransports.ObfsvpnClient; public class OpenVPNService extends VpnService implements StateListener, Callback, ByteCountListener, IOpenVPNServiceInternal, VpnNotificationManager.VpnServiceCallback { @@ -91,8 +88,7 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac private Toast mlastToast; private Runnable mOpenVPNThread; private VpnNotificationManager notificationManager; - private ShapeshifterClient shapeshifter; - private PtClientInterface obfsVpnClient; + private ObfsvpnClient obfsVpnClient; private FirewallManager firewallManager; private final IBinder mBinder = new IOpenVPNServiceInternal.Stub() { @@ -239,10 +235,7 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac if(isVpnRunning()) { if (getManagement() != null && getManagement().stopVPN(replaceConnection)) { if (!replaceConnection) { - if (shapeshifter != null) { - shapeshifter.stop(); - shapeshifter = null; - } else if (obfsVpnClient != null && obfsVpnClient.isStarted()) { + if (obfsVpnClient != null && obfsVpnClient.isStarted()) { obfsVpnClient.stop(); obfsVpnClient = null; } @@ -416,21 +409,15 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac mStarting = false; Connection.TransportType transportType = connection.getTransportType(); if (mProfile.usePluggableTransports() && transportType.isPluggableTransport()) { - if (useObfsVpn()) { - if (obfsVpnClient != null && obfsVpnClient.isStarted()) { - obfsVpnClient.stop(); - } - obfsVpnClient = PtClientBuilder.getPtClient(connection); - int runningSocksPort = obfsVpnClient.start(); - if (connection.getTransportType() == Connection.TransportType.OBFS4) { - connection.setProxyPort(String.valueOf(runningSocksPort)); - } - } else if (shapeshifter == null) { - shapeshifter = new ShapeshifterClient(((Obfs4Connection) connection).getObfs4Options()); - shapeshifter.start(); + if (obfsVpnClient != null && obfsVpnClient.isStarted()) { + obfsVpnClient.stop(); } + obfsVpnClient = new ObfsvpnClient(((Obfs4Connection) connection).getObfs4Options()); + obfsVpnClient.start(); + Log.d(TAG, "obfsvpn client started"); } + // Start a new session by creating a new thread. boolean useOpenVPN3 = VpnProfile.doUseOpenVPN3(this); @@ -484,12 +471,7 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac if (mOpenVPNThread != null) ((OpenVPNThread) mOpenVPNThread).setReplaceConnection(); if (mManagement.stopVPN(true)) { - // an old was asked to exit, wait 1s - if (shapeshifter != null) { - Log.d(TAG, "-> stop shapeshifter"); - shapeshifter.stop(); - shapeshifter = null; - } else if (obfsVpnClient != null && obfsVpnClient.isStarted()) { + if (obfsVpnClient != null && obfsVpnClient.isStarted()) { Log.d(TAG, "-> stop obfsvpnClient"); obfsVpnClient.stop(); obfsVpnClient = null; 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 ecc03a19..73616ba4 100644 --- a/app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java +++ b/app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java @@ -223,7 +223,7 @@ public class VpnStatus { public enum ErrorType { UNKNOWN, - SHAPESHIFTER + OBFSVPN } // keytool -printcert -jarfile de.blinkt.openvpn_85.apk diff --git a/app/src/main/java/de/blinkt/openvpn/core/connection/Obfs4Connection.java b/app/src/main/java/de/blinkt/openvpn/core/connection/Obfs4Connection.java index 19ea180d..c646c099 100644 --- a/app/src/main/java/de/blinkt/openvpn/core/connection/Obfs4Connection.java +++ b/app/src/main/java/de/blinkt/openvpn/core/connection/Obfs4Connection.java @@ -1,12 +1,7 @@ package de.blinkt.openvpn.core.connection; -import static se.leap.bitmaskclient.base.utils.BuildConfigHelper.useObfsVpn; -import static se.leap.bitmaskclient.pluggableTransports.ShapeshifterClient.DISPATCHER_IP; -import static se.leap.bitmaskclient.pluggableTransports.ShapeshifterClient.DISPATCHER_PORT; - -import se.leap.bitmaskclient.pluggableTransports.HoppingObfsVpnClient; -import se.leap.bitmaskclient.pluggableTransports.Obfs4Options; -import se.leap.bitmaskclient.pluggableTransports.ObfsVpnClient; +import se.leap.bitmaskclient.pluggableTransports.ObfsvpnClient; +import se.leap.bitmaskclient.pluggableTransports.models.Obfs4Options; /** @@ -19,33 +14,10 @@ public class Obfs4Connection extends Connection { private Obfs4Options options; public Obfs4Connection(Obfs4Options options) { - if (useObfsVpn()) { - setServerName(options.gatewayIP); - setServerPort(options.transport.getPorts()[0]); - setProxyName(ObfsVpnClient.SOCKS_IP); - setProxyType(ProxyType.SOCKS5); - switch (options.transport.getTransportType()) { - case OBFS4: - setUseUdp(false); - setProxyPort(String.valueOf(ObfsVpnClient.SOCKS_PORT.get())); - break; - case OBFS4_HOP: - setUseUdp(true); - setProxyPort(String.valueOf(HoppingObfsVpnClient.PORT)); - break; - default:break; - } - } else { - setServerName(DISPATCHER_IP); - setServerPort(DISPATCHER_PORT); - setProxyName(""); - setProxyPort(""); - setProxyType(ProxyType.NONE); - - // while udp/kcp might be used on the wire, - // we don't use udp for openvpn in case of a obfs4 connection - setUseUdp(false); - } + setServerName(ObfsvpnClient.IP); + setServerPort(String.valueOf(ObfsvpnClient.PORT)); + setProxyType(ProxyType.NONE); + setUseUdp(true); setProxyAuthUser(null); setProxyAuthPassword(null); setUseProxyAuth(false); @@ -61,7 +33,7 @@ public class Obfs4Connection extends Connection { @Override public TransportType getTransportType() { - return TransportType.OBFS4; + return options.transport.getTransportType(); } diff --git a/app/src/main/java/de/blinkt/openvpn/core/connection/Obfs4HopConnection.java b/app/src/main/java/de/blinkt/openvpn/core/connection/Obfs4HopConnection.java deleted file mode 100644 index f983ae20..00000000 --- a/app/src/main/java/de/blinkt/openvpn/core/connection/Obfs4HopConnection.java +++ /dev/null @@ -1,48 +0,0 @@ -package de.blinkt.openvpn.core.connection; - -import se.leap.bitmaskclient.pluggableTransports.HoppingObfsVpnClient; -import se.leap.bitmaskclient.pluggableTransports.Obfs4Options; - - -/** - * Created by cyberta on 08.03.19. - */ - -public class Obfs4HopConnection extends Connection { - - private static final String TAG = Obfs4HopConnection.class.getName(); - private Obfs4Options options; - - public Obfs4HopConnection(Obfs4Options options) { - setServerName(HoppingObfsVpnClient.IP); - setServerPort(String.valueOf(HoppingObfsVpnClient.PORT)); - setProxyName(""); - setProxyPort(""); - setProxyType(ProxyType.NONE); - - - setUseUdp(true); - setProxyAuthUser(null); - setProxyAuthPassword(null); - setUseProxyAuth(false); - this.options = options; - } - - @Override - public Connection clone() throws CloneNotSupportedException { - Obfs4HopConnection connection = (Obfs4HopConnection) super.clone(); - connection.options = this.options; - return connection; - } - - @Override - public TransportType getTransportType() { - return TransportType.OBFS4_HOP; - } - - - public Obfs4Options getObfs4Options() { - return options; - } - -} |