summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-09-03 16:59:11 -0300
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-09-17 10:44:20 -0300
commit0772073fe5bfb0f17a50899686eaab30d3d6459e (patch)
tree12aaf848f1cba437d411189d887b88c291a76062
parent25afa242b0a3016a0458ab64f0b5260044743cb8 (diff)
downloadmullvadvpn-0772073fe5bfb0f17a50899686eaab30d3d6459e.tar.xz
mullvadvpn-0772073fe5bfb0f17a50899686eaab30d3d6459e.zip
Add authentication failure reason
-rw-r--r--gui/packages/desktop/src/renderer/components/Connect.js12
-rw-r--r--gui/packages/desktop/src/renderer/lib/daemon-rpc.js32
-rw-r--r--gui/packages/desktop/test/components/Connect.spec.js4
-rw-r--r--talpid-core/src/tunnel/mod.rs7
-rw-r--r--talpid-core/src/tunnel_state_machine/connecting_state.rs4
-rw-r--r--talpid-types/src/tunnel.rs14
6 files changed, 47 insertions, 26 deletions
diff --git a/gui/packages/desktop/src/renderer/components/Connect.js b/gui/packages/desktop/src/renderer/components/Connect.js
index 315c83ffc5..832e805bb8 100644
--- a/gui/packages/desktop/src/renderer/components/Connect.js
+++ b/gui/packages/desktop/src/renderer/components/Connect.js
@@ -39,10 +39,12 @@ type State = {
showCopyIPMessage: boolean,
};
-function getBlockReasonMessage(reason: BlockReason): string {
- switch (reason) {
- case 'auth_failed':
- return 'Authentication failed';
+function getBlockReasonMessage(blockReason: BlockReason): string {
+ switch (blockReason.reason) {
+ case 'auth_failed': {
+ const details = blockReason.details ? `: ${blockReason.details}` : '';
+ return `Authentication failed${details}`;
+ }
case 'ipv6_unavailable':
return 'Could not configure IPv6, please enable it on your system or disable it in the app';
case 'set_security_policy_error':
@@ -52,7 +54,7 @@ function getBlockReasonMessage(reason: BlockReason): string {
case 'no_matching_relay':
return 'No relay server matches the current settings';
default:
- return `Unknown error: ${(reason: empty)}`;
+ return `Unknown error: ${(blockReason.reason: empty)}`;
}
}
diff --git a/gui/packages/desktop/src/renderer/lib/daemon-rpc.js b/gui/packages/desktop/src/renderer/lib/daemon-rpc.js
index 630d813490..d984bfbf76 100644
--- a/gui/packages/desktop/src/renderer/lib/daemon-rpc.js
+++ b/gui/packages/desktop/src/renderer/lib/daemon-rpc.js
@@ -42,11 +42,14 @@ const LocationSchema = object({
});
export type BlockReason =
- | 'auth_failed'
- | 'ipv6_unavailable'
- | 'set_security_policy_error'
- | 'start_tunnel_error'
- | 'no_matching_relay';
+ | {
+ reason:
+ | 'ipv6_unavailable'
+ | 'set_security_policy_error'
+ | 'start_tunnel_error'
+ | 'no_matching_relay',
+ }
+ | { reason: 'auth_failed', details: ?string };
export type TunnelState = 'connecting' | 'connected' | 'disconnecting' | 'disconnected' | 'blocked';
@@ -230,17 +233,20 @@ const AccountDataSchema = object({
expiry: string,
});
-const allBlockReasons: Array<BlockReason> = [
- 'auth_failed',
- 'ipv6_unavailable',
- 'set_security_policy_error',
- 'start_tunnel_error',
- 'no_matching_relay',
-];
const TunnelStateTransitionSchema = oneOf(
object({
state: enumeration('blocked'),
- details: enumeration(...allBlockReasons),
+ details: oneOf(
+ object({
+ reason: enumeration(
+ 'ipv6_unavailable',
+ 'set_security_policy_error',
+ 'start_tunnel_error',
+ 'no_matching_relay',
+ ),
+ }),
+ object({ reason: enumeration('auth_failed'), details: maybe(string) }),
+ ),
}),
object({
state: enumeration('connected', 'connecting', 'disconnected', 'disconnecting'),
diff --git a/gui/packages/desktop/test/components/Connect.spec.js b/gui/packages/desktop/test/components/Connect.spec.js
index 57fd93229f..567518b0ce 100644
--- a/gui/packages/desktop/test/components/Connect.spec.js
+++ b/gui/packages/desktop/test/components/Connect.spec.js
@@ -45,7 +45,7 @@ describe('components/Connect', () => {
connection: {
...defaultProps.connection,
status: 'blocked',
- blockReason: 'no_matching_relay',
+ blockReason: { reason: 'no_matching_relay' },
},
});
@@ -157,7 +157,7 @@ describe('components/Connect', () => {
connection: {
...defaultProps.connection,
status: 'blocked',
- blockReason: 'no_matching_relay',
+ blockReason: { reason: 'no_matching_relay' },
},
});
const blockingAccordion = getComponent(component, 'blockingAccordion');
diff --git a/talpid-core/src/tunnel/mod.rs b/talpid-core/src/tunnel/mod.rs
index a5d8c35f78..2c84f16596 100644
--- a/talpid-core/src/tunnel/mod.rs
+++ b/talpid-core/src/tunnel/mod.rs
@@ -80,7 +80,7 @@ error_chain!{
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
pub enum TunnelEvent {
/// Sent when the tunnel fails to connect due to an authentication error.
- AuthFailed,
+ AuthFailed(Option<String>),
/// Sent when the tunnel comes up and is ready for traffic.
Up(TunnelMetadata),
/// Sent when the tunnel goes down.
@@ -106,7 +106,10 @@ impl TunnelEvent {
env: &HashMap<String, String>,
) -> Option<TunnelEvent> {
match *event {
- OpenVpnPluginEvent::AuthFailed => Some(TunnelEvent::AuthFailed),
+ OpenVpnPluginEvent::AuthFailed => {
+ let reason = env.get("auth_failed_reason").cloned();
+ Some(TunnelEvent::AuthFailed(reason))
+ }
OpenVpnPluginEvent::Up => {
let interface = env
.get("dev")
diff --git a/talpid-core/src/tunnel_state_machine/connecting_state.rs b/talpid-core/src/tunnel_state_machine/connecting_state.rs
index c41fca0b3b..228bc0c6fd 100644
--- a/talpid-core/src/tunnel_state_machine/connecting_state.rs
+++ b/talpid-core/src/tunnel_state_machine/connecting_state.rs
@@ -246,13 +246,13 @@ impl ConnectingState {
use self::EventConsequence::*;
match try_handle_event!(self, self.tunnel_events.poll()) {
- Ok(TunnelEvent::AuthFailed) => NewState(DisconnectingState::enter(
+ Ok(TunnelEvent::AuthFailed(reason)) => NewState(DisconnectingState::enter(
shared_values,
(
self.close_handle,
self.tunnel_close_event,
AfterDisconnect::Block(
- BlockReason::AuthFailed,
+ BlockReason::AuthFailed(reason),
self.tunnel_parameters.allow_lan,
),
),
diff --git a/talpid-types/src/tunnel.rs b/talpid-types/src/tunnel.rs
index cce96f6354..6a1c7a55ed 100644
--- a/talpid-types/src/tunnel.rs
+++ b/talpid-types/src/tunnel.rs
@@ -29,9 +29,10 @@ impl TunnelStateTransition {
/// Reason for entering the blocked state.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
+#[serde(tag = "reason", content = "details")]
pub enum BlockReason {
/// Authentication with remote server failed.
- AuthFailed,
+ AuthFailed(Option<String>),
/// Failed to configure IPv6 because it's disabled in the platform.
Ipv6Unavailable,
/// Failed to set security policy.
@@ -45,7 +46,16 @@ pub enum BlockReason {
impl fmt::Display for BlockReason {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
let description = match *self {
- BlockReason::AuthFailed => "Authentication with remote server failed",
+ BlockReason::AuthFailed(ref reason) => {
+ return write!(
+ formatter,
+ "Authentication with remote server failed: {}",
+ match reason {
+ Some(ref reason) => reason.as_str(),
+ None => "No reason provided",
+ }
+ );
+ }
BlockReason::Ipv6Unavailable => {
"Failed to configure IPv6 because it's disabled in the platform"
}