Beispiel #1
0
        internal static bool CycleProxy(ClientSocket cs)
        {
            //reduces the count of how many times this specific proxy ip has been used
            LowerUseCount(cs.ProxyAddress);

            ProxyDetails proxy = NextAddress();

            if (proxy == null)
            {
                return(false);
            } //no more keys
            else
            {
                cs.ProxyPort    = proxy.Port;
                cs.ProxyAddress = proxy.Address;
                cs.ProxyFormat  = proxy.Type;
                return(true);
            }
        }
Beispiel #2
0
        //loads all proxy list
        internal static void ImportProxylist()
        {
            //clear proxy list, reset take from index
            _proxyList.Clear();
            _proxyIndex = 0;

            string[] paths;
            paths = new string[]
            {
                GeneratedSettings.AppDirectory + @"\Text\Proxies.txt",
                GeneratedSettings.AppDirectory + @"\Text\ProxiesHttp.txt",
                GeneratedSettings.AppDirectory + @"\Text\ProxiesS4.txt",
                GeneratedSettings.AppDirectory + @"\Text\ProxiesS5.txt"
            };

            ProxyType[] types;
            types = new ProxyType[]
            {
                ProxyType.Default,
                ProxyType.Http,
                ProxyType.Socks4,
                ProxyType.Socks5
            };


            for (int i = 0; i < paths.Length; i++)
            {
                string    path     = paths[i];
                string    fileText = null; //default
                ProxyType type     = types[i];

                if (File.Exists(path))
                {
                    StreamReader FileReader = new StreamReader(path);
                    while ((fileText = FileReader.ReadLine()) != null)
                    {
                        try
                        {
                            fileText = TidyText(fileText);

                            if (!string.IsNullOrEmpty(fileText))
                            { //filetext still contains data, lets proceed
                                //set proxy type from the beginning if reading from a specified type file
                                switch (type)
                                {
                                case ProxyType.Default:
                                    break;

                                case ProxyType.Http:
                                    fileText = fileText + "@http";
                                    break;

                                case ProxyType.Socks4:
                                    fileText = fileText + "@s4";
                                    break;

                                case ProxyType.Socks5:
                                    fileText = fileText + "@s5";
                                    break;
                                }

                                //pass string to proxy parser
                                ProxyDetails proxyInfo = new ProxyDetails(); //initialize
                                ProxyParser  parser    = new ProxyParser();
                                parser.Engage(fileText);                     //presets some valus on our sorter

                                proxyInfo.Address = parser.ReturnAddress();

                                //if valid ip proceed
                                if (proxyInfo.Address != null)
                                {
                                    //if already in list continue past
                                    if (ReturnProxyIndex(proxyInfo.Address) != -1)
                                    {
                                        continue;
                                    }
                                    proxyInfo.Port      = parser.ReturnPort();
                                    proxyInfo.Type      = parser.ReturnType();
                                    proxyInfo.UsedCount = 0;
                                    //bool proxyFound = _proxyList.Exists(IPAddress => IPAddress.Address == proxyInfo.Address);
                                    //if (!proxyFound)
                                    //{
                                    _proxyList.Add(proxyInfo);
                                }
                            }
                        } //try end
                        finally
                        {
                            //do nothing
                        } //try set scanlist entry
                    }
                    FileReader.Close();
                }
            }

            Chat.Add(Color.Silver, "Loaded " + _proxyList.Count + " proxies." + Environment.NewLine);
        }