Ejemplo n.º 1
0
        private void ThreadPoolMethod_Proxies(object objProxy)
        {
            try
            {
                countParseProxiesThreads++;

                string item = (string)objProxy;
                int IsPublic = 0;
                int Working = 0;
                string LoggedInIp = string.Empty;

                string proxyAddress = string.Empty;
                string proxyPort = string.Empty;
                string proxyUserName = string.Empty;
                string proxyPassword = string.Empty;

                string account = item;

                int DataCount = account.Split(':').Length;

                if (DataCount == 1)
                {
                    proxyAddress = account.Split(':')[0];
                    AddToProxysLogs("Proxy Not In correct Format");
                    AddToProxysLogs(account);
                    return;
                }
                if (DataCount == 2)
                {
                    proxyAddress = account.Split(':')[0];
                    proxyPort = account.Split(':')[1];
                }
                else if (DataCount > 2)
                {
                    //proxyAddress = account.Split(':')[0];
                    //proxyPort = account.Split(':')[1];
                    //proxyUserName = account.Split(':')[2];
                    //proxyPassword = account.Split(':')[3];
                    AddToProxysLogs("Proxy Not In correct Format");
                    AddToProxysLogs(account);
                    return;
                }

                ProxyChecker proxyChecker = new ProxyChecker(proxyAddress, proxyPort, proxyUserName, proxyPassword, IsPublic);
                if (proxyChecker.CheckProxy())
                {
                    //lock (((System.Collections.ICollection)listWorkingProxies).SyncRoot)
                    {
                        //if (!listWorkingProxies.Contains(proxy))
                        {
                            workingproxiesCount++;
                            //listWorkingProxies.Add(proxy);
                            lock (proxyListLockr)
                            {
                                queWorkingProxies.Enqueue(item);
                                Monitor.Pulse(proxyListLockr);
                            }
                            AddToProxysLogs("Added " + item + " to working proxies list");
                            //Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(item, Globals.FilePathWorkingProxies);
                        }
                    }
                }
                else
                {
                    AddToProxysLogs("Non Working Proxy: " + proxyAddress + ":" + proxyPort);
                    GlobusFileHelper.AppendStringToTextfileNewLine(item, Globals.Path_Non_ExsistingProxies);
                }

                #region Commented
                //string pageSource = string.Empty;
                //try
                //{
                //    GlobusHttpHelper httpHelper = new GlobusHttpHelper();
                //    pageSource = httpHelper.getHtmlfromUrlProxy(new Uri("https://twitter.com/"), "", proxyAddress, proxyPort, proxyUserName, proxyPassword);
                //}
                //catch (Exception ex)
                //{
                //    GlobusFileHelper.AppendStringToTextfileNewLine(item, Globals.Path_Non_ExsistingProxies);
                //}
                //if (pageSource.Contains("class=\"signin\"") && pageSource.Contains("class=\"signup\"") && pageSource.Contains("Twitter"))
                //{
                //    using (SQLiteConnection con = new SQLiteConnection(DataBaseHandler.CONstr))
                //    {
                //        //using (SQLiteDataAdapter ad = new SQLiteDataAdapter("SELECT * FROM tb_FBAccount WHERE ProxyAddress = '" + proxyAddress + "'", con))
                //        using (SQLiteDataAdapter ad = new SQLiteDataAdapter())
                //        {
                //            if (DataCount >= 2)
                //            {
                //                //0 is true
                //                IsPublic = 0;
                //            }
                //            else
                //            {
                //                //1 is false
                //                IsPublic = 1;
                //            }
                //            Working = 1;
                //            string InsertQuery = "Insert into tb_Proxies values('" + proxyAddress + "','" + proxyPort + "','" + proxyUserName + "','" + proxyPassword + "', " + Working + "," + IsPublic + " , '" + LoggedInIp + "')";
                //            DataBaseHandler.InsertQuery(InsertQuery, "tb_Proxies");
                //        }
                //    }
                //    ValidPublicProxies.Add(item);
                //} 

                #endregion
            }
            catch (Exception ex)
            {
                AddToProxysLogs(ex.Message);
            }
            finally
            {
                lock (proxiesThreadLockr)
                {
                    countParseProxiesThreads--;
                    Monitor.Pulse(proxiesThreadLockr);
                }
            }
        }
