예제 #1
0
        private void ExecuteAsync()
        {
            while (!ShutDown)
            {
                Thread.Sleep(100);
                if (Idle)
                {
                    Idle = false;
                    if (ip == null)
                    {
                        ShutDown = true;
                        return;
                    }
                    foreach (var port in ports)
                    {
                        using (TcpClient client = new TcpClient())
                            if (client.ConnectAsync(ip, port).Wait(timeOut))
                            {
                                OnRespnse?.Invoke(this, true);
                                return;
                            }
                    }

                    OnRespnse?.Invoke(this, false);
                }
            }
        }
예제 #2
0
 public void Start()
 {
     //create workers
     for (int i = 0; i < Threads; i++)
     {
         Worker worker = new Worker();
         workers.Add(worker);
         worker.OnRespnse += (sender, success) =>
         {
             Debug.Print("response " + sender.ip);
             OnRespnse?.Invoke(sender.ip, success);
             string ip = GetIp();
             worker.Start(ip, Ports, TimeOut);
         };
     }
 }
예제 #3
0
        private void ExecuteAsync()
        {
            while (!ShutDown)
            {
                Thread.Sleep(100);
                if (Idle)
                {
                    Idle = false;
                    if (ip == null)
                    {
                        ShutDown = true;
                        return;
                    }
                    foreach (var port in ports)
                    {
                        try
                        {
                            Debug.Print(ip);
                            HttpWebRequest request = WebRequest.Create(ip) as HttpWebRequest;
                            request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2";
                            request.Proxy     = new WebProxy(proxy.ip, proxy.port);
                            HttpWebResponse     response = (HttpWebResponse)request.GetResponse();
                            WebHeaderCollection header   = response.Headers;
                            var encoding = ASCIIEncoding.ASCII;
                            using (var reader = new System.IO.StreamReader(response.GetResponseStream(), encoding))
                            {
                                string responseText = reader.ReadToEnd();
                                Debug.Print(responseText);
                                // Console.ReadLine();
                                if (responseText.Contains("ERROR:101"))
                                {
                                    OnRespnse?.Invoke(this, true);
                                }
                            }
                        }
                        catch (Exception)
                        {
                            OnRetry?.Invoke(ip);
                        }
                    }

                    OnRespnse?.Invoke(this, false);
                }
            }
        }
예제 #4
0
 public void Start()
 {
     //create workers
     for (int i = 0; i < Threads; i++)
     {
         Worker worker = new Worker();
         workers.Add(worker);
         worker.OnRetry += (domain) =>
         {
             retries++;
             domains.Add(domain);
         };
         worker.OnRespnse += (sender, success) =>
         {
             Debug.Print("response " + sender.ip);
             OnRespnse?.Invoke(sender.ip, success);
             string ip    = GetIp();
             Proxy  proxy = GetProxy();
             worker.Start(ip, Ports, TimeOut, GetProxy());
         };
     }
 }