Ejemplo n.º 1
0
        internal static void doOnProxyListChange(TeknarProxy proxy)
        {
            if (onProxyListChange == null)
            {
                return;
            }
            var ilist = onProxyListChange.GetInvocationList();

            foreach (EventHandler <TeknarProxy> handler in ilist)
            {
                syncContext.Post(new SendOrPostCallback((o) => { handler(handler.Target, proxy); }), null);
            }
        }
Ejemplo n.º 2
0
        private static void FPLN_ParseProxies(string html)
        {
            var trs = html.Replace("\r", string.Empty).Replace("\n", string.Empty).
                      Split(new string[] { "table" }, StringSplitOptions.RemoveEmptyEntries)[6].
                      Split(new string[] { "<tr>", "</tr>" }, StringSplitOptions.RemoveEmptyEntries).Where(item => item.StartsWith("<td>")).ToList();

            foreach (var tr in trs)
            {
                try
                {
                    var tds      = tr.Split(new string[] { "<td>", "</td>" }, StringSplitOptions.RemoveEmptyEntries);
                    var newProxy = new TeknarProxy
                    {
                        country  = tds[3].Trim(),
                        ip       = tds[0].Trim(),
                        port     = ushort.Parse(tds[1].Trim()),
                        security = (anonymity_level)Enum.Parse(typeof(anonymity_level), tds[4].Replace(" ", string.Empty).Trim().ToUpperInvariant()),
                        type     = (protocol)Enum.Parse(typeof(protocol), tds[6].Replace(" ", string.Empty).Trim().ToUpperInvariant()),
                    };
                    if (newProxy.security < anonymity_level.HIGH)
                    {
                        continue;
                    }
                    var         key = string.Format("{0}:{1}", newProxy.ip, newProxy.port);
                    TeknarProxy proxy;
                    if (proxyList.TryGetValue(key, out proxy))
                    {
                        proxy._pheromone = TeknarProxy.InitialPheromoneValue;
                        proxy.security   = newProxy.security;
                        proxy.type       = newProxy.type;
                        proxy.country    = newProxy.country;
                    }
                    else
                    {
                        proxyList[key] = newProxy;
                    }
                    doOnProxyListChange(proxyList[key]);
                }
                catch (Exception)
                {
                }
            }
        }
        private static void HMA_ParseProxies(string table)
        {
            try
            {
                IHTMLDocument2 doc = (IHTMLDocument2)new HTMLDocument();
                doc.write(string.Format("<table>{0}</table>", table.Replace("\r\n", string.Empty)));
                IHTMLElementCollection rows = ((IHTMLDocument3)doc).getElementsByTagName("tr");
                for (int i = 0; i < rows.length; i++)
                {
                    try
                    {
                        HTMLTableRow row = rows.item(i);
                        var type = (protocol)Enum.Parse(typeof(protocol), rows.item(i).cells.item(6).innerText.Replace("/", string.Empty).ToUpperInvariant());
                        var security = (anonymity_level)Enum.Parse(typeof(anonymity_level), rows.item(i).cells.item(7).innerText.Replace(" +", string.Empty).ToUpperInvariant());
                        if (type == protocol.SOCKS45 || security < anonymity_level.HIGH) continue;

                        var ipChilds = ((IHTMLDOMNode)row.cells.item(1)).firstChild.childNodes;
                        string ipaddress = "";
                        for (int j = 0; j < ipChilds.length; j++)
                        {
                            var element = ipChilds.item(j) as IHTMLDOMNode;
                            string tagname = element.nodeName;
                            if (tagname == "#text") ipaddress += element.nodeValue;
                            else
                            {
                                var element2 = (IHTMLElement2)element;
                                string display = element2.currentStyle.display;
                                if (display != "none") ipaddress += ((IHTMLElement)element).innerText;
                            }
                        }
                        var port = ushort.Parse(((IHTMLElement)row.cells.item(2)).innerText);
                        var key = string.Format("{0}:{1}", ipaddress, port);
                        TeknarProxy newProxy = new TeknarProxy
                        {
                            ip = ipaddress,
                            port = ushort.Parse(((IHTMLElement)row.cells.item(2)).innerText),
                            country = ((IHTMLElement)row.cells.item(3)).innerText,
                            type = type,
                            security = security
                        };
                        TeknarProxy proxy;
                        if (proxyList.TryGetValue(key, out proxy))
                        {
                            proxy._pheromone = TeknarProxy.InitialPheromoneValue;
                            proxy.security = newProxy.security;
                            proxy.type = newProxy.type;
                            proxy.country = newProxy.country;
                        }
                        else
                        {
                            proxyList[key] = newProxy;
                        }
                        doOnProxyListChange(proxyList[key]);
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            catch (Exception)
            {
            }
        }