summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2020-07-01 00:15:52 +0200
committercyBerta <cyberta@riseup.net>2020-07-01 00:15:52 +0200
commit015d8f9f512b5020d380aadf4af70a89a4b3dc42 (patch)
tree02d659c33e3d62be8f5e64ac991ee55767488cdb /app/src/main/java
parent4198c9b3bb1fee4bfcb3009ac9d80610ead13466 (diff)
inject preshipped geoip url to provider object
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Provider.java42
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderAPI.java1
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java2
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderManager.java5
4 files changed, 36 insertions, 14 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/Provider.java b/app/src/main/java/se/leap/bitmaskclient/Provider.java
index 4dd7c76e..8db3cc97 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Provider.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Provider.java
@@ -50,6 +50,7 @@ public final class Provider implements Parcelable {
private JSONObject eipServiceJson = new JSONObject();
private DefaultedURL mainUrl = new DefaultedURL();
private DefaultedURL apiUrl = new DefaultedURL();
+ private DefaultedURL geoipUrl = new DefaultedURL();
private String providerIp = "";
private String providerApiIp = "";
private String certificatePin = "";
@@ -78,21 +79,35 @@ public final class Provider implements Parcelable {
DOMAIN = "domain",
MAIN_URL = "main_url",
PROVIDER_IP = "provider_ip",
- PROVIDER_API_IP = "provider_api_ip";
+ PROVIDER_API_IP = "provider_api_ip",
+ GEOIP_URL = "geoip_url";
private static final String API_TERM_NAME = "name";
public Provider() { }
public Provider(String mainUrl) {
+ this(mainUrl, null);
+ }
+
+ public Provider(String mainUrl, String geoipUrl) {
try {
this.mainUrl.setUrl(new URL(mainUrl));
} catch (MalformedURLException e) {
this.mainUrl = new DefaultedURL();
}
+ try {
+ this.geoipUrl.setUrl(new URL(geoipUrl));
+ } catch (MalformedURLException e) {
+ this.geoipUrl = new DefaultedURL();
+ }
}
public Provider(String mainUrl, String providerIp, String providerApiIp) {
+ this(mainUrl, null, providerIp, providerApiIp);
+ }
+
+ public Provider(String mainUrl, String geoipUrl, String providerIp, String providerApiIp) {
try {
this.mainUrl.setUrl(new URL(mainUrl));
if (providerIp != null) {
@@ -103,21 +118,18 @@ public final class Provider implements Parcelable {
}
} catch (MalformedURLException e) {
e.printStackTrace();
+ return;
}
- }
-
- public Provider(String mainUrl, String providerIp, String providerApiIp, String caCert, String definition) {
try {
- this.mainUrl.setUrl(new URL(mainUrl));
+ this.geoipUrl.setUrl(new URL(geoipUrl));
} catch (MalformedURLException e) {
- e.printStackTrace();
- }
- if (this.providerIp != null) {
- this.providerIp = providerIp;
- }
- if (this.providerApiIp != null) {
- this.providerApiIp = providerApiIp;
+ this.geoipUrl = new DefaultedURL();
}
+ }
+
+
+ public Provider(String mainUrl, String geoipUrl, String providerIp, String providerApiIp, String caCert, String definition) {
+ this(mainUrl, geoipUrl, providerIp, providerApiIp);
if (caCert != null) {
this.caCert = caCert;
}
@@ -241,6 +253,10 @@ public final class Provider implements Parcelable {
return apiUrl;
}
+ protected DefaultedURL getGeoipUrl() {
+ return geoipUrl;
+ }
+
protected String getApiUrlWithVersion() {
return getApiUrlString() + "/" + getApiVersion();
}
@@ -321,6 +337,7 @@ public final class Provider implements Parcelable {
parcel.writeString(getMainUrlString());
parcel.writeString(getProviderIp());
parcel.writeString(getProviderApiIp());
+ parcel.writeString(getGeoipUrl().toString());
parcel.writeString(getDefinitionString());
parcel.writeString(getCaCert());
parcel.writeString(getEipServiceJsonString());
@@ -340,6 +357,7 @@ public final class Provider implements Parcelable {
providerIp.equals(p.getProviderIp()) &&
providerApiIp.equals(p.getProviderApiIp()) &&
apiUrl.equals(p.getApiUrl()) &&
+ geoipUrl.equals(p.getGeoipUrl()) &&
certificatePin.equals(p.getCertificatePin()) &&
certificatePinEncoding.equals(p.getCertificatePinEncoding()) &&
caCert.equals(p.getCaCert()) &&
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderAPI.java b/app/src/main/java/se/leap/bitmaskclient/ProviderAPI.java
index 9d34b38f..df67f282 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderAPI.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderAPI.java
@@ -53,6 +53,7 @@ public class ProviderAPI extends JobIntentService implements ProviderApiManagerB
LOG_OUT = "logOut",
DOWNLOAD_VPN_CERTIFICATE = "downloadUserAuthedVPNCertificate",
UPDATE_INVALID_VPN_CERTIFICATE = "ProviderAPI.UPDATE_INVALID_VPN_CERTIFICATE",
+ GEOSERVICE = "geoService",
PARAMETERS = "parameters",
RECEIVER_KEY = "receiver",
ERRORS = "errors",
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java b/app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java
index 7c45c921..a7d0f916 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java
@@ -106,7 +106,7 @@ public abstract class ProviderListBaseActivity extends ProviderSetupBaseActivity
}
public void showAndSelectProvider(String newURL) {
- provider = new Provider(newURL, "", "");
+ provider = new Provider(newURL, null, null);
autoSelectProvider();
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderManager.java b/app/src/main/java/se/leap/bitmaskclient/ProviderManager.java
index 6d074a7a..c23ad270 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderManager.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderManager.java
@@ -20,6 +20,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
+import static se.leap.bitmaskclient.Provider.GEOIP_URL;
import static se.leap.bitmaskclient.Provider.MAIN_URL;
import static se.leap.bitmaskclient.Provider.PROVIDER_API_IP;
import static se.leap.bitmaskclient.Provider.PROVIDER_IP;
@@ -90,18 +91,20 @@ public class ProviderManager implements AdapteeCollection<Provider> {
String providerApiIp = null;
String certificate = null;
String providerDefinition = null;
+ String geoipUrl = null;
try {
String provider = file.substring(0, file.length() - ".url".length());
InputStream providerFile = assetsManager.open(directory + "/" + file);
mainUrl = extractKeyFromInputStream(providerFile, MAIN_URL);
providerIp = extractKeyFromInputStream(providerFile, PROVIDER_IP);
providerApiIp = extractKeyFromInputStream(providerFile, PROVIDER_API_IP);
+ geoipUrl = extractKeyFromInputStream(providerFile, GEOIP_URL);
certificate = loadInputStreamAsString(assetsManager.open(provider + EXT_PEM));
providerDefinition = loadInputStreamAsString(assetsManager.open(provider + EXT_JSON));
} catch (IOException e) {
e.printStackTrace();
}
- providers.add(new Provider(mainUrl, providerIp, providerApiIp, certificate, providerDefinition));
+ providers.add(new Provider(mainUrl, geoipUrl, providerIp, providerApiIp, certificate, providerDefinition));
}
return providers;