summaryrefslogtreecommitdiff
path: root/app/src/production
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2021-10-02 13:31:36 +0200
committercyBerta <cyberta@riseup.net>2021-10-02 13:32:30 +0200
commit80bf751141c85316c22a0d16c1e4d6fa0f473f44 (patch)
tree08802373b1a0c24f5f83fe3f9a295141df3ae8b1 /app/src/production
parent9e131a6ae3456c6b8daa99dbd5b38dc5ef5d8592 (diff)
* refactor startTorProxy()
* fix setting http proxy port correctly * snowflake+tor does currently only work when being connected to a wifi, not a cellular network. For now, we check if the device is connected to a wifi, before attempting to start tor
Diffstat (limited to 'app/src/production')
-rw-r--r--app/src/production/java/se/leap/bitmaskclient/providersetup/ProviderApiManager.java48
1 files changed, 29 insertions, 19 deletions
diff --git a/app/src/production/java/se/leap/bitmaskclient/providersetup/ProviderApiManager.java b/app/src/production/java/se/leap/bitmaskclient/providersetup/ProviderApiManager.java
index fc1f0f59..3067c1bf 100644
--- a/app/src/production/java/se/leap/bitmaskclient/providersetup/ProviderApiManager.java
+++ b/app/src/production/java/se/leap/bitmaskclient/providersetup/ProviderApiManager.java
@@ -28,6 +28,7 @@ import org.json.JSONObject;
import java.io.IOException;
import java.net.URL;
import java.util.List;
+import java.util.concurrent.TimeoutException;
import de.blinkt.openvpn.core.VpnStatus;
import okhttp3.OkHttpClient;
@@ -325,17 +326,21 @@ public class ProviderApiManager extends ProviderApiManagerBase {
}
}
- if (tries == 0 &&
- responseString != null &&
- responseString.contains(ERRORS) &&
- PreferenceHelper.useTor(preferences) &&
- EipStatus.getInstance().isDisconnected() &&
- (TorStatusObservable.getStatus() == OFF ||
- TorStatusObservable.getStatus() == UNKOWN)) {
- TorStatusObservable.setProxyPort(startTorProxy());
- return downloadWithCommercialCA(stringUrl, provider, 1);
+ try {
+ if (tries == 0 &&
+ responseString != null &&
+ responseString.contains(ERRORS) &&
+ PreferenceHelper.useTor(preferences) &&
+ EipStatus.getInstance().isDisconnected() &&
+ (TorStatusObservable.getStatus() == OFF ||
+ TorStatusObservable.getStatus() == UNKOWN) &&
+ startTorProxy()
+ ) {
+ return downloadWithCommercialCA(stringUrl, provider, 1);
+ }
+ } catch (InterruptedException | TimeoutException e) {
+ e.printStackTrace();
}
-
return responseString;
}
@@ -366,15 +371,20 @@ public class ProviderApiManager extends ProviderApiManagerBase {
List<Pair<String, String>> headerArgs = getAuthorizationHeader();
responseString = sendGetStringToServer(urlString, headerArgs, okHttpClient);
- if (tries == 0 &&
- responseString != null &&
- responseString.contains(ERRORS) &&
- PreferenceHelper.useTor(preferences) &&
- EipStatus.getInstance().isDisconnected() &&
- (TorStatusObservable.getStatus() == OFF ||
- TorStatusObservable.getStatus() == UNKOWN)) {
- TorStatusObservable.setProxyPort(startTorProxy());
- return downloadFromUrlWithProviderCA(urlString, provider, 1);
+ try {
+ if (tries == 0 &&
+ responseString != null &&
+ responseString.contains(ERRORS) &&
+ PreferenceHelper.useTor(preferences) &&
+ EipStatus.getInstance().isDisconnected() &&
+ (TorStatusObservable.getStatus() == OFF ||
+ TorStatusObservable.getStatus() == UNKOWN) &&
+ startTorProxy()
+ ) {
+ return downloadFromUrlWithProviderCA(urlString, provider, 1);
+ }
+ } catch (InterruptedException | TimeoutException e) {
+ e.printStackTrace();
}
return responseString;