summaryrefslogtreecommitdiffhomepage
path: root/gui
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-08-30 14:38:40 -0300
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-09-03 08:05:18 -0300
commita4add0ecce0b7105c2eb6c9af738ba91aaafe86f (patch)
tree9267173e475bf28d88937a00fd4eeeab69f97086 /gui
parent7663c2ea549dff8fdf210c41f95a373b4bdedd9b (diff)
downloadmullvadvpn-a4add0ecce0b7105c2eb6c9af738ba91aaafe86f.tar.xz
mullvadvpn-a4add0ecce0b7105c2eb6c9af738ba91aaafe86f.zip
Add reason to transition to blocked state
Diffstat (limited to 'gui')
-rw-r--r--gui/packages/desktop/src/renderer/app.js8
-rw-r--r--gui/packages/desktop/src/renderer/lib/daemon-rpc.js48
2 files changed, 45 insertions, 11 deletions
diff --git a/gui/packages/desktop/src/renderer/app.js b/gui/packages/desktop/src/renderer/app.js
index 5c4847d76a..e3ed3f78ef 100644
--- a/gui/packages/desktop/src/renderer/app.js
+++ b/gui/packages/desktop/src/renderer/app.js
@@ -504,7 +504,11 @@ export default class AppRenderer {
if (newState) {
const connectionState = this._tunnelStateToConnectionState(newState);
- log.debug(`Got new state from daemon '${newState}', translated to '${connectionState}'`);
+ log.debug(
+ `Got new state from daemon '${JSON.stringify(
+ newState,
+ )}', translated to '${connectionState}'`,
+ );
this._updateConnectionState(connectionState);
this._refreshStateOnChange();
@@ -546,7 +550,7 @@ export default class AppRenderer {
}
_tunnelStateToConnectionState(tunnelState: TunnelState): ConnectionState {
- switch (tunnelState) {
+ switch (tunnelState.state) {
case 'disconnected':
// Fall through
case 'disconnecting':
diff --git a/gui/packages/desktop/src/renderer/lib/daemon-rpc.js b/gui/packages/desktop/src/renderer/lib/daemon-rpc.js
index 5dcf041dcd..1578b04638 100644
--- a/gui/packages/desktop/src/renderer/lib/daemon-rpc.js
+++ b/gui/packages/desktop/src/renderer/lib/daemon-rpc.js
@@ -41,7 +41,29 @@ const LocationSchema = object({
mullvad_exit_ip: boolean,
});
-export type TunnelState = 'disconnected' | 'connecting' | 'connected' | 'disconnecting' | 'blocked';
+export type BlockReason = string;
+export type DisconnectedState = {
+ state: 'disconnected',
+};
+export type ConnectingState = {
+ state: 'connecting',
+};
+export type ConnectedState = {
+ state: 'connected',
+};
+export type DisconnectingState = {
+ state: 'disconnecting',
+};
+export type BlockedState = {
+ state: 'blocked',
+ details: BlockReason,
+};
+export type TunnelState =
+ | DisconnectedState
+ | ConnectingState
+ | ConnectedState
+ | DisconnectingState
+ | BlockedState;
export type RelayProtocol = 'tcp' | 'udp';
export type RelayLocation = {| city: [string, string] |} | {| country: string |};
@@ -196,14 +218,22 @@ const AccountDataSchema = object({
expiry: string,
});
-const allTunnelStates: Array<TunnelState> = [
- 'disconnected',
- 'connecting',
- 'connected',
- 'disconnecting',
- 'blocked',
-];
-const TunnelStateSchema = enumeration(...allTunnelStates);
+const BlockedStateSchema = object({
+ state: enumeration('blocked'),
+ details: string,
+});
+const ConnectedStateSchema = object({ state: enumeration('connected') });
+const ConnectingStateSchema = object({ state: enumeration('connecting') });
+const DisconnectedStateSchema = object({ state: enumeration('disconnected') });
+const DisconnectingStateSchema = object({ state: enumeration('disconnecting') });
+
+const TunnelStateSchema = oneOf(
+ BlockedStateSchema,
+ ConnectedStateSchema,
+ ConnectingStateSchema,
+ DisconnectedStateSchema,
+ DisconnectingStateSchema,
+);
export type AppVersionInfo = {
currentIsSupported: boolean,