예제 #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;
            }
        }
예제 #2
0
        private void DoStart(Bundle data)
        {
            LastError = "";

            DoChangeStatus(VPN.Status.CONNECTING);

            if ((Application as AndroidApplication).Initialized)
            {
                try
                {
                    TunnelSetup(data);
                }
                catch (Exception e)
                {
                    LastError = "Tunnel start failed: " + e.Message;

                    DoStopService();
                }

                Java.Lang.Thread newVpnTask = SupportTools.StartThread(new Java.Lang.Runnable(() =>
                {
                    EddieLogger.Info("Starting VPN thread");

                    vpnTunnel.Run();
                }));

                if (newVpnTask != null)
                {
                    vpnThread = newVpnTask;
                }
            }
            else
            {
                LastError = "Initialization failed";

                DoStopService();
            }
        }