public void UiSendStatusInfo() { // Data sended in case of big event, like connect/disconnect. XmlItem xml = new XmlItem("command"); xml.SetAttribute("action", "ui.info.status"); xml.SetAttributeBool("logged", IsLogged()); xml.SetAttributeBool("waiting", IsWaiting()); xml.SetAttribute("waiting.message", WaitMessage); xml.SetAttributeBool("connected", IsConnected()); xml.SetAttributeBool("netlock", ((Engine.Instance.NetworkLockManager != null) && (Engine.Instance.NetworkLockManager.IsActive()))); if(CurrentServer != null) { xml.SetAttribute("server.country.code", CurrentServer.CountryCode); xml.SetAttribute("server.display-name", CurrentServer.DisplayName); } Command(xml); }
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())); } }
public void UiSendOsInfo() { // Data sended at connection, never changed, at least until options changes. XmlItem xml = new XmlItem("command"); xml.SetAttribute("action", "ui.info.os"); xml.SetAttribute("eddie.version.text", Constants.VersionDesc); xml.SetAttributeInt("eddie.version.int", Constants.VersionInt); xml.SetAttribute("eddie.windows.tap.driver", Constants.WindowsDriverVersion); xml.SetAttribute("eddie.windows-xp.tap.driver", Constants.WindowsXpDriverVersion); xml.SetAttributeBool("eddie.development", DevelopmentEnvironment); xml.SetAttribute("mono.version", Platform.Instance.GetMonoVersion()); xml.SetAttribute("os.code", Platform.Instance.GetSystemCode()); xml.SetAttribute("os.name", Platform.Instance.GetName()); xml.SetAttribute("tools.tap-driver.version", Software.OpenVpnDriver); xml.SetAttribute("tools.openvpn.version", Software.OpenVpnVersion); xml.SetAttribute("tools.openvpn.path", Software.OpenVpnPath); xml.SetAttribute("tools.ssh.version", Software.SshVersion); xml.SetAttribute("tools.ssh.path", Software.SshPath); xml.SetAttribute("tools.ssl.version", Software.SslVersion); xml.SetAttribute("tools.ssl.path", Software.SslPath); Command(xml); }
public void Log(LogType Type, string Message, int BalloonTime, Exception e) { // Avoid repetition if (Message == m_logLast) return; m_logLast = Message; LogEntry l = new LogEntry(); l.Type = Type; l.Message = Message; l.BalloonTime = BalloonTime; l.Exception = e; if (l.Type > LogType.Realtime) { m_lastLogMessage = l.Message; m_logDotCount += 1; m_logDotCount = m_logDotCount % 10; } Entries.Add(l); if( (Engine.Instance != null) && (Engine.Instance.Storage != null) && (Entries.Count >= Engine.Instance.Storage.GetInt("gui.log_limit")) ) Entries.RemoveAt(0); if(LogEvent != null) LogEvent(l); XmlItem xml = new XmlItem("command"); xml.SetAttribute("action", "ui.log"); l.WriteXML(xml); Engine.Instance.Command(xml); Engine.Instance.OnLog(l); }
public void WriteXML(XmlItem item) { item.SetAttributeInt64("timestamp", Conversions.ToUnixTime(Date)); item.SetAttribute("level", GetTypeString()); item.SetAttribute("message", Message); }
public void UpdateValue(string key, string newValue) { StatsEntry entry = Get(key); if (entry.Value != newValue) { entry.Value = newValue; XmlItem xml = new XmlItem("command"); xml.SetAttribute("action", "ui.stats.change"); entry.WriteXML(xml); Engine.Instance.Command(xml); Engine.Instance.OnStatsChange(entry); } }
public void WriteXML(XmlItem item) { item.SetAttribute("key", Key); item.SetAttribute("value", Value); item.SetAttribute("text", Text); }