Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Net;
- using System.Collections;
- using System.IO;
- using System.Windows.Forms;
- namespace Proxy_Checker
- {
- class Program
- {
- private static int ProxyCount = 0;
- private static string[] split;
- private static string Myproxy;
- private static int ReturnPort(String Proxy)
- {
- try
- {
- split = Proxy.Split(':');
- }
- catch (ArgumentException)
- {
- ProxyCount++;
- }
- return int.Parse(split[1]);
- }
- private static int TimeOut;
- public static List<String> MyList = new List<string>();
- private static String ReturnAddress(String Proxy)
- {
- try
- {
- split = Proxy.Split(':');
- }
- catch (ArgumentException)
- {
- ProxyCount++;
- }
- return split[0];
- }
- private static void LoadProxies()
- {
- try
- {
- if (!File.Exists(Application.StartupPath + "/Proxies.txt"))
- {
- Console.WriteLine("Proxy text file doesn't exist, please fill it up now");
- File.Create(Application.StartupPath + "/Proxies.txt");
- Console.Beep(5000, 2000);
- System.Threading.Thread.Sleep(5000);
- Environment.Exit(0);
- }
- else if (File.Exists(Application.StartupPath + "/Proxies.txt"))
- {
- StreamReader reader = new StreamReader(Application.StartupPath + "/Proxies.txt");
- while (reader.Peek() > -1)
- {
- MyList.Add(reader.ReadLine());
- //Console.WriteLine(reader.ReadLine());
- }
- }
- }
- catch (IOException)
- {
- Console.WriteLine("Input/Output Exception");
- Console.Beep(5000, 2000);
- System.Threading.Thread.Sleep(5000);
- Environment.Exit(0);
- }
- }
- private static void SaveProxy(String Proxy)
- {
- try
- {
- if (!File.Exists(Application.StartupPath + "/Working Proxies.txt"))
- {
- StreamReader reader = new StreamReader(Application.StartupPath + "/Working Proxies.txt");
- StreamWriter writer = new StreamWriter(Application.StartupPath + "/Working Proxies.txt");
- File.Create(Application.StartupPath + "/Working Proxies.txt");
- writer.WriteLine(Proxy);
- writer.Close();
- }
- else
- {
- StreamReader reader = new StreamReader(Application.StartupPath + "/Working Proxies.txt");
- StreamWriter writer = new StreamWriter(Application.StartupPath + "/Working Proxies.txt");
- File.Create(Application.StartupPath + "/Working Proxies.txt");
- string tempp = reader.ReadToEnd();
- writer.Write(tempp + Environment.NewLine + Proxy);
- writer.Close();
- }
- }
- catch (IOException)
- {
- Console.WriteLine("Error saving proxy");
- }
- }
- static void Main(string[] args)
- {
- Console.WriteLine("Proxy Checker ~ BuckleyInDaHouse");
- Console.WriteLine("");
- R:
- Console.WriteLine("Please enter a timeout in seconds");
- try
- {
- TimeOut = Convert.ToInt32(Console.ReadLine()) * 1000;
- }
- catch (ArgumentException)
- {
- Console.WriteLine("Error reading your timeout number");
- Console.WriteLine(Environment.NewLine);
- goto R;
- }
- LoadProxies();
- while (ProxyCount <= MyList.Count)
- {
- Console.Title = "BuckleyInDaHouse Proxy Checker ~~ On proxy " + ProxyCount + " of a total " + MyList.Count;
- try
- {
- System.Diagnostics.Stopwatch Watch = new System.Diagnostics.Stopwatch();
- Watch.Start();
- Myproxy = MyList[ProxyCount];
- WebProxy pr = new WebProxy(ReturnAddress(Myproxy), ReturnPort(Myproxy));
- //Console.WriteLine("Address: " + ReturnAddress(Myproxy) + " Port: " + ReturnPort(Myproxy));
- WebRequest request = HttpWebRequest.Create("http://big.joshua.buckley.googlepages.com/ProxyTester.txt");
- request.Proxy = pr;
- request.Timeout = TimeOut;
- WebResponse response = request.GetResponse();
- StreamReader myreader = new StreamReader(response.GetResponseStream());
- string temp = myreader.ReadToEnd();
- if (temp.IndexOf("Hello World") > 0)
- {
- Watch.Stop();
- int TempTimeOut = Watch.Elapsed.Milliseconds;
- Console.WriteLine("Proxy: " + Myproxy + " Works. TimeOut: " + TempTimeOut);
- SaveProxy(Myproxy);
- ProxyCount++;
- }
- else if (string.IsNullOrEmpty(temp))
- {
- Console.WriteLine("Proxy: " + Myproxy + " doesn't Work.");
- ProxyCount++;
- }
- }
- catch (WebException web)
- {
- Console.WriteLine("Proxy: " + Myproxy + " Timed out");
- ProxyCount++;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement