예제 #1
0
        public void SelectNextProxy()
        {
            if (_preventDeadLock == WebProxies.Count + 1)
            {
                CurrentWebProxy  = null;
                UseProxy         = false;
                _preventDeadLock = 0;
                return;
            }

            WebProxies.Enqueue(WebProxies.Dequeue());
            WebProxy webProxy = WebProxies.Peek();
            RegCount rc       = ProxyRegCounts[webProxy];

            if (rc == null || rc.CountRegistrations < AllowReg)
            {
                CurrentWebProxy = webProxy;
                SaveCurrentProxyList();
                _preventDeadLock = 0;
            }
            else
            {
                _preventDeadLock++;
                SelectNextProxy();
            }
        }
예제 #2
0
        public void SelectNextProxy()
        {
            if (_preventDeadLock == WebProxies.Count + 1)
            {
                Logger.Info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                Logger.Info("Закончились прокси сервера на сегодня. Каждый уже зарегил максимум человек.");
                Logger.Info("Переключаюсь на основной адрес.");
                Logger.Info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                CurrentWebProxy  = null;
                UseProxy         = false;
                _preventDeadLock = 0;
                return;
            }

            WebProxies.Enqueue(WebProxies.Dequeue());
            WebProxy webProxy = WebProxies.Peek();
            RegCount rc       = ProxyRegCounts[webProxy];

            if (rc == null || rc.CountRegistrations < AllowReg)
            {
                CurrentWebProxy = webProxy;
                Logger.Info("SetProxy " + CurrentWebProxy.Address.Host + " " + CurrentWebProxy.Address.Port);
                SaveCurrentProxyList();
                _preventDeadLock = 0;
            }
            else
            {
                _preventDeadLock++;
                SelectNextProxy();
            }
        }
예제 #3
0
        // <summary>
        // Public function to get next proxies in a list
        // </summary>
        public void SelectNextProxy()
        {
            var taskProxy = new Task(() =>
            {
                if (_preventDeadLock == WebProxies.Count + 1)
                {
                    Logger.Info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                    Logger.Info("Закончились прокси сервера на сегодня. Каждый уже зарегил максимум человек.");
                    Logger.Info("Переключаюсь на основной адрес.");
                    Logger.Info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                    CurrentWebProxy  = null;
                    UseProxy         = false;
                    _preventDeadLock = 0;
                    return;
                }

                WebProxies.Enqueue(WebProxies.Dequeue());
                var webProxy = WebProxies.Peek();
                var rc       = ProxyRegCounts[webProxy];
                if (rc == null || rc.CountRegistrations < AllowReg)
                {
                    CurrentWebProxy = webProxy;
                    Logger.Info("SetProxy " + CurrentWebProxy.Address.Host + " " + CurrentWebProxy.Address.Port);
                    SaveCurrentProxyList();
                    _preventDeadLock = 0;
                }
                else
                {
                    _preventDeadLock++;
                    SelectNextProxy();
                }
            }, CancellationToken.None, TaskCreationOptions.AttachedToParent);

            taskProxy.Start();
            taskProxy.Wait();
        }