예제 #1
0
        public void Command(XmlItem xml, bool ignoreIfNotExists)
        {
            try
            {
                if (Engine.Storage.Get("console.mode") == "backend")
                    Console.WriteLine(xml.ToString());

                if (CommandEvent != null)
                    CommandEvent(xml);

                OnCommand(xml, ignoreIfNotExists);
            }
            catch (Exception e)
            {
                Logs.Log(LogType.Error, e);
            }
        }
예제 #2
0
        public virtual void OnCommand(XmlItem xml, bool ignoreIfNotExists)
        {
            string action = xml.GetAttribute("action").ToLowerInvariant();
            if (action == "exit")
            {
                OnExit();
            }
            else if (action == "openvpn")
            {
                SendManagementCommand(xml.GetAttribute("command"));
            }
            else if (action == "ui.show.text")
            {
                OnShowText(xml.GetAttribute("title",""), xml.GetAttribute("body",""));
            }
            else if (action == "ui.show.url")
            {
                Platform.Instance.OpenUrl(xml.GetAttribute("url"));
            }
            else if (action == "ui.show.license")
            {
                XmlItem xml2 = new XmlItem("command");
                xml2.SetAttribute("action", "ui.show.text");
                xml2.SetAttribute("title", "License");
                xml2.SetAttribute("body", ResourcesFiles.GetString("license.txt"));
                Command(xml2);
            }
            else if (action == "ui.show.libraries")
            {
                XmlItem xml2 = new XmlItem("command");
                xml2.SetAttribute("action", "ui.show.text");
                xml2.SetAttribute("title", "Libraries and Tools");
                xml2.SetAttribute("body", ResourcesFiles.GetString("thirdparty.txt"));
                Command(xml2);
            }
            else if (action == "ui.show.website")
            {
                Platform.Instance.OpenUrl(Constants.WebSite + "/" + "");
            }
            else if (action == "ui.show.ports")
            {
                Platform.Instance.OpenUrl(Constants.WebSite + "/" + "ports/");
            }
            else if (action == "ui.show.speedtest")
            {
                Platform.Instance.OpenUrl(Constants.WebSite + "/" + "speedtest/");
            }
            else if (action == "ui.show.clientarea")
            {
                Platform.Instance.OpenUrl(Constants.WebSite + "/" + "client/");
            }
            else if (action == "ui.show.docs.general")
            {
                Platform.Instance.OpenUrl(Constants.WebSite + "/" + "software/");
            }
            else if (action == "ui.show.docs.protocols")
            {
                Platform.Instance.OpenUrl(Constants.WebSite + "/" + "faq/software_protocols/");
            }
            else if (action == "ui.show.docs.udp_vs_tcp")
            {
                Platform.Instance.OpenUrl(Constants.WebSite + "/" + "faq/udp_vs_tcp/");
            }
            else if (action == "ui.show.docs.tor")
            {
                Platform.Instance.OpenUrl(Constants.WebSite + "/" + "tor/");
            }
            else if (action == "ui.show.docs.advanced")
            {
                Platform.Instance.OpenUrl(Constants.WebSite + "/" + "faq/software_advanced/");
            }
            else if (action == "ui.show.docs.directives")
            {
                Platform.Instance.OpenUrl(Constants.WebSite + "/" + "faq/software_directives/");
            }
            else if (action == "ui.show.docs.lock")
            {
                Platform.Instance.OpenUrl(Constants.WebSite + "/" + "faq/software_lock/");
            }
            else if (action == "ui.show.sources")
            {
                string url = "https://github.com/AirVPN/airvpn-client";
                Platform.Instance.OpenUrl(url);
            }
            else if (action == "ui.show.gpl")
            {
                Platform.Instance.OpenUrl("http://www.gnu.org/licenses/gpl.html");
            }
            else if (action == "ui.show.openvpn.management")
            {
                Platform.Instance.OpenUrl("http://openvpn.net/index.php/open-source/documentation/miscellaneous/79-management-interface.html");
            }
            else if (action == "ui.stats.vpngeneratedovpn")
            {
                if (IsConnected() == false)
                    return;

                OnShowText(Messages.StatsVpnGeneratedOVPN, ConnectedOVPN);
            }
            else if (action == "ui.stats.systemreport")
            {
                OnShowText(Messages.StatsSystemReport, Platform.Instance.GenerateSystemReport());
            }
            else if (action == "ui.stats.pinger")
            {
                Core.Threads.Pinger.Instance.InvalidateAll();
                OnRefreshUi(Core.Engine.RefreshUiMode.Full);
            }
            else if (action == "ui.stats.manifestlastupdate")
            {
                Core.Threads.Manifest.Instance.ForceUpdate = true;
            }
            else if (action == "ui.stats.pathapp")
            {
                Platform.Instance.OpenDirectoryInFileManager(Stats.Get("PathApp").Value);
            }
            else if (action == "ui.stats.pathprofile")
            {
                Platform.Instance.OpenDirectoryInFileManager(Stats.Get("PathProfile").Value);
            }
            else if (action == "providers.add.airvpn")
            {
                Engine.Instance.ProvidersManager.AddProvider("AirVPN", null);
            }
            else if (action == "providers.add.openvpn")
            {
                Engine.Instance.ProvidersManager.AddProvider("OpenVPN", null);
            }
            else if (action == "testlog")
            {
                Engine.Instance.Logs.Log(LogType.Warning, "Test Log " + Utils.GetRandomToken());
            }
            else if (action == "ui.hello")
            {
                Engine.Instance.Command("ui.show.ready");
            }
            else if (action == "ui.start")
            {
                UiSendOsInfo();
                UiSendStatusInfo();
                UiSendQuickInfo();
            }
            else
            {
                if(ignoreIfNotExists == false)
                    throw new Exception(MessagesFormatter.Format(Messages.CommandUnknown, xml.ToString()));
            }
        }
예제 #3
0
        private void OnCommandEvent(XmlItem data)
        {
            lock (Clients)
            {
                CheckStillConnected();

                foreach (StateObject so in Clients)
                {
                    string x = data.ToString();
                    Send(so.workSocket, x + "\n");
                }
            }
        }