Hack Forums
[C#] [C#] Basic Proxy Checker source - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] [C#] Basic Proxy Checker source (/showthread.php?tid=1536887)



[C#] Basic Proxy Checker source - CaptainBri - Jul 29, 2011

I just wrote a Proxy Checker to improve my knowledge on multi-threading and invoking while on another thread, and this is what I made of it ^^

[Image: fqogg.png]

When you check the proxies

[Image: iojbV.png]

End result

[Image: 9EQpZ.png]

Pretty basic stuff, you can enter the timeout in the textbox and it will rule out all proxies that have a timeout for longer than that time (= not working or way to slow)

Up to you to advance it, such as resizing the app with anchors (easy ^^), copy to clipboard, scrollbars and stuff.

The source in plain text:

PHP Code

<?php 
int Working 
= 0;
  
int Broken = 0;
  
int Timeout = 10000;

  private 
void btnCheck_Click(object sender, EventArgs e)
  {
    
Working = 0;
    
Broken = 0;
    
Timeout = Convert.ToInt32(txtTimeout.Text);
    
string[] Lines = txtInputProxies.Lines;
    
prgProgress.Maximum = Lines.Length;

    for (
int i = 0; i < Lines.Length; i++)
    {
    new 
Thread(
    
delegate(object o)
    {
    try
    {
    
string[] Proxy = ((string)o).Split(':');
    
WebRequest req = WebRequest.Create("http://google.nl");
    
req.Proxy = new WebProxy(Proxy[0], Convert.ToInt32(Proxy[1]));
    
req.Timeout = Timeout;
    
req.GetResponse();
    
UpdateStatus(true, string.Join(":", Proxy));
    }
    catch
    {
    
UpdateStatus(false, "");
    }
    }
    ).
Start(Lines[i]);
    }
  }

  private 
void UpdateStatus(bool goodProxy, string Proxy)
  {
    
Invoke(new MethodInvoker(
    
delegate()
    {
    
prgProgress.Value++;
    if (
goodProxy)
    {
    
txtWorkingProxies.Text += Proxy + Environment.NewLine;
    
lblWorking.Text = "Working: " + (++Working).ToString();
    }
    else
    {
    
lblBroken.Text = "Broken: " + (++Broken).ToString();
    }
    
lblTotal.Text = "Total: " + (Broken + Working).ToString();
    }));
  } 

And if you'd like the project here it is: http://leetcoders.org/forum/showthread.php?tid=128 (Scroll to the bottom)

Have fun with it :)

CaptainBri



* - SIM-812607 - Sep 14, 2011

This looks really nice :D thank you, im downloading now. :)


* - ( ͡° ͜ʖ ͡°) - Sep 14, 2011

Thanks you very much! i will probably use this in the future!


* - nFоrсe - Sep 15, 2011

Seems like it will crash with more than 1,000 proxies lol.