diff options
author | cyBerta <cyberta@riseup.net> | 2021-02-18 14:15:41 +0100 |
---|---|---|
committer | cyBerta <cyberta@riseup.net> | 2021-02-18 14:15:41 +0100 |
commit | e5d71c8dd60f10a5fcb9dbeab3158207932905e2 (patch) | |
tree | 67efca7589d9834e79d7b72069c661edda17593b | |
parent | f492851c35a621c8d23a86d7c9cd17a760f50915 (diff) |
add DEBUG_MODE api response logging to insecure build flavor, too
3 files changed, 30 insertions, 9 deletions
diff --git a/app/build.gradle b/app/build.gradle index 5a1b1217..5b16f8e9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -218,14 +218,17 @@ android { signingConfig signingConfigs.release.isSigningReady() ? signingConfigs.release : signingConfigs.debug //minifyEnabled = true //shrinkResources true + buildConfigField "Boolean", "DEBUG_MODE", "false" } beta { initWith release applicationIdSuffix ".beta" appSuffix = " Beta" + buildConfigField "Boolean", "DEBUG_MODE", "true" } debug { testCoverageEnabled = true + buildConfigField "Boolean", "DEBUG_MODE", "true" } } diff --git a/app/src/insecure/java/se/leap/bitmaskclient/providersetup/ProviderApiManager.java b/app/src/insecure/java/se/leap/bitmaskclient/providersetup/ProviderApiManager.java index a13f056f..833d1e48 100644 --- a/app/src/insecure/java/se/leap/bitmaskclient/providersetup/ProviderApiManager.java +++ b/app/src/insecure/java/se/leap/bitmaskclient/providersetup/ProviderApiManager.java @@ -19,6 +19,7 @@ package se.leap.bitmaskclient.providersetup; import android.content.SharedPreferences; import android.content.res.Resources; +import static se.leap.bitmaskclient.BuildConfig.DEBUG_MODE; import android.os.Bundle; import android.util.Pair; @@ -44,6 +45,7 @@ import javax.net.ssl.SSLSession; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; +import de.blinkt.openvpn.core.VpnStatus; import okhttp3.OkHttpClient; import se.leap.bitmaskclient.R; import se.leap.bitmaskclient.base.models.Provider; @@ -104,6 +106,7 @@ public class ProviderApiManager extends ProviderApiManagerBase { if (isEmpty(provider.getMainUrlString()) || provider.getMainUrl().isDefault()) { setErrorResult(currentDownload, malformed_url, null); currentDownload.putParcelable(PROVIDER_KEY, provider); + VpnStatus.logWarning("[API] MainURL String is not set. Cannot setup provider."); return currentDownload; } @@ -153,6 +156,10 @@ public class ProviderApiManager extends ProviderApiManagerBase { return result; } + if (DEBUG_MODE) { + VpnStatus.logDebug("[API] PROVIDER JSON: " + providerDotJsonString); + } + try { JSONObject providerJson = new JSONObject(providerDotJsonString); @@ -183,6 +190,9 @@ public class ProviderApiManager extends ProviderApiManagerBase { JSONObject providerDefinition = provider.getDefinition(); String eipServiceUrl = providerDefinition.getString(Provider.API_URL) + "/" + providerDefinition.getString(Provider.API_VERSION) + "/" + EIP.SERVICE_API_PATH; eipServiceJsonString = downloadWithProviderCA(provider.getCaCert(), eipServiceUrl, lastDangerOn); + if (DEBUG_MODE) { + VpnStatus.logDebug("[API] EIP SERVICE JSON: " + eipServiceJsonString); + } JSONObject eipServiceJson = new JSONObject(eipServiceJsonString); @@ -213,6 +223,9 @@ public class ProviderApiManager extends ProviderApiManagerBase { URL newCertStringUrl = new URL(provider.getApiUrlWithVersion() + "/" + PROVIDER_VPN_CERTIFICATE); String certString = downloadWithProviderCA(provider.getCaCert(), newCertStringUrl.toString(), lastDangerOn); + if (DEBUG_MODE) { + VpnStatus.logDebug("[API] VPN CERT: " + certString); + } if (ConfigHelper.checkErroneousDownload(certString)) { if (certString == null || certString.isEmpty()) { // probably 204 @@ -252,6 +265,9 @@ public class ProviderApiManager extends ProviderApiManagerBase { URL geoIpUrl = provider.getGeoipUrl().getUrl(); String geoipJsonString = downloadFromUrlWithProviderCA(geoIpUrl.toString(), provider, lastDangerOn); + if (DEBUG_MODE) { + VpnStatus.logDebug("[API] MENSHEN JSON: " + geoipJsonString); + } JSONObject geoipJson = new JSONObject(geoipJsonString); if (geoipJson.has(ERRORS)) { @@ -281,6 +297,9 @@ public class ProviderApiManager extends ProviderApiManagerBase { if (validCertificate(provider, certString)) { provider.setCaCert(certString); + if (DEBUG_MODE) { + VpnStatus.logDebug("[API] CA CERT: " + certString); + } preferences.edit().putString(Provider.CA_CERT + "." + providerDomain, certString).apply(); result.putBoolean(BROADCAST_RESULT_KEY, true); } else { 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 61105318..96d8ea69 100644 --- a/app/src/production/java/se/leap/bitmaskclient/providersetup/ProviderApiManager.java +++ b/app/src/production/java/se/leap/bitmaskclient/providersetup/ProviderApiManager.java @@ -22,8 +22,6 @@ import android.content.res.Resources; import android.os.Bundle; import android.util.Pair; -import androidx.multidex.BuildConfig; - import org.json.JSONException; import org.json.JSONObject; @@ -40,6 +38,7 @@ import se.leap.bitmaskclient.eip.EIP; import se.leap.bitmaskclient.providersetup.connectivity.OkHttpClientGenerator; import static android.text.TextUtils.isEmpty; +import static se.leap.bitmaskclient.BuildConfig.DEBUG_MODE; import static se.leap.bitmaskclient.R.string.downloading_vpn_certificate_failed; import static se.leap.bitmaskclient.R.string.error_io_exception_user_message; import static se.leap.bitmaskclient.R.string.malformed_url; @@ -140,7 +139,7 @@ public class ProviderApiManager extends ProviderApiManagerBase { return result; } - if (BuildConfig.DEBUG) { + if (DEBUG_MODE) { VpnStatus.logDebug("[API] PROVIDER JSON: " + providerDotJsonString); } try { @@ -169,10 +168,10 @@ public class ProviderApiManager extends ProviderApiManagerBase { try { String eipServiceUrl = provider.getApiUrlWithVersion() + "/" + EIP.SERVICE_API_PATH; eipServiceJsonString = downloadWithProviderCA(provider.getCaCert(), eipServiceUrl); - JSONObject eipServiceJson = new JSONObject(eipServiceJsonString); - if (BuildConfig.DEBUG) { + if (DEBUG_MODE) { VpnStatus.logDebug("[API] EIP SERVICE JSON: " + eipServiceJsonString); } + JSONObject eipServiceJson = new JSONObject(eipServiceJsonString); if (eipServiceJson.has(ERRORS)) { setErrorResult(result, eipServiceJsonString); } else { @@ -198,7 +197,7 @@ public class ProviderApiManager extends ProviderApiManagerBase { URL newCertStringUrl = new URL(provider.getApiUrlWithVersion() + "/" + PROVIDER_VPN_CERTIFICATE); String certString = downloadWithProviderCA(provider.getCaCert(), newCertStringUrl.toString()); - if (BuildConfig.DEBUG) { + if (DEBUG_MODE) { VpnStatus.logDebug("[API] VPN CERT: " + certString); } if (ConfigHelper.checkErroneousDownload(certString)) { @@ -241,7 +240,7 @@ public class ProviderApiManager extends ProviderApiManagerBase { URL geoIpUrl = provider.getGeoipUrl().getUrl(); String geoipJsonString = downloadFromUrlWithProviderCA(geoIpUrl.toString(), provider); - if (BuildConfig.DEBUG) { + if (DEBUG_MODE) { VpnStatus.logDebug("[API] MENSHEN JSON: " + geoipJsonString); } JSONObject geoipJson = new JSONObject(geoipJsonString); @@ -271,10 +270,10 @@ public class ProviderApiManager extends ProviderApiManagerBase { if (validCertificate(provider, certString)) { provider.setCaCert(certString); - preferences.edit().putString(Provider.CA_CERT + "." + providerDomain, certString).apply(); - if (BuildConfig.DEBUG) { + if (DEBUG_MODE) { VpnStatus.logDebug("[API] CA CERT: " + certString); } + preferences.edit().putString(Provider.CA_CERT + "." + providerDomain, certString).apply(); result.putBoolean(BROADCAST_RESULT_KEY, true); } else { setErrorResult(result, warning_corrupted_provider_cert, ERROR_CERTIFICATE_PINNING.toString()); |