Ejemplo n.º 2
0
        private void ThreadPoolMethod_Proxies(object objProxy)
        {
            try
            {
                if (!proxy_stop)
                {
                    try
                    {
                        lstStopPublicProxyTest.Add(Thread.CurrentThread);
                        lstStopPublicProxyTest = lstStopPublicProxyTest.Distinct().ToList();
                        Thread.CurrentThread.IsBackground = true;
                    }
                    catch { }

                    countParseProxiesThreads++;

                    string item = string.Empty;

                    Array paramsArray = new Array[1];
                    paramsArray = (Array)objProxy;

                    try
                    {
                        item = (string)paramsArray.GetValue(0);
                    }
                    catch { };
                    int IsPublic = 0;
                    //int Working = 0;
                    string LoggedInIp = string.Empty;
                    string proxyAddress = string.Empty;
                    string proxyPort = string.Empty;
                    string proxyUserName = string.Empty;
                    string proxyPassword = string.Empty;
                    string account = item;
                    int DataCount = account.Split(':').Length;
                    #region Check condition Thread is Stop or Not

                    #endregion

                    if (DataCount == 1)
                    {
                        proxyAddress = account.Split(':')[0];
                        AddToProxysLogs("[ " + DateTime.Now + " ] => [ Proxy Not In correct Format ]");
                        AddToProxysLogs(account);
                        return;
                    }
                    if (DataCount == 2)
                    {
                        proxyAddress = account.Split(':')[0];
                        proxyPort = account.Split(':')[1];
                    }
                    else if (DataCount > 2)
                    {
                        //proxyAddress = account.Split(':')[0];
                        //proxyPort = account.Split(':')[1];
                        //proxyUserName = account.Split(':')[2];
                        //proxyPassword = account.Split(':')[3];
                        AddToProxysLogs("[ " + DateTime.Now + " ] => [ Proxy Not In correct Format ]");
                        AddToProxysLogs(account);
                        return;
                    }

                    ProxyChecker proxyChecker = new ProxyChecker(proxyAddress, proxyPort, proxyUserName, proxyPassword, IsPublic);
                    if (proxyChecker.CheckProxy())
                    {
                        //lock (((System.Collections.ICollection)listWorkingProxies).SyncRoot)
                        {
                            //if (!listWorkingProxies.Contains(proxy))
                            {
                                workingproxiesCount++;
                                //listWorkingProxies.Add(proxy);
                                lock (proxyListLockr)
                                {
                                    queWorkingProxies.Enqueue(item);
                                    Monitor.Pulse(proxyListLockr);
                                }
                                AddToProxysLogs("[ " + DateTime.Now + " ] => [ Added " + item + " to working proxies list ]");
                                //Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(item, Globals.FilePathWorkingProxies);
                            }
                        }
                    }
                    else
                    {
                        AddToProxysLogs("[ " + DateTime.Now + " ] => [ Non Working Proxy: " + proxyAddress + ":" + proxyPort + " ]");
                        GlobusFileHelper.AppendStringToTextfileNewLine(item, Globals.Path_Non_ExsistingProxies);
                    }

                    #region Commented

                    //string pageSource = string.Empty;
                    //try
                    //{
                    //    GlobusHttpHelper httpHelper = new GlobusHttpHelper();
                    //    pageSource = httpHelper.getHtmlfromUrlProxy(new Uri("https://twitter.com/"), "", proxyAddress, proxyPort, proxyUserName, proxyPassword);
                    //}
                    //catch (Exception ex)
                    //{
                    //    GlobusFileHelper.AppendStringToTextfileNewLine(item, Globals.Path_Non_ExsistingProxies);
                    //}
                    //if (pageSource.Contains("class=\"signin\"") && pageSource.Contains("class=\"signup\"") && pageSource.Contains("Twitter"))
                    //{
                    //    using (SQLiteConnection con = new SQLiteConnection(DataBaseHandler.CONstr))
                    //    {
                    //        //using (SQLiteDataAdapter ad = new SQLiteDataAdapter("SELECT * FROM tb_FBAccount WHERE ProxyAddress = '" + proxyAddress + "'", con))
                    //        using (SQLiteDataAdapter ad = new SQLiteDataAdapter())
                    //        {
                    //            if (DataCount >= 2)
                    //            {
                    //                //0 is true
                    //                IsPublic = 0;
                    //            }
                    //            else
                    //            {
                    //                //1 is false
                    //                IsPublic = 1;
                    //            }
                    //            Working = 1;
                    //            string InsertQuery = "Insert into tb_Proxies values('" + proxyAddress + "','" + proxyPort + "','" + proxyUserName + "','" + proxyPassword + "', " + Working + "," + IsPublic + " , '" + LoggedInIp + "')";
                    //            DataBaseHandler.InsertQuery(InsertQuery, "tb_Proxies");
                    //        }
                    //    }
                    //    ValidPublicProxies.Add(item);
                    //}

                    #endregion

                }
            }
            catch (Exception ex)
            {
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Proxy Setting --> ThreadPoolMethod_Proxies() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs);
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Proxy Setting --> ThreadPoolMethod_Proxies() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinProxySettingErrorLogs);

            }

            finally
            {

                lock (proxiesThreadLockr)
                {
                    countParseProxiesThreads--;
                    Monitor.Pulse(proxiesThreadLockr);
                }

                Proxystatus--;
                if (Proxystatus == 0)
                {
                    if (btnTestPublicProxy.InvokeRequired)
                    {
                        btnTestPublicProxy.Invoke(new MethodInvoker(delegate
                        {
                            AddToProxysLogs("[ " + DateTime.Now + " ] => [ PROCESS COMPLETED ]");
                            AddToProxysLogs("-----------------------------------------------------------------------------------------------------------------------------------");
                        }));
                    }
                }
            }
        }