From 6a3b5094cbc347bc9119214f8ea074ce53452cdb Mon Sep 17 00:00:00 2001 From: cyBerta Date: Sun, 11 Jul 2021 16:31:30 +0200 Subject: inject IPtProxy in TorService --- .../bitmaskclient/providersetup/ProviderAPI.java | 2 ++ .../se/leap/bitmaskclient/tor/IPtProxyWrapper.java | 40 ++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 app/src/main/java/se/leap/bitmaskclient/tor/IPtProxyWrapper.java (limited to 'app/src/main/java/se') diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderAPI.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderAPI.java index dcbe9636..9ba64b31 100644 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderAPI.java +++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderAPI.java @@ -39,6 +39,7 @@ import java.util.concurrent.LinkedBlockingQueue; import se.leap.bitmaskclient.base.utils.PreferenceHelper; import se.leap.bitmaskclient.providersetup.connectivity.OkHttpClientGenerator; +import se.leap.bitmaskclient.tor.IPtProxyWrapper; import se.leap.bitmaskclient.tor.TorNotificationManager; import se.leap.bitmaskclient.tor.TorStatusObservable; @@ -202,6 +203,7 @@ public class ProviderAPI extends JobIntentService implements ProviderApiManagerB try { if (torServiceConnection == null) { Log.d(TAG, "serviceConnection is still null"); + TorService.setIPtProxy(new IPtProxyWrapper()); torServiceConnection = new TorServiceConnection(context); } } catch (InterruptedException | IllegalStateException e) { diff --git a/app/src/main/java/se/leap/bitmaskclient/tor/IPtProxyWrapper.java b/app/src/main/java/se/leap/bitmaskclient/tor/IPtProxyWrapper.java new file mode 100644 index 00000000..c7ca165e --- /dev/null +++ b/app/src/main/java/se/leap/bitmaskclient/tor/IPtProxyWrapper.java @@ -0,0 +1,40 @@ +package se.leap.bitmaskclient.tor; + +import IPtProxy.IPtProxy; + +public class IPtProxyWrapper implements IPtProxyInterface { + @Override + public void setStateLocation(String location) { + IPtProxy.setStateLocation(location); + } + + @Override + public String getStateLocation() { + return IPtProxy.getStateLocation(); + } + + @Override + public long snowflakePort() { + return IPtProxy.snowflakePort(); + } + + @Override + public long startSnowflake(String ice, String url, String front, String logFile, boolean logToStateDir, boolean keepLocalAddresses, boolean unsafeLogging, long maxPeers) { + return IPtProxy.startSnowflake(ice, url, front, logFile, logToStateDir, keepLocalAddresses, unsafeLogging, maxPeers); + } + + @Override + public void startSnowflakeProxy(long capacity, String broker, String relay, String stun, String logFile, boolean keepLocalAddresses, boolean unsafeLogging) { + IPtProxy.startSnowflakeProxy(capacity, broker, relay, stun, logFile, keepLocalAddresses, unsafeLogging); + } + + @Override + public void stopSnowflake() { + IPtProxy.stopSnowflake(); + } + + @Override + public void stopSnowflakeProxy() { + IPtProxy.stopSnowflakeProxy(); + } +} -- cgit v1.2.3