public ProxifierProxyServer getProxy(int ID) { ProxifierProxyServer result = null; if (this.innerProxyList.TryGetValue(ID, out result)) { return(result); } else { return(null); } }
public void Load(TextReader xmlReader) { XDocument innerXML = XDocument.Load(xmlReader); this.innerProfile.Clear(); if (innerXML != null) { XElement ProxifierProfile = innerXML.Element("ProxifierProfile"); if (ProxifierProfile != null) { XElement currentE; var b = ProxifierProfile.Element("Options"); if (b != null) { currentE = b.Element("Resolve"); if (currentE != null) { this.AutoModeDetection = Parse(currentE.Element("AutoModeDetection").Attribute("enabled"), false); this.ViaProxy = Parse(currentE.Element("ViaProxy").Attribute("enabled"), false); this.TryLocalDnsFirst = Parse(currentE.Element("ViaProxy").Element("TryLocalDnsFirst").Attribute("enabled"), false); this.ExclusionList = Parse(currentE.Element("ExclusionList"), "%ComputerName%; localhost; *.local"); } this.Encryption = Parse <EncryptionMode>(b.Element("Encryption").Attribute("mode"), EncryptionMode.disabled); this.HttpProxiesSupport = Parse(b.Element("HttpProxiesSupport").Attribute("enabled"), false); this.HandleDirectConnections = Parse(b.Element("HandleDirectConnections").Attribute("enabled"), false); this.ConnectionLoopDetection = Parse(b.Element("ConnectionLoopDetection").Attribute("enabled"), true); this.ProcessServices = Parse(b.Element("ProcessServices").Attribute("enabled"), true); this.ProcessOtherUsers = Parse(b.Element("ProcessOtherUsers").Attribute("enabled"), true); } Dictionary <int, int> transition = new Dictionary <int, int>(); XElement _ProxyList = ProxifierProfile.Element("ProxyList"); ProxifierProxyServer currentServer; int newIDServer; if (_ProxyList != null) { foreach (var c in _ProxyList.Elements()) { newIDServer = -1; currentServer = new ProxifierProxyServer(Parse(c.Attribute("id"), -1)); currentServer.Type = Parse <ProxyType>(c.Attribute("type"), ProxyType.SOCKS5); currentServer.Address = Parse(c.Element("Address"), string.Empty); currentServer.Port = Parse(c.Element("Port"), 1080); currentServer.Options = Parse(c.Element("Options"), 48); currentE = c.Element("Authentication"); if (currentE != null) { currentServer.Authentication = Parse(currentE.Attribute("enabled"), false); currentServer.Username = Parse(currentE.Element("Username"), string.Empty); currentServer.Password = Parse(currentE.Element("Password"), string.Empty); } newIDServer = this.innerProfile.AddProxy(currentServer); if (currentServer.ID >= 100) { if (currentServer.ID != newIDServer) { transition.Add(currentServer.ID, newIDServer); } } } } XElement _RuleList = ProxifierProfile.Element("RuleList"); ProxifierRule currentRule; if (_RuleList != null) { foreach (var c in _RuleList.Elements()) { currentRule = new ProxifierRule(Parse(c.Attribute("enabled"), true)); currentRule.Name = Parse(c.Element("ProxifierRule"), string.Empty); currentRule.Ports = Parse(c.Element("Ports"), string.Empty); currentRule.Applications = Parse(c.Element("Applications"), string.Empty); currentRule.Targets = Parse(c.Element("Targets"), string.Empty); currentRule.Action.Type = Parse <ActionType>(c.Element("Action").Attribute("type"), ActionType.Direct); if (currentRule.Action.Type != ActionType.Direct && currentRule.Action.Type != ActionType.Block) { newIDServer = Parse(c.Element("Action"), -1); if (transition.ContainsKey(newIDServer)) { currentRule.Action.ServerID = transition[newIDServer]; } else { currentRule.Action.ServerID = newIDServer; } } this.innerProfile.AddRule(currentRule); } } } } }
public void AddProxy(ProxifierProxyServer proxy) { this.innerProfile.AddProxy(proxy); }
public bool AddRule(bool enabled, string ruleName, string targetAddress, string Applications, string Ports, ActionType actionType, ProxifierProxyServer proxy) { if (this.innerProxyList.ContainsValue(proxy)) { return(this.AddRule(enabled, ruleName, targetAddress, Applications, Ports, actionType, proxy.ID)); } else { return(this.AddRule(enabled, ruleName, targetAddress, Applications, Ports, actionType)); } }
public int AddProxy(ProxifierProxyServer proxy) { this.innerProxyList.Add(this.proxyCount, proxy); this.proxyCount++; return(this.proxyCount - 1); }