• Earn real money by being active: Hello Guest, earn real money by simply being active on the forum — post quality content, get reactions, and help the community. Once you reach the minimum credit amount, you’ll be able to withdraw your balance directly. Learn how it works.

C# [C# source] Proxy checker

Status
Not open for further replies.

sQuo

~ KillmeMories ~
Shadow
User
Joined
Oct 16, 2011
Messages
5,851
Reputation
0
Reaction score
22,904
Points
688
Credits
0
‎13 Years of Service‎
24%
image.php


Features:

- lists proxy from .txt files.

- check if proxy is working (socket)

- export alive proxy

- uses background worker

Additional imports:

Code:
>using System.Net;
using System.Net.Sockets;
Classlevel declaration:

Code:
>OpenFileDialog opfd = new OpenFileDialog();
private string[] ipport;
btnCheck click event:

Code:
>aliveIPLV.Items.Clear();
           btnCheck.Enabled = false;
           bworker.RunWorkerAsync();
btnBrowse click event:

Code:
>opfd.FileName= "";
           opfd.Title = "Select proxy list file.";
           opfd.Filter = "txt files|*.txt";
           string pattern = @"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d{1,5}$";
           Regex rgx = new Regex(pattern);

           if (opfd.ShowDialog() == DialogResult.OK)
           {
               txtlocation.Text = opfd.FileName;
               availableIPLV.Items.Clear();
               btnExport.Enabled = false;
               ipport = File.ReadAllLines(opfd.FileName);
               for(int i = 0; i                 {
                  MatchCollection matches = rgx.Matches(ipport[i]);
                  if (matches.Count > 0)
                  {
                      foreach (Match mat in matches)
                      {
                          //MessageBox.Show(mat.Value);
                          string[] ipadd = mat.Value.Split(':');
                          availableIPLV.Items.Add(ipadd[0]);
                          availableIPLV.Items[i].SubItems.Add(ipadd[1]);
                      }
                  }
                  else {
                      MessageBox.Show("No IPs Found in the file!\r\n Format should bein: IP:Port", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                      return;
                  }
               }
               btnCheck.Enabled = true;
           }
bgworker dowork

Code:
>string[] ips = ipport;
           Socket connsock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
           connsock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, 200);

           for (int j = 0; j             {
               try
               {
                   System.Threading.Thread.Sleep(500);
                   string splitip = ips[j].ToString();
                   string[] hostip = splitip.Split(':');
                   double progress;
                   progress = (j + 1) * 100 / ips.Length;
                   
                   IPAddress hip = IPAddress.Parse(hostip[0]);
                   int hport = int.Parse(hostip[1]);

                   statusInfo.Text = "Trying: " + hostip[0] + ":" + hostip[1]; 
                   
                   //check through socket connection
                   IPEndPoint ipep = new IPEndPoint(hip, hport);
                   
                   connsock.Connect(ipep);
                   if (connsock.Connected)
                   {
                       bworker.ReportProgress(Convert.ToInt32(Math.Round(progress)), j);
                       continue;
                   }
                   else 
                   {
                       bworker.ReportProgress(Convert.ToInt32(Math.Round(progress)), "");
                   }
                   connsock.Close();
               }
               catch(SocketException x)
               {
                  //problem
                  }
               
             }
bgworker progresschange

Code:
>statusPbar.Value = e.ProgressPercentage;
           string aliveproxycounter = e.UserState.ToString();

           if (aliveproxycounter != null) {
               string[] aliveproxy = ipport[int.Parse(aliveproxycounter)].Split(':');
               aliveIPLV.Items.Add(aliveproxy[0]).SubItems.Add(aliveproxy[1]);
           }
bgworker completed

Code:
>if (aliveIPLV.Items.Count > 0)
           {
               btnExport.Enabled = true;
           }
           btnCheck.Enabled = true;
           statusPbar.Value = 0;
           statusInfo.Text = "Ready";
btnExport click event

Code:
>int numofcount = aliveIPLV.Items.Count;

           string[] aproxy = new string[numofcount];
           for (int i = 0; i                 {
                   aproxy[i] = aliveIPLV.Items[i].Text.ToString() + ":"+ aliveIPLV.Items[i].SubItems[1].Text.ToString();
               }

           SaveFileDialog sfile = new SaveFileDialog();
           sfile.Filter = "txt files|*.txt";
           sfile.Title = "Save fresh proxy";
          // sfile.ShowDialog();

            if (sfile.ShowDialog() == DialogResult.OK)
               {
                   File.WriteAllLines(sfile.FileName, aproxy);
               }
Creditos: 0x01

 
Status
Not open for further replies.
Back
Top