Esempio n. 1
0
        public void Activation()
        {
            try
            {
                if (m_current != null)
                {
                    throw new Exception(LanguageManager.GetText("NetworkLockUnexpectedAlreadyActive"));
                }

                NetworkLockPlugin nextCurrent = null;

                string requestedMode = Engine.Instance.Storage.GetLower("netlock.mode");
                if (requestedMode == "auto")
                {
                    requestedMode = Platform.Instance.OnNetworkLockRecommendedMode();
                }

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

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

                    // This is not useless: resolve hostnames (available later as cache) before a possible lock of DNS server.
                    nextCurrent.GetIpsWhiteListOutgoing(true);

                    nextCurrent.Activation();

                    m_current = nextCurrent;
                }
            }
            catch (Exception e)
            {
                Engine.Instance.Logs.Log(LogType.Fatal, e);
            }

            Recovery.Save();
        }
Esempio n. 2
0
        public void Activation()
        {
            try
            {
                if (m_current != null)
                {
                    throw new Exception(Messages.NetworkLockUnexpectedAlreadyActive);
                }

                NetworkLockPlugin nextCurrent = null;

                string requestedMode = Engine.Instance.Storage.GetLower("netlock.mode");
                if (requestedMode == "auto")
                {
                    requestedMode = Platform.Instance.OnNetworkLockRecommendedMode();
                }

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

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

                    nextCurrent.Activation();

                    m_current = nextCurrent;
                }
            }
            catch (Exception e)
            {
                Engine.Instance.Logs.Log(LogType.Fatal, e);
            }

            Recovery.Save();
        }