summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2022-05-30 23:43:58 +0200
committercyBerta <cyberta@riseup.net>2022-07-19 00:03:41 +0200
commit778128e94fc3f6601986b5943122e499a318b8cd (patch)
treeca7cfc9da822377d5846a950ddb21f3b5da3eade
parent31dcd6366378c9a813fbadd4a1620189a2edfe74 (diff)
implement ObfsVpnClient, wrapping go jni bindings
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/pluggableTransports/ObfsVpnClient.java68
1 files changed, 68 insertions, 0 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/ObfsVpnClient.java b/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/ObfsVpnClient.java
new file mode 100644
index 00000000..c871c708
--- /dev/null
+++ b/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/ObfsVpnClient.java
@@ -0,0 +1,68 @@
+package se.leap.bitmaskclient.pluggableTransports;
+
+import android.util.Log;
+
+import java.util.Observable;
+import java.util.Observer;
+
+import client.Client_;
+import de.blinkt.openvpn.core.ConnectionStatus;
+import se.leap.bitmaskclient.eip.EipStatus;
+
+public class ObfsVpnClient implements Observer {
+
+ public static final String SOCKS_PORT = "4430";
+ public static final String SOCKS_IP = "127.0.0.1";
+
+ private static final String TAG = ObfsVpnClient.class.getSimpleName();
+ private boolean noNetwork;
+ // TODO: implement error signaling go->java
+ private boolean isErrorHandling;
+
+ private final client.Client_ obfsVpnClient;
+ private final Object LOCK = new Object();
+
+ public ObfsVpnClient(Obfs4Options options) {
+ obfsVpnClient = new Client_(options.udp, SOCKS_IP+":"+SOCKS_PORT, options.cert);
+ }
+
+ public void start() {
+ new Thread(() -> {
+ synchronized (LOCK) {
+ Log.d(TAG, "aquired LOCK");
+ new Thread(obfsVpnClient::start).start();
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ Log.d(TAG, "returning LOCK after 500 ms");
+ }
+ }).start();
+ }
+
+ public void stop() {
+ synchronized (LOCK) {
+ Log.d(TAG, "stopping obfsVpnClient...");
+ obfsVpnClient.stop();
+ }
+ }
+
+ @Override
+ public void update(Observable observable, Object arg) {
+ if (observable instanceof EipStatus) {
+ EipStatus status = (EipStatus) observable;
+ //This doesn't do anything yet, since the error handling is still missing
+ if (status.getLevel() == ConnectionStatus.LEVEL_NONETWORK) {
+ noNetwork = true;
+ } else {
+ noNetwork = false;
+ if (isErrorHandling) {
+ isErrorHandling = false;
+ stop();
+ start();
+ }
+ }
+ }
+ }
+}