예제 #1
0
        public void Deactivation(bool onExit)
        {
            if (m_current != null)
            {
                if (onExit == false)
                {
                    Engine.Instance.WaitMessageSet(Messages.NetworkLockDeactivation, false);
                    Engine.Instance.Log(Engine.LogType.InfoImportant, Messages.NetworkLockDeactivation);
                }
                else
                {
                    Engine.Instance.Log(Engine.LogType.Verbose, Messages.NetworkLockDeactivation);
                }

                try
                {
                    m_current.Deactivation();
                }
                catch (Exception e)
                {
                    Engine.Instance.Log(e);
                }

                m_current = null;
            }

            // TOCLEAN, < 2.9

            /*
             * if(onExit == false)
             *      Engine.Instance.Storage.SetBool("netlock", false);
             */

            Recovery.Save();
        }
예제 #2
0
        public virtual bool OnRouteDefaultRemoveRestore()
        {
            if (m_routeDefaultRemove != null)
            {
                m_routeDefaultRemove.Add();
                m_routeDefaultRemove = null;

                Recovery.Save();
            }

            return(true);
        }
예제 #3
0
        public void Activation()
        {
            try
            {
                if (m_current != null)
                {
                    throw new Exception(Messages.NetworkLockUnexpectedAlreadyActive);
                }

                NetworkLockPlugin nextCurrent = null;

                string requestedMode = Engine.Instance.Storage.Get("netlock.mode");

                if (requestedMode != "none")
                {
                    foreach (NetworkLockPlugin plugin in Modes)
                    {
                        if ((requestedMode == "auto") || (requestedMode == plugin.GetCode()))
                        {
                            nextCurrent = plugin;
                            break;
                        }
                    }
                }

                if (nextCurrent == null)
                {
                    Engine.Instance.Log(Engine.LogType.Fatal, Messages.NetworkLockNoMode);
                }
                else
                {
                    string message = Messages.NetworkLockActivation + " - " + nextCurrent.GetName();
                    Engine.Instance.WaitMessageSet(message, false);
                    Engine.Instance.Log(Engine.LogType.InfoImportant, message);

                    nextCurrent.Activation();

                    m_current = nextCurrent;
                }

                // Engine.Instance.Storage.SetBool("netlock", true); // TOCLEAN, < 2.9
            }
            catch (Exception e)
            {
                Engine.Instance.Log(Engine.LogType.Fatal, e);

                // Engine.Instance.Storage.SetBool("netlock", false);  // TOCLEAN, < 2.9
            }

            Recovery.Save();
        }
예제 #4
0
 public virtual void OnVpnDisconnected()
 {
     if (m_current != null)
     {
         try
         {
             m_current.OnVpnDisconnected();
             Recovery.Save();
         }
         catch (Exception e)
         {
             Engine.Instance.Log(e);
         }
     }
 }
예제 #5
0
 public void OnUpdateIps()
 {
     if (m_current != null)
     {
         try
         {
             m_current.OnUpdateIps();
             Recovery.Save();
         }
         catch (Exception e)
         {
             Engine.Instance.Log(e);
         }
     }
 }
예제 #6
0
        public virtual bool OnRouteDefaultRemoveDo()
        {
            List <RouteEntry> routeEntries = RouteList();

            foreach (RouteEntry routeEntry in routeEntries)
            {
                if (routeEntry.Mask.ToString() == "0.0.0.0")
                {
                    m_routeDefaultRemove = routeEntry;

                    routeEntry.Remove();

                    Recovery.Save();
                }
            }

            return(true);
        }