summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--talpid-core/src/tunnel_state_machine/blocked_state.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/talpid-core/src/tunnel_state_machine/blocked_state.rs b/talpid-core/src/tunnel_state_machine/blocked_state.rs
index d392318c6a..abc782cd24 100644
--- a/talpid-core/src/tunnel_state_machine/blocked_state.rs
+++ b/talpid-core/src/tunnel_state_machine/blocked_state.rs
@@ -14,16 +14,21 @@ pub struct BlockedState {
}
impl BlockedState {
- fn set_security_policy(shared_values: &mut SharedTunnelStateValues) {
+ fn set_security_policy(shared_values: &mut SharedTunnelStateValues) -> Option<BlockReason> {
let policy = SecurityPolicy::Blocked {
allow_lan: shared_values.allow_lan,
};
- if let Err(error) = shared_values
+
+ match shared_values
.security
.apply_policy(policy)
.chain_err(|| "Failed to apply security policy for blocked state")
{
- log::error!("{}", error.display_chain());
+ Ok(()) => None,
+ Err(error) => {
+ log::error!("{}", error.display_chain());
+ Some(BlockReason::SetSecurityPolicyError)
+ }
}
}
}
@@ -35,7 +40,8 @@ impl TunnelState for BlockedState {
shared_values: &mut SharedTunnelStateValues,
block_reason: Self::Bootstrap,
) -> (TunnelStateWrapper, TunnelStateTransition) {
- Self::set_security_policy(shared_values);
+ let block_reason = Self::set_security_policy(shared_values).unwrap_or_else(|| block_reason);
+
(
TunnelStateWrapper::from(BlockedState {
block_reason: block_reason.clone(),