summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2019-06-27 20:25:45 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2019-06-28 19:18:45 +0000
commitd91a855e6b7981e90f7cd9f6d2374dcb54cd04bb (patch)
treee3d66089e74e9414b7624e414f28efa1ab14a9a3
parentea3466c3bf5eb16619d67bd61e27d635d879c51b (diff)
downloadmullvadvpn-d91a855e6b7981e90f7cd9f6d2374dcb54cd04bb.tar.xz
mullvadvpn-d91a855e6b7981e90f7cd9f6d2374dcb54cd04bb.zip
Change how tunnel endpoint is broadcasted
-rw-r--r--gui/src/main/daemon-rpc.ts24
-rw-r--r--gui/src/renderer/containers/ConnectionPanelContainer.tsx4
-rw-r--r--gui/src/renderer/redux/connection/actions.ts14
-rw-r--r--gui/src/renderer/redux/connection/reducers.ts4
-rw-r--r--gui/src/shared/daemon-rpc-types.ts8
-rw-r--r--gui/test/components/NotificationArea.spec.tsx14
-rw-r--r--mullvad-cli/src/cmds/status.rs8
-rw-r--r--mullvad-daemon/src/lib.rs8
-rw-r--r--mullvad-jni/src/into_java.rs4
-rw-r--r--mullvad-types/src/states.rs4
10 files changed, 53 insertions, 39 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts
index bf6134465f..435edacdf7 100644
--- a/gui/src/main/daemon-rpc.ts
+++ b/gui/src/main/daemon-rpc.ts
@@ -237,17 +237,19 @@ const tunnelStateSchema = oneOf(
}),
object({
state: enumeration('connecting', 'connected'),
- details: partialObject({
- address: string,
- protocol: enumeration('tcp', 'udp'),
- tunnel_type: enumeration('wireguard', 'openvpn'),
- proxy: maybe(
- partialObject({
- address: string,
- protocol: enumeration('tcp', 'udp'),
- proxy_type: enumeration('shadowsocks', 'custom'),
- }),
- ),
+ details: object({
+ endpoint: partialObject({
+ address: string,
+ protocol: enumeration('tcp', 'udp'),
+ tunnel_type: enumeration('wireguard', 'openvpn'),
+ proxy: maybe(
+ partialObject({
+ address: string,
+ protocol: enumeration('tcp', 'udp'),
+ proxy_type: enumeration('shadowsocks', 'custom'),
+ }),
+ ),
+ }),
}),
}),
object({
diff --git a/gui/src/renderer/containers/ConnectionPanelContainer.tsx b/gui/src/renderer/containers/ConnectionPanelContainer.tsx
index 77b164c65b..44d3330c78 100644
--- a/gui/src/renderer/containers/ConnectionPanelContainer.tsx
+++ b/gui/src/renderer/containers/ConnectionPanelContainer.tsx
@@ -43,12 +43,12 @@ const mapStateToProps = (state: IReduxState) => {
const inAddress: IInAddress | undefined =
(status.state === 'connecting' || status.state === 'connected') && status.details
- ? tunnelEndpointToRelayInAddress(status.details)
+ ? tunnelEndpointToRelayInAddress(status.details.endpoint)
: undefined;
const bridgeInfo: IBridgeData | undefined =
(status.state === 'connecting' || status.state === 'connected') && status.details
- ? tunnelEndpointToBridgeData(status.details)
+ ? tunnelEndpointToBridgeData(status.details.endpoint)
: undefined;
return {
diff --git a/gui/src/renderer/redux/connection/actions.ts b/gui/src/renderer/redux/connection/actions.ts
index b84e85f8e6..8f5b2e62bb 100644
--- a/gui/src/renderer/redux/connection/actions.ts
+++ b/gui/src/renderer/redux/connection/actions.ts
@@ -2,17 +2,17 @@ import {
AfterDisconnect,
BlockReason,
ILocation,
- ITunnelEndpoint,
+ ITunnelStateRelayInfo,
} from '../../../shared/daemon-rpc-types';
interface IConnectingAction {
type: 'CONNECTING';
- tunnelEndpoint?: ITunnelEndpoint;
+ details?: ITunnelStateRelayInfo;
}
interface IConnectedAction {
type: 'CONNECTED';
- tunnelEndpoint: ITunnelEndpoint;
+ details: ITunnelStateRelayInfo;
}
interface IDisconnectedAction {
@@ -48,17 +48,17 @@ export type ConnectionAction =
| IBlockedAction
| IUpdateBlockStateAction;
-function connecting(tunnelEndpoint?: ITunnelEndpoint): IConnectingAction {
+function connecting(details?: ITunnelStateRelayInfo): IConnectingAction {
return {
type: 'CONNECTING',
- tunnelEndpoint,
+ details,
};
}
-function connected(tunnelEndpoint: ITunnelEndpoint): IConnectedAction {
+function connected(details: ITunnelStateRelayInfo): IConnectedAction {
return {
type: 'CONNECTED',
- tunnelEndpoint,
+ details,
};
}
diff --git a/gui/src/renderer/redux/connection/reducers.ts b/gui/src/renderer/redux/connection/reducers.ts
index 8b971cb7cc..4772df8fc5 100644
--- a/gui/src/renderer/redux/connection/reducers.ts
+++ b/gui/src/renderer/redux/connection/reducers.ts
@@ -41,13 +41,13 @@ export default function(
case 'CONNECTING':
return {
...state,
- status: { state: 'connecting', details: action.tunnelEndpoint },
+ status: { state: 'connecting', details: action.details },
};
case 'CONNECTED':
return {
...state,
- status: { state: 'connected', details: action.tunnelEndpoint },
+ status: { state: 'connected', details: action.details },
};
case 'DISCONNECTED':
diff --git a/gui/src/shared/daemon-rpc-types.ts b/gui/src/shared/daemon-rpc-types.ts
index 62d765c0b0..b245685f85 100644
--- a/gui/src/shared/daemon-rpc-types.ts
+++ b/gui/src/shared/daemon-rpc-types.ts
@@ -75,10 +75,14 @@ export type DaemonEvent =
| { relayList: IRelayList }
| { wireguardKey: KeygenEvent };
+export interface ITunnelStateRelayInfo {
+ endpoint: ITunnelEndpoint;
+}
+
export type TunnelState =
| { state: 'disconnected' }
- | { state: 'connecting'; details?: ITunnelEndpoint }
- | { state: 'connected'; details: ITunnelEndpoint }
+ | { state: 'connecting'; details?: ITunnelStateRelayInfo }
+ | { state: 'connected'; details: ITunnelStateRelayInfo }
| { state: 'disconnecting'; details: AfterDisconnect }
| { state: 'blocked'; details: BlockReason };
diff --git a/gui/test/components/NotificationArea.spec.tsx b/gui/test/components/NotificationArea.spec.tsx
index 7b1a69bd8a..f2674e848c 100644
--- a/gui/test/components/NotificationArea.spec.tsx
+++ b/gui/test/components/NotificationArea.spec.tsx
@@ -63,9 +63,17 @@ describe('components/NotificationArea', () => {
tunnelState={{
state: 'connected',
details: {
- address: '1.2.3.4',
- protocol: 'tcp',
- tunnelType: 'openvpn',
+ endpoint: {
+ address: '1.2.3.4',
+ protocol: 'tcp',
+ tunnelType: 'openvpn',
+ },
+ location: {
+ country: 'Sweden',
+ latitude: 57.70887,
+ longitude: 11.97456,
+ mullvadExitIp: true,
+ },
},
}}
version={defaultVersion}
diff --git a/mullvad-cli/src/cmds/status.rs b/mullvad-cli/src/cmds/status.rs
index 9f0b447673..ab9f9e4ab5 100644
--- a/mullvad-cli/src/cmds/status.rs
+++ b/mullvad-cli/src/cmds/status.rs
@@ -43,7 +43,7 @@ impl Command for Status {
print_state(&new_state);
use self::TunnelState::*;
match new_state {
- Connected(_) | Disconnected => print_location(&mut rpc)?,
+ Connected { .. } | Disconnected => print_location(&mut rpc)?,
_ => {}
}
}
@@ -74,10 +74,10 @@ fn print_state(state: &TunnelState) {
print!("Tunnel status: ");
match state {
Blocked(reason) => print_blocked_reason(reason),
- Connected(details) => {
- println!("Connected to {}", details);
+ Connected { endpoint } => {
+ println!("Connected to {}", endpoint);
}
- Connecting(details) => println!("Connecting to {}...", details),
+ Connecting { endpoint } => println!("Connecting to {}...", endpoint),
Disconnected => println!("Disconnected"),
Disconnecting(_) => println!("Disconnecting..."),
}
diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs
index eacb9a2197..c887caa50f 100644
--- a/mullvad-daemon/src/lib.rs
+++ b/mullvad-daemon/src/lib.rs
@@ -456,8 +456,8 @@ where
fn handle_tunnel_state_transition(&mut self, tunnel_state_transition: TunnelStateTransition) {
let tunnel_state = match tunnel_state_transition {
TunnelStateTransition::Disconnected => TunnelState::Disconnected,
- TunnelStateTransition::Connecting(endpoint) => TunnelState::Connecting(endpoint),
- TunnelStateTransition::Connected(endpoint) => TunnelState::Connected(endpoint),
+ TunnelStateTransition::Connecting(endpoint) => TunnelState::Connecting { endpoint },
+ TunnelStateTransition::Connected(endpoint) => TunnelState::Connected { endpoint },
TunnelStateTransition::Disconnecting(after_disconnect) => {
TunnelState::Disconnecting(after_disconnect)
}
@@ -783,12 +783,12 @@ where
let get_location: Box<dyn Future<Item = Option<GeoIpLocation>, Error = ()> + Send> =
match self.tunnel_state {
Disconnected => Box::new(self.get_geo_location().map(Some)),
- Connecting(_) | Disconnecting(..) => match self.build_location_from_relay() {
+ Connecting { .. } | Disconnecting(..) => match self.build_location_from_relay() {
Some(relay_location) => Box::new(future::result(Ok(Some(relay_location)))),
// Custom relay is set, no location is known
None => Box::new(future::result(Ok(None))),
},
- Connected(_) => match self.build_location_from_relay() {
+ Connected { .. } => match self.build_location_from_relay() {
Some(location_from_relay) => Box::new(
self.get_geo_location()
.map(|fetched_location| GeoIpLocation {
diff --git a/mullvad-jni/src/into_java.rs b/mullvad-jni/src/into_java.rs
index 69a279a765..204f023ec0 100644
--- a/mullvad-jni/src/into_java.rs
+++ b/mullvad-jni/src/into_java.rs
@@ -467,8 +467,8 @@ impl<'env> IntoJava<'env> for TunnelState {
fn into_java(self, env: &JNIEnv<'env>) -> Self::JavaType {
let variant = match self {
TunnelState::Disconnected => "Disconnected",
- TunnelState::Connecting(_) => "Connecting",
- TunnelState::Connected(_) => "Connected",
+ TunnelState::Connecting { .. } => "Connecting",
+ TunnelState::Connected { .. } => "Connected",
TunnelState::Disconnecting(_) => "Disconnecting",
TunnelState::Blocked(_) => "Blocked",
};
diff --git a/mullvad-types/src/states.rs b/mullvad-types/src/states.rs
index 77ef24fd7f..9c881a1c8a 100644
--- a/mullvad-types/src/states.rs
+++ b/mullvad-types/src/states.rs
@@ -20,8 +20,8 @@ pub enum TargetState {
#[serde(tag = "state", content = "details")]
pub enum TunnelState {
Disconnected,
- Connecting(TunnelEndpoint),
- Connected(TunnelEndpoint),
+ Connecting { endpoint: TunnelEndpoint },
+ Connected { endpoint: TunnelEndpoint },
Disconnecting(ActionAfterDisconnect),
Blocked(BlockReason),
}