summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap/bitmaskclient/providersetup
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2024-10-26 04:51:59 +0200
committercyberta <cyberta@riseup.net>2024-12-11 00:09:34 +0000
commit6c1b8f8c0ed8915de7247a603481e4e434ebd6da (patch)
tree041afc3a3fca2b6b6b8b651f7c4d5b9947fb450b /app/src/main/java/se/leap/bitmaskclient/providersetup
parent2f79616938eb8d570bad779f6846644e09cfefa4 (diff)
add support for running bitmask-core's apiv5 bootstrap via tor + snowflake
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/providersetup')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderAPI.java5
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiManagerBase.java1
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiManagerV5.java5
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiTorHandler.java4
4 files changed, 14 insertions, 1 deletions
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 751bf1dc..63ae3731 100644
--- a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderAPI.java
+++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderAPI.java
@@ -140,6 +140,11 @@ public class ProviderAPI extends JobIntentService implements ProviderApiManagerB
}
@Override
+ public int getTorSocksProxyPort() {
+ return TorServiceCommand.getSocksProxyPort(this);
+ }
+
+ @Override
public boolean hasNetworkConnection() {
try {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiManagerBase.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiManagerBase.java
index 3032bd4f..4093f25c 100644
--- a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiManagerBase.java
+++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiManagerBase.java
@@ -78,6 +78,7 @@ public abstract class ProviderApiManagerBase {
boolean startTorService() throws InterruptedException, IllegalStateException, TimeoutException;
void stopTorService();
int getTorHttpTunnelPort();
+ int getTorSocksProxyPort();
boolean hasNetworkConnection();
void saveProvider(Provider p);
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiManagerV5.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiManagerV5.java
index 6e748afa..9981feb1 100644
--- a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiManagerV5.java
+++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiManagerV5.java
@@ -56,6 +56,8 @@ import se.leap.bitmaskclient.tor.TorStatusObservable;
public class ProviderApiManagerV5 extends ProviderApiManagerBase implements IProviderApiManager {
private static final String TAG = ProviderApiManagerV5.class.getSimpleName();
+ private static final String PROXY_HOST = "127.0.0.1";
+ private static final String SOCKS_PROXY_SCHEME = "socks5://";
ProviderApiManagerV5(Resources resources, ProviderApiServiceCallback callback) {
super(resources, callback);
@@ -189,6 +191,9 @@ public class ProviderApiManagerV5 extends ProviderApiManagerBase implements IPro
BitmaskMobile bm;
try {
bm = new BitmaskMobile(provider.getMainUrl(), new PreferenceHelper.SharedPreferenceStore());
+ if (TorStatusObservable.isRunning() && TorStatusObservable.getSocksProxyPort() != -1) {
+ bm.setSocksProxy(SOCKS_PROXY_SCHEME + PROXY_HOST + ":" + TorStatusObservable.getSocksProxyPort());
+ }
} catch (IllegalStateException e) {
// TODO: improve error message
return eventSender.setErrorResult(currentDownload, R.string.config_error_found, null);
diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiTorHandler.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiTorHandler.java
index b551cea0..3b7d4247 100644
--- a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiTorHandler.java
+++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiTorHandler.java
@@ -29,7 +29,9 @@ public class ProviderApiTorHandler {
}
int port = serviceCallback.getTorHttpTunnelPort();
TorStatusObservable.setProxyPort(port);
- return port != -1;
+ int socksPort = serviceCallback.getTorSocksProxyPort();
+ TorStatusObservable.setSocksProxyPort(socksPort);
+ return port != -1 && socksPort != -1;
}
return false;
}