Exemplo n.º 1
0
 private bool UseCurrentProxy()
 {
     if (CheckIfHealthy() == HealthStatus.Healthy)
     {
         Output("AutoProxyManager: UseCurrentProxy " + _currentProxy.ToString());
         GlobalCache.MainForm.Invoke(() =>
         {
             GeckoSettings.HttpProxy     = _currentProxy.IP;
             GeckoSettings.HttpProxyPort = _currentProxy.Port;
         });
         StartMonitoring();
         HideOutput();
         return(true);
     }
     return(false);
 }
Exemplo n.º 2
0
        private void RecycleCurrentProxy()
        {
            if (_currentProxy == null)
            {
                return;
            }
            HttpProxyEntity currentProxy = _currentProxy;

            new Async(() =>
            {
                API.SDK.Extend.HttpProxy.Instance.RecycleProxy(Utility.EncryptHelper.Encrypt(currentProxy.ProxyId));
                Output("AutoProxyManager: RecycleCurrentProxy " + currentProxy.ToString());
            }).Start();
        }
Exemplo n.º 3
0
 private HttpProxyStartStatus UseNewProxy()
 {
     if (IsConnectInternet())
     {
         try
         {
             while (badProxyRetry < BadProxyRetryMax)
             {
                 RecycleCurrentProxy(); // 先回收
                 var serverRes = API.SDK.Extend.HttpProxy.Instance.GetProxy(TokenManager.CachedToken, GlobalCache.CurrentTaskId);
                 if (serverRes.IsSuccess)
                 {
                     _currentProxy    = serverRes.Data;
                     _currentProxy.IP = Utility.EncryptHelper.Decrypt(_currentProxy.IP);
                     Output("AutoProxyManager: UseNewProxy " + _currentProxy.ToString());
                     if (UseCurrentProxy())
                     {
                         return(HttpProxyStartStatus.OK);
                     }
                 }
                 else
                 {
                     Output($"{serverRes.Error}, {serverRes.Error},重试{badProxyRetry + 1}/{BadProxyRetryMax + 1}...", true);
                 }
                 badProxyRetry++;
             }
         }
         catch (Exception ex)
         {
             Log.Default.Error(ex);
         }
         return(HttpProxyStartStatus.ProxyServiceInvalid);
     }
     else
     {
         return(HttpProxyStartStatus.NetworkDown);
     }
 }