summaryrefslogtreecommitdiffhomepage
path: root/gui/packages
diff options
context:
space:
mode:
authorEmīls Piņķis <emils@mullvad.net>2019-01-09 12:35:43 +0000
committerEmīls Piņķis <emils@mullvad.net>2019-01-09 12:35:43 +0000
commite0ca3662e1ea57ef09001ab1b8a4b529dcdd72cf (patch)
tree4770c52ca63514d41d41800f45a23d0870b80117 /gui/packages
parent74da64ba1e1f0dda1ac94dfdf5eead7a41576e68 (diff)
parentebfd4edf81e8ddeafed3304410636fc2033bf265 (diff)
downloadmullvadvpn-e0ca3662e1ea57ef09001ab1b8a4b529dcdd72cf.tar.xz
mullvadvpn-e0ca3662e1ea57ef09001ab1b8a4b529dcdd72cf.zip
Merge branch 'adjust-current-locaiton-rpc'
Diffstat (limited to 'gui/packages')
-rw-r--r--gui/packages/desktop/src/main/daemon-rpc.js29
-rw-r--r--gui/packages/desktop/src/main/index.js5
2 files changed, 22 insertions, 12 deletions
diff --git a/gui/packages/desktop/src/main/daemon-rpc.js b/gui/packages/desktop/src/main/daemon-rpc.js
index bb55e5d335..1716190351 100644
--- a/gui/packages/desktop/src/main/daemon-rpc.js
+++ b/gui/packages/desktop/src/main/daemon-rpc.js
@@ -34,15 +34,17 @@ export type Location = {
mullvadExitIp: boolean,
hostname: ?string,
};
-const LocationSchema = partialObject({
- ip: maybe(string),
- country: string,
- city: maybe(string),
- latitude: number,
- longitude: number,
- mullvad_exit_ip: boolean,
- hostname: maybe(string),
-});
+const LocationSchema = maybe(
+ partialObject({
+ ip: maybe(string),
+ country: string,
+ city: maybe(string),
+ latitude: number,
+ longitude: number,
+ mullvad_exit_ip: boolean,
+ hostname: maybe(string),
+ }),
+);
export type BlockReason =
| {
@@ -413,7 +415,7 @@ export interface DaemonRpcProtocol {
setAutoConnect(boolean): Promise<void>;
connectTunnel(): Promise<void>;
disconnectTunnel(): Promise<void>;
- getLocation(): Promise<Location>;
+ getLocation(): Promise<?Location>;
getState(): Promise<TunnelStateTransition>;
getSettings(): Promise<Settings>;
subscribeStateListener(listener: SubscriptionListener<TunnelStateTransition>): Promise<void>;
@@ -532,10 +534,13 @@ export class DaemonRpc implements DaemonRpcProtocol {
await this._transport.send('disconnect');
}
- async getLocation(): Promise<Location> {
+ async getLocation(): Promise<?Location> {
const response = await this._transport.send('get_current_location', [], NETWORK_CALL_TIMEOUT);
try {
- return camelCaseObjectKeys(validate(LocationSchema, response));
+ const validatedResponse = validate(LocationSchema, response);
+ if (validatedResponse) {
+ return camelCaseObjectKeys(validatedResponse);
+ }
} catch (error) {
throw new ResponseParseError('Invalid response from get_current_location', error);
}
diff --git a/gui/packages/desktop/src/main/index.js b/gui/packages/desktop/src/main/index.js
index 3165729458..5da25f39de 100644
--- a/gui/packages/desktop/src/main/index.js
+++ b/gui/packages/desktop/src/main/index.js
@@ -660,6 +660,11 @@ const ApplicationMain = {
// Fetch the new user location
const location = await this._daemonRpc.getLocation();
+ // If the location is currently unavailable, do nothing! This only ever
+ // happens when a custom relay is set or we are in a blocked state.
+ if (!location) {
+ return;
+ }
// Cache the user location
// Note: hostname is only set for relay servers.