示例#1
0
        private void ThreadPoolMethod_Proxies(object objProxy)
        {
            try
            {
                LstPublicProxy.Add(Thread.CurrentThread);
                LstPublicProxy = LstPublicProxy.Distinct().ToList();
                Thread.CurrentThread.IsBackground = true;

                Interlocked.Increment(ref countParseProxiesThreads);
                //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("[ " + DateTime.Now + " ] => [ Proxy Not In correct Format ]");
                    AddToProxysLogs("[ " + DateTime.Now + " ] => [ " + 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("[ " + DateTime.Now + " ] => [ " + account + " ]");
                    return;
                }

                try
                {
                    dictionary_Threads.Add("proxy_" + proxyAddress, Thread.CurrentThread);
                }
                catch { };

                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 ]");

                            lock (Locker_LstRunningProxy_ProxyModule)
                            {
                                LstRunningProxy_ProxyModule.Add(item);
                            }

                            Globals.EnquequeWorkingProxiesForSignUp(item);

                            //Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(item, Globals.FilePathWorkingProxies);
                        }
                    }
                }
                else
                {
                    AddToProxysLogs("[ " + DateTime.Now + " ] => [ Non Working Proxy: " + proxyAddress + ":" + proxyPort + " ]");
                    GlobusFileHelper.AppendStringToTextfileNewLine(item, Globals.Path_Non_ExistingProxies);
                }

                #region Commented code
                //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--;
                    Interlocked.Decrement(ref countParseProxiesThreads);
                    Monitor.Pulse(proxiesThreadLockr);
                }

                threadcountForFinishMSG--;

                if (threadcountForFinishMSG == 0)
                {

                    AddToProxysLogs("[ " + DateTime.Now + " ] => [ PROCESS COMPLETED ]");
                    AddToProxysLogs("-----------------------------------------------------------------------------------------------------------------------");
                }

            }
        }
示例#2
0
        public void ThreadPoolCheckProxies(object parameters)
        {
            try
            {
                Array paramsArray = new object[2];

                paramsArray = (Array)parameters;

                DataRow dr = (DataRow)paramsArray.GetValue(0);

                clsDBQueryManager db = new clsDBQueryManager();

                string proxyAddress = dr[0].ToString();
                string proxyPort = dr[1].ToString();
                string proxyUsername = string.Empty;
                string proxyPassword = string.Empty;
                int IsPublic = 0;
                int Working = 0;

                ProxyChecker pc = new ProxyChecker(proxyAddress, proxyPort, proxyUsername, proxyPassword, 0);
                bool RunningProxy = pc.CheckProxy();

                if (!RunningProxy)
                {
                    DataBaseHandler Db = new DataBaseHandler();
                    DataBaseHandler.DeleteQuery("DELETE FROM tb_Proxies WHERE ProxyAddress ='" + proxyAddress + "' AND ProxyPort ='" + proxyPort + "'", "tb_Proxies");
                }
            }
            catch (Exception ex)
            {
                GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> ThreadPoolCheckProxies()  --> " + ex.Message, Globals.Path_ProxySettingErroLog);
                GlobusFileHelper.AppendStringToTextfileNewLine("Error --> ThreadPoolCheckProxies() --> " + ex.Message, Globals.Path_TwtErrorLogs);
            }
        }
示例#3
0
        private void CheckAndFillProxyInQueue()
        {
            try
            {
                string proxyAddress = string.Empty;
                string proxyPort = string.Empty;
                string proxyUsername = string.Empty;
                string proxyPassword = string.Empty;

                int isPublic = 0;

                if (frmMain_NewUI.LstRunningProxy_ProxyModule.Count > 0)
                {
                    List<string> lstTemp = frmMain_NewUI.LstRunningProxy_ProxyModule.Distinct().ToList();

                    AddToMobileLogs("[ " + DateTime.Now + " ] => [ " + lstTemp.Count + " Proxy Loaded ! ]");

                    foreach (string item in lstTemp)
                    {
                        try
                        {
                            proxyAddress = item.Split(':')[0];
                            proxyPort = item.Split(':')[1];
                            proxyUsername = item.Split(':')[2];
                            proxyPassword = item.Split(':')[3];

                            ProxyChecker obj_ProxyChecker = new ProxyChecker(proxyAddress, proxyPort, proxyUsername, proxyPassword, isPublic);

                            if (obj_ProxyChecker.CheckProxy())
                            {
                                qRunningProxy_Mobile.Enqueue(item);
                            }

                            lock (frmMain_NewUI.Locker_LstRunningProxy_ProxyModule)
                            {
                                frmMain_NewUI.LstRunningProxy_ProxyModule.Remove(item);
                            }

                            AddToMobileLogs("[ " + DateTime.Now + " ] => [ Not Running Proxy >>> " + item + " ]");
                        }
                        catch
                        {
                        }
                    }
                }
                else
                {
                    AddToMobileLogs("[ " + DateTime.Now + " ] => [ There Is No Running Proxy. So Please Upload The New Proxy And Start Process Aggain ! ]");
                    // return;
                }
            }
            catch
            {
            }
        }