summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap/bitmaskclient/eip
diff options
context:
space:
mode:
authorcyberta <cyberta@riseup.net>2026-04-16 01:49:47 +0200
committercyberta <cyberta@riseup.net>2026-04-16 01:49:47 +0200
commite243f77fa9dcaea116dfd010e23605b45f36c697 (patch)
treefb8354789abbf4237561276cc10fe142a5ffd00c /app/src/main/java/se/leap/bitmaskclient/eip
parent84279381be7466f3d9b53e3c13042b992d72ce8f (diff)
catch possible nullpointer exceptions when accessing eipService properties. They can be null if the provider backend is misconfigured for some reason
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/eip')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java41
1 files changed, 29 insertions, 12 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java b/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java
index b207d6e8..73ba7ae1 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java
@@ -30,6 +30,8 @@ import static se.leap.bitmaskclient.base.models.Constants.TIMEZONE;
import static se.leap.bitmaskclient.base.models.Constants.VERSION;
import static se.leap.bitmaskclient.base.models.Transport.createTransportsFrom;
+import android.util.Log;
+
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -125,7 +127,12 @@ public class Gateway {
this.remoteIpAddress = modelsGateway.getIpAddr();
this.remoteIpAddressV6 = modelsGateway.getIp6Addr();
this.host = modelsGateway.getHost();
- ModelsLocation modelsLocation = eipService.getLocations().get(modelsGateway.getLocation());
+ ModelsLocation modelsLocation = null;
+ try {
+ modelsLocation = eipService.getLocations().get(modelsGateway.getLocation());
+ } catch (NullPointerException npe) {
+ Log.e(TAG, "No locations configured in service endpoint. This smells like a provider misconfiguration.");
+ }
if (modelsLocation != null) {
this.locationName = modelsLocation.getDisplayName();
this.timezone = Integer.parseInt(modelsLocation.getTimezone());
@@ -147,7 +154,12 @@ public class Gateway {
this.modelsBridges.add(modelsBridge);
remoteIpAddress = modelsBridge.getIpAddr();
host = modelsBridge.getHost();
- ModelsLocation modelsLocation = eipService.getLocations().get(modelsBridge.getLocation());
+ ModelsLocation modelsLocation = null;
+ try {
+ modelsLocation = eipService.getLocations().get(modelsBridge.getLocation());
+ } catch (NullPointerException npe) {
+ Log.e(TAG, "No locations configured in service endpoint. This smells like a provider misconfiguration.");
+ }
if (modelsLocation != null) {
this.locationName = modelsLocation.getDisplayName();
this.timezone = Integer.parseInt(modelsLocation.getTimezone());
@@ -179,19 +191,24 @@ public class Gateway {
private JSONObject getGeneralConfiguration(ModelsEIPService eipService) {
JSONObject config = new JSONObject();
- Map<String, Object> openvpnOptions = eipService.getOpenvpnConfiguration();
- Set<String> keys = openvpnOptions.keySet();
- Iterator<String> i = keys.iterator();
- while (i.hasNext()) {
- try {
- String key = i.next();
- Object o = openvpnOptions.get(key);
- config.put(key, o);
- } catch (JSONException e) {
- e.printStackTrace();
+ try {
+ Map<String, Object> openvpnOptions = eipService.getOpenvpnConfiguration();
+ Set<String> keys = openvpnOptions.keySet();
+ Iterator<String> i = keys.iterator();
+ while (i.hasNext()) {
+ try {
+ String key = i.next();
+ Object o = openvpnOptions.get(key);
+ config.put(key, o);
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
}
+ } catch (NullPointerException npe) {
+ Log.e(TAG, "Failed to get openvpn configuration. This smells like a provider misconfiguration");
}
+
return config;
}