summaryrefslogtreecommitdiff
path: root/app/src/production
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2021-11-08 01:02:11 +0100
committercyBerta <cyberta@riseup.net>2021-11-08 01:02:11 +0100
commit5e4003572133c4bd4e31c831d6bf3729425aca29 (patch)
tree1b36238e64330a893e02a7288de54c24d36c7697 /app/src/production
parent0b80fad26c91e5aa0faf8bc0132184eeeb7883b0 (diff)
Don't allow fallback tor mechanism for failed geoip service calls.
Diffstat (limited to 'app/src/production')
-rw-r--r--app/src/production/java/se/leap/bitmaskclient/providersetup/ProviderApiManager.java18
1 files changed, 9 insertions, 9 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 dfd1bfbf..5416b1f8 100644
--- a/app/src/production/java/se/leap/bitmaskclient/providersetup/ProviderApiManager.java
+++ b/app/src/production/java/se/leap/bitmaskclient/providersetup/ProviderApiManager.java
@@ -245,7 +245,7 @@ public class ProviderApiManager extends ProviderApiManagerBase {
try {
URL geoIpUrl = provider.getGeoipUrl().getUrl();
- String geoipJsonString = downloadFromUrlWithProviderCA(geoIpUrl.toString(), provider);
+ String geoipJsonString = downloadFromUrlWithProviderCA(geoIpUrl.toString(), provider, false);
if (DEBUG_MODE) {
VpnStatus.logDebug("[API] MENSHEN JSON: " + geoipJsonString);
}
@@ -292,14 +292,14 @@ public class ProviderApiManager extends ProviderApiManagerBase {
}
private String downloadWithCommercialCA(String stringUrl, Provider provider) {
- return downloadWithCommercialCA(stringUrl, provider, 0);
+ return downloadWithCommercialCA(stringUrl, provider, true);
}
/**
* Tries to download the contents of the provided url using commercially validated CA certificate from chosen provider.
*
*/
- private String downloadWithCommercialCA(String stringUrl, Provider provider, int tries) {
+ private String downloadWithCommercialCA(String stringUrl, Provider provider, boolean allowRetry) {
String responseString;
JSONObject errorJson = new JSONObject();
@@ -326,13 +326,13 @@ public class ProviderApiManager extends ProviderApiManagerBase {
}
try {
- if (tries == 0 &&
+ if (allowRetry &&
responseString != null &&
responseString.contains(ERRORS) &&
TorStatusObservable.getStatus() == OFF &&
startTorProxy()
) {
- return downloadWithCommercialCA(stringUrl, provider, 1);
+ return downloadWithCommercialCA(stringUrl, provider, false);
}
} catch (InterruptedException | IllegalStateException | TimeoutException e) {
e.printStackTrace();
@@ -353,10 +353,10 @@ public class ProviderApiManager extends ProviderApiManagerBase {
}
private String downloadFromUrlWithProviderCA(String urlString, Provider provider) {
- return downloadFromUrlWithProviderCA(urlString, provider, 0);
+ return downloadFromUrlWithProviderCA(urlString, provider, true);
}
- private String downloadFromUrlWithProviderCA(String urlString, Provider provider, int tries) {
+ private String downloadFromUrlWithProviderCA(String urlString, Provider provider, boolean allowRetry) {
String responseString;
JSONObject errorJson = new JSONObject();
OkHttpClient okHttpClient = clientGenerator.initSelfSignedCAHttpClient(provider.getCaCert(), getProxyPort(), errorJson);
@@ -368,13 +368,13 @@ public class ProviderApiManager extends ProviderApiManagerBase {
responseString = sendGetStringToServer(urlString, headerArgs, okHttpClient);
try {
- if (tries == 0 &&
+ if (allowRetry &&
responseString != null &&
responseString.contains(ERRORS) &&
TorStatusObservable.getStatus() == OFF &&
startTorProxy()
) {
- return downloadFromUrlWithProviderCA(urlString, provider, 1);
+ return downloadFromUrlWithProviderCA(urlString, provider, false);
}
} catch (InterruptedException | IllegalStateException | TimeoutException e) {
e.printStackTrace();