diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-10-12 13:50:20 -0300 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-10-16 10:38:11 -0300 |
| commit | cf704402133750b02bd26e62cb54992df3765bce (patch) | |
| tree | f1d1d6af05f0b0ec8dc4988e11262b89fc128dcd /gui | |
| parent | 691125bc746ac8a0ad1cf3121c871f955fab9007 (diff) | |
| download | mullvadvpn-cf704402133750b02bd26e62cb54992df3765bce.tar.xz mullvadvpn-cf704402133750b02bd26e62cb54992df3765bce.zip | |
Send tunnel endpoint on connected and connecting
Diffstat (limited to 'gui')
4 files changed, 43 insertions, 21 deletions
diff --git a/gui/packages/desktop/src/renderer/app.js b/gui/packages/desktop/src/renderer/app.js index 1ef54ca4e9..20de8d81e3 100644 --- a/gui/packages/desktop/src/renderer/app.js +++ b/gui/packages/desktop/src/renderer/app.js @@ -229,7 +229,7 @@ export default class AppRenderer { if (tunnelState.state === 'disconnected' || tunnelState.state === 'blocked') { // switch to connecting state immediately to prevent a lag that may be caused by RPC // communication delay - actions.connection.connecting(); + actions.connection.connecting(null); await this._daemonRpc.connectTunnel(); } @@ -616,11 +616,11 @@ export default class AppRenderer { switch (stateTransition.state) { case 'connecting': - actions.connection.connecting(); + actions.connection.connecting(stateTransition.details); break; case 'connected': - actions.connection.connected(); + actions.connection.connected(stateTransition.details); break; 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 572954b26b..c4ac506f36 100644 --- a/gui/packages/desktop/src/renderer/lib/daemon-rpc.js +++ b/gui/packages/desktop/src/renderer/lib/daemon-rpc.js @@ -55,8 +55,22 @@ export type AfterDisconnect = 'nothing' | 'block' | 'reconnect'; export type TunnelState = 'connecting' | 'connected' | 'disconnecting' | 'disconnected' | 'blocked'; +export type TunnelEndpoint = { + address: string, + tunnel: TunnelEndpointData, +}; + +export type TunnelEndpointData = { + openvpn: { + port: number, + protocol: RelayProtocol, + }, +}; + export type TunnelStateTransition = - | { state: 'disconnected' | 'connecting' | 'connected' } + | { state: 'disconnected' } + | { state: 'connecting', details: ?TunnelEndpoint } + | { state: 'connected', details: TunnelEndpoint } | { state: 'disconnecting', details: AfterDisconnect } | { state: 'blocked', details: BlockReason }; @@ -91,12 +105,7 @@ type RelaySettingsNormal<TTunnelConstraints> = { // types describing the structure of RelaySettings export type RelaySettingsCustom = { host: string, - tunnel: { - openvpn: { - port: number, - protocol: RelayProtocol, - }, - }, + tunnel: TunnelEndpointData, }; export type RelaySettings = | {| @@ -127,6 +136,13 @@ const constraint = <T>(constraintValue: SchemaNode<T>) => { ); }; +const TunnelEndpointDataSchema = object({ + openvpn: object({ + port: number, + protocol: enumeration('udp', 'tcp'), + }), +}); + const RelaySettingsSchema = oneOf( object({ normal: object({ @@ -156,12 +172,7 @@ const RelaySettingsSchema = oneOf( object({ custom_tunnel_endpoint: object({ host: string, - tunnel: object({ - openvpn: object({ - port: number, - protocol: enumeration('udp', 'tcp'), - }), - }), + tunnel: TunnelEndpointDataSchema, }), }), ); @@ -240,6 +251,13 @@ const TunnelStateTransitionSchema = oneOf( details: enumeration('nothing', 'block', 'reconnect'), }), object({ + state: enumeration('connecting', 'connected'), + details: object({ + address: string, + tunnel: TunnelEndpointDataSchema, + }), + }), + object({ state: enumeration('blocked'), details: oneOf( object({ diff --git a/gui/packages/desktop/src/renderer/redux/connection/actions.js b/gui/packages/desktop/src/renderer/redux/connection/actions.js index 668eb2a67b..6f8a297678 100644 --- a/gui/packages/desktop/src/renderer/redux/connection/actions.js +++ b/gui/packages/desktop/src/renderer/redux/connection/actions.js @@ -1,13 +1,15 @@ // @flow -import type { AfterDisconnect, BlockReason } from '../../lib/daemon-rpc'; +import type { AfterDisconnect, BlockReason, TunnelEndpoint } from '../../lib/daemon-rpc'; type ConnectingAction = { type: 'CONNECTING', + tunnelEndpoint: ?TunnelEndpoint, }; type ConnectedAction = { type: 'CONNECTED', + tunnelEndpoint: TunnelEndpoint, }; type DisconnectedAction = { @@ -54,15 +56,17 @@ export type ConnectionAction = | OnlineAction | OfflineAction; -function connecting(): ConnectingAction { +function connecting(tunnelEndpoint: ?TunnelEndpoint): ConnectingAction { return { type: 'CONNECTING', + tunnelEndpoint, }; } -function connected(): ConnectedAction { +function connected(tunnelEndpoint: TunnelEndpoint): ConnectedAction { return { type: 'CONNECTED', + tunnelEndpoint, }; } diff --git a/gui/packages/desktop/src/renderer/redux/connection/reducers.js b/gui/packages/desktop/src/renderer/redux/connection/reducers.js index b90f285e4f..622663dc14 100644 --- a/gui/packages/desktop/src/renderer/redux/connection/reducers.js +++ b/gui/packages/desktop/src/renderer/redux/connection/reducers.js @@ -32,10 +32,10 @@ export default function( return { ...state, ...action.newLocation }; case 'CONNECTING': - return { ...state, status: { state: 'connecting' } }; + return { ...state, status: { state: 'connecting', details: action.tunnelEndpoint } }; case 'CONNECTED': - return { ...state, status: { state: 'connected' } }; + return { ...state, status: { state: 'connected', details: action.tunnelEndpoint } }; case 'DISCONNECTED': return { ...state, status: { state: 'disconnected' } }; |
