Beispiel #1
0
 private void CleanupTunnel()
 {
     try
     {
         if (m_tunnel != null)
         {
             m_tunnel.Cleanup();
         }
     }
     catch (Exception e)
     {
         LastError = "Tunnel stop failed: " + e.Message;
     }
     finally
     {
         m_tunnel = null;
     }
 }
Beispiel #2
0
        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;
            }
        }
Beispiel #3
0
 public OpenVPNDispatcher(OpenVPNTunnel tunnel, CancellationToken cancellationToken)
 {
     m_tunnel            = tunnel;
     m_cancellationToken = cancellationToken;
 }