From 78540fb6815f2542d0155e0262d71439f96600ff Mon Sep 17 00:00:00 2001 From: cyBerta Date: Wed, 26 Jun 2024 16:42:33 +0200 Subject: fix missing start() call for the obfsvpn client thread, implement EventLogger in the ObfsvpnClient instead of using an anonymous class implementing obfsvpn's EventLogger interface --- .../pluggableTransports/ObfsvpnClient.java | 28 ++++++++++++---------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'app/src') diff --git a/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/ObfsvpnClient.java b/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/ObfsvpnClient.java index dfdfbdd5..bf030a0f 100644 --- a/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/ObfsvpnClient.java +++ b/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/ObfsvpnClient.java @@ -13,7 +13,7 @@ import se.leap.bitmaskclient.pluggableTransports.models.KcpConfig; import se.leap.bitmaskclient.pluggableTransports.models.Obfs4Options; import se.leap.bitmaskclient.pluggableTransports.models.ObfsvpnConfig; -public class ObfsvpnClient { +public class ObfsvpnClient implements EventLogger { public static final int PORT = 8080; public static final String IP = "127.0.0.1"; @@ -40,31 +40,22 @@ public class ObfsvpnClient { try { Log.d(TAG, obfsvpnConfig.toString()); client = Client.newFFIClient(obfsvpnConfig.toString()); + client.setEventLogger(this); } catch (Exception e) { throw new IllegalStateException(e); } } public int start() { + synchronized (LOCK) { new Thread(() -> { try { - client.setEventLogger(new EventLogger() { - @Override - public void error(String s) { - VpnStatus.logError("[obfs4-client] " + s); - } - - @Override - public void log(String state, String message) { - VpnStatus.logDebug("[obfs4-client] " + state + ": " + message); - } - }); client.start(); } catch (Exception e) { e.printStackTrace(); } - }); + }).start(); return PORT; } } @@ -84,4 +75,15 @@ public class ObfsvpnClient { public boolean isStarted() { return client.isStarted(); } + + @Override + public void error(String s) { + VpnStatus.logError("[obfs4-client] " + s); + + } + + @Override + public void log(String state, String message) { + VpnStatus.logDebug("[obfs4-client] " + state + ": " + message); + } } -- cgit v1.2.3