private void CleanupTunnel() { try { if (m_tunnel != null) { m_tunnel.Cleanup(); } } catch (Exception e) { LastError = "Tunnel stop failed: " + e.Message; } finally { m_tunnel = null; } }
private void DoStartTunnel(Bundle data) { ResetLastProfile(); if (m_tunnel != null) { throw new Exception("internal error (m_tunnel already initialized)"); } if (data == null) { throw new Exception("internal error (data bundle is null)"); } m_tunnel = new OpenVPNTunnel(this); m_tunnel.Init(); string profile = data.GetString(PARAM_PROFILE, ""); if (profile.Length == 0) { throw new Exception("no profile defined"); } m_tunnel.LoadProfileString(profile); m_tunnel.BindOptions(); m_lastProfile = profile; TaskEx vpnTask = m_tasksManager.Add((CancellationToken c) => { m_tunnel.Run(c); }); lock (m_vpnTaskSync) { m_vpnTask = vpnTask; } }
public OpenVPNDispatcher(OpenVPNTunnel tunnel, CancellationToken cancellationToken) { m_tunnel = tunnel; m_cancellationToken = cancellationToken; }