Exemplo n.º 1
0
        private VpnReconnectionSteps UpdateReconnectionStepIfSimilarOnAutoProtocol(VpnReconnectionSteps reconnectionStep)
        {
            if (reconnectionStep == VpnReconnectionSteps.SimilarOnSmartProtocol)
            {
                reconnectionStep = CalculateSimilarOnAutoProtocolReconnectionStep();
            }

            return(reconnectionStep);
        }
Exemplo n.º 2
0
        private VpnReconnectionSteps RestartReconnectionStepsIfRequested(VpnReconnectionSteps reconnectionStep)
        {
            if (reconnectionStep == VpnReconnectionSteps.RestartReconnectionSteps)
            {
                _logger.Info("Restarting reconnection process from the first step.");
                reconnectionStep = VpnReconnectionSteps.SimilarOnSameProtocol;
            }

            return(reconnectionStep);
        }
Exemplo n.º 3
0
        private VpnReconnectionSteps IncrementReconnectionStep(VpnReconnectionSteps reconnectionStep)
        {
            if (reconnectionStep < VpnReconnectionSteps.RestartReconnectionSteps)
            {
                reconnectionStep++;
            }

            reconnectionStep = UpdateReconnectionStepIfLastConnectionDataIsNotAvailable(reconnectionStep);
            reconnectionStep = UpdateReconnectionStepIfSimilarOnAutoProtocol(reconnectionStep);
            reconnectionStep = RestartReconnectionStepsIfRequested(reconnectionStep);

            return(reconnectionStep);
        }
Exemplo n.º 4
0
        private VpnReconnectionSteps UpdateReconnectionStepIfLastConnectionDataIsNotAvailable(
            VpnReconnectionSteps reconnectionStep)
        {
            if (_targetProfile == null &&
                (_targetServer == null || _targetServer.IsEmpty()) &&
                reconnectionStep != VpnReconnectionSteps.RestartReconnectionSteps &&
                reconnectionStep != VpnReconnectionSteps.Disconnect)
            {
                _logger.Info("There is no last connection data, so reconnection will fast forward to quick connect.");
                return(VpnReconnectionSteps.QuickConnect);
            }

            return(reconnectionStep);
        }
Exemplo n.º 5
0
        private async Task SmartReconnectAsync(Server lastServer, Profile lastProfile, VpnReconnectionSettings settings)
        {
            _isToShowReconnectionPopup = settings.IsToShowReconnectionPopup;
            VpnReconnectionSteps reconnectionStep = _reconnectionStep;

            SetTargetServerAndProfile(lastServer, lastProfile, reconnectionStep);
            reconnectionStep = IncrementReconnectionStep(reconnectionStep);
            await ExecuteReconnectionAsync(reconnectionStep, isToTryLastServer : !settings.IsToExcludeLastServer);

            if (reconnectionStep == VpnReconnectionSteps.Disconnect)
            {
                ResetReconnectionStep();
            }
            else
            {
                _reconnectionStep = reconnectionStep;
            }
        }
Exemplo n.º 6
0
        private async Task ExecuteReconnectionAsync(VpnReconnectionSteps reconnectionStep, bool isToTryLastServer)
        {
            switch (reconnectionStep)
            {
            case VpnReconnectionSteps.SimilarOnSameProtocol:
                await ConnectToSimilarServerAsync(isToTryLastServer, _appSettings.GetProtocol());

                break;

            case VpnReconnectionSteps.SimilarOnSmartProtocol:
                await ConnectToSimilarServerAsync(isToTryLastServer, VpnProtocol.Smart);

                break;

            case VpnReconnectionSteps.QuickConnect:
                await ConnectToSimilarServerOrQuickConnectAsync(isToTryLastServer, _appSettings.GetProtocol());

                break;
            }
        }
Exemplo n.º 7
0
 public void ResetReconnectionStep()
 {
     _reconnectionStep = VpnReconnectionSteps.UserChoice;
     _targetServer     = null;
     _targetProfile    = null;
 }
Exemplo n.º 8
0
 private void SetTargetServerAndProfile(Server lastServer, Profile lastProfile, VpnReconnectionSteps reconnectionStep)
 {
     if (reconnectionStep == VpnReconnectionSteps.UserChoice)
     {
         _targetServer  = lastServer;
         _targetProfile = lastProfile;
     }
     else if (_targetServer != null && !_targetServer.IsEmpty())
     {
         Server updatedTargetServer = _serverManager.GetServers(new ServerById(_targetServer.Id)).FirstOrDefault();
         if (updatedTargetServer != null && !updatedTargetServer.IsEmpty())
         {
             _targetServer = updatedTargetServer;
         }
     }
 }