diff options
| -rw-r--r-- | talpid-core/src/tunnel/mod.rs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/talpid-core/src/tunnel/mod.rs b/talpid-core/src/tunnel/mod.rs index ce49ea7b0d..9c23bcad59 100644 --- a/talpid-core/src/tunnel/mod.rs +++ b/talpid-core/src/tunnel/mod.rs @@ -150,10 +150,8 @@ impl TunnelMonitor { where L: Fn(TunnelEvent) + Send + Sync + 'static, { - match tunnel_endpoint.tunnel { - TunnelEndpointData::OpenVpn(_) => (), - TunnelEndpointData::Wireguard(_) => bail!(ErrorKind::UnsupportedTunnelProtocol), - } + Self::ensure_endpoint_is_openvpn(&tunnel_endpoint)?; + let user_pass_file = Self::create_user_pass_file(username).chain_err(|| ErrorKind::CredentialsWriteError)?; let cmd = Self::create_openvpn_cmd( @@ -188,6 +186,13 @@ impl TunnelMonitor { }) } + fn ensure_endpoint_is_openvpn(endpoint: &TunnelEndpoint) -> Result<()> { + match endpoint.tunnel { + TunnelEndpointData::OpenVpn(_) => Ok(()), + TunnelEndpointData::Wireguard(_) => bail!(ErrorKind::UnsupportedTunnelProtocol), + } + } + fn create_openvpn_cmd( remote: Endpoint, tunnel_alias: Option<OsString>, |
