Esempio n. 1
0
        private void DoStartTunnel(Bundle data)
        {
            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();

            TaskEx vpnTask = m_tasksManager.Add((CancellationToken c) =>
            {
                m_tunnel.Run(c);
            });

            lock (m_vpnTaskSync)
            {
                m_vpnTask = vpnTask;
            }
        }
Esempio n. 2
0
        private void TunnelSetup(Bundle data)
        {
            if (vpnTunnel != null)
            {
                throw new Exception("internal error (m_tunnel already initialized)");
            }

            if (data == null)
            {
                throw new Exception("internal error (data bundle is null)");
            }

            vpnTunnel = new OpenVPNTunnel(this);

            vpnTunnel.Init();

            string profile = data.GetString(PARAM_PROFILE, "");

            if (profile.Length == 0)
            {
                throw new Exception("no profile defined");
            }

            vpnTunnel.LoadProfileString(profile);

            vpnTunnel.BindOptions();
        }
Esempio n. 3
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;
     }
 }
Esempio n. 4
0
 public OpenVPNDispatcher(OpenVPNTunnel tunnel, CancellationToken cancellationToken)
 {
     m_tunnel            = tunnel;
     m_cancellationToken = cancellationToken;
 }