Ejemplo n.º 1
0
        public bool Initialization(bool cli)
        {
            if (ResourcesFiles.Count() == 0)
            {
                ResourcesFiles.SetString("AirVPN.xml", Lib.Core.Properties.Resources.AirVPN); // TOCLEAN with Eddie3
                ResourcesFiles.SetString("OpenVPN.xml", Lib.Core.Properties.Resources.OpenVPN); // TOCLEAN with Eddie3
                ResourcesFiles.SetString("license.txt", Lib.Core.Properties.Resources.License);
                ResourcesFiles.SetString("thirdparty.txt", Lib.Core.Properties.Resources.ThirdParty);
                ResourcesFiles.SetString("tos.txt", Lib.Core.Properties.Resources.TOS); // TOCLEAN
            }

            DevelopmentEnvironment = Platform.Instance.FileExists(Platform.Instance.NormalizePath(Platform.Instance.GetApplicationPath() + "/dev.txt"));
            m_logsManager = new LogsManager();

            Console.CancelKeyPress += new ConsoleCancelEventHandler(Console_CancelKeyPress);

            m_storage = new Core.Storage();

            if (cli)
            {
                if (Storage.GetBool("help"))
                {
                    Engine.Instance.Logs.Log(LogType.Info, Storage.GetMan(Storage.Get("help_format")));
                    return false;
                }
            }

            Logs.Log(LogType.Info, "Eddie client version: " + Constants.VersionDesc + " / " + Platform.Instance.GetSystemCode() + ", System: " + Platform.Instance.GetCode() + ", Name: " + Platform.Instance.GetName() + ", Mono/.Net Framework: " + Platform.Instance.GetMonoVersion());

            if (DevelopmentEnvironment)
                Logs.Log(LogType.Info, "Development environment.");

            // This is before the Storage.Load, because non-root can't read option (chmod)
            if (Storage.GetBool("advanced.skip_privileges") == false)
            {
                if (Platform.Instance.IsAdmin() == false)
                {
                    if (OnNoRoot() == false)
                        Logs.Log(LogType.Fatal, Messages.AdminRequiredStop);

                    return false;
                }
            }

            CountriesManager.Init();

            // Providers
            m_providersManager = new ProvidersManager();
            m_providersManager.Init();

            m_storage.Load();

            if (Storage.GetBool("tcpserver.enabled") == true)
            {
                m_tcpServer = new TcpServer();
                m_tcpServer.Start();

                /*
                string pathControl = Storage.Get("console.control.path");
                if (pathControl != "")
                {
                    Platform.Instance.FileContentsWriteText(pathControl, Storage.Get("tcpserver.port"));

                    m_tcpServer.SignalConnection.WaitOne(); // Clodo, TOCHECK; CTRL+C stop it?
                }
                */

                if (Storage.Get("console.mode") == "tcp")
                {
                    // Start requested by an UI, wait it.
                    m_tcpServer.SignalConnection.WaitOne(); // Clodo, TOCHECK; CTRL+C stop it?
                }
            }

            m_providersManager.Load();

            if (Storage.GetBool("cli"))
                ConsoleMode = true;

            if(Storage.Get("paramtest") != "") // Look comment in storage.cs
                Logs.Log(LogType.Warning, "Param test:-" + Storage.Get("paramtest") + "-");

            if(Storage.GetBool("os.single_instance") == true)
            {
                if(Platform.Instance.OnCheckSingleInstance() == false)
                {
                    Logs.Log(LogType.Fatal, Messages.OsInstanceAlreadyRunning);
                    return false;
                }
            }

            m_stats = new Core.Stats();

            if( (WebServer.GetPath() != "") && (Storage.GetBool("webui.enabled") == true) )
            {
                m_webServer = new WebServer();
                m_webServer.Start();
            }

            m_networkLockManager = new NetworkLockManager();
            m_networkLockManager.Init();

            CompatibilityManager.Init();

            Platform.Instance.OnInit();

            return true;
        }
Ejemplo n.º 2
0
        public virtual void OnDeInit()
        {
            SessionStop();

            WaitMessageSet(Messages.AppExiting, false);
            //Engine.Log(Engine.LogType.InfoImportant, Messages.AppExiting);

            if (m_threadManifest != null)
                m_threadManifest.RequestStopSync();

            if (m_threadPenalities != null)
                m_threadPenalities.RequestStopSync();

            if (m_threadDiscover != null)
                m_threadDiscover.RequestStopSync();

            if (m_threadPinger != null)
                m_threadPinger.RequestStopSync();

            m_networkLockManager.Deactivation(true);
            m_networkLockManager = null;

            TemporaryFiles.Clean();

            Platform.Instance.OnCheckSingleInstanceClear();

            Platform.Instance.OnDeInit();
        }