mirror of
https://github.com/bitwarden/server
synced 2026-01-07 11:03:37 +00:00
Changed all C# control flow block statements to include space between keyword and open paren
This commit is contained in:
@@ -36,7 +36,7 @@ namespace Bit.Admin.HostedServices
|
||||
var unblockIpQueue = await _client.GetQueueUrlAsync("unblock-ip", cancellationToken);
|
||||
var unblockIpQueueUrl = unblockIpQueue.QueueUrl;
|
||||
|
||||
while(!cancellationToken.IsCancellationRequested)
|
||||
while (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
var blockMessageResponse = await _client.ReceiveMessageAsync(new ReceiveMessageRequest
|
||||
{
|
||||
@@ -44,15 +44,15 @@ namespace Bit.Admin.HostedServices
|
||||
MaxNumberOfMessages = 10,
|
||||
WaitTimeSeconds = 15
|
||||
}, cancellationToken);
|
||||
if(blockMessageResponse.Messages.Any())
|
||||
if (blockMessageResponse.Messages.Any())
|
||||
{
|
||||
foreach(var message in blockMessageResponse.Messages)
|
||||
foreach (var message in blockMessageResponse.Messages)
|
||||
{
|
||||
try
|
||||
{
|
||||
await BlockIpAsync(message.Body, cancellationToken);
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Failed to block IP.");
|
||||
}
|
||||
@@ -66,15 +66,15 @@ namespace Bit.Admin.HostedServices
|
||||
MaxNumberOfMessages = 10,
|
||||
WaitTimeSeconds = 15
|
||||
}, cancellationToken);
|
||||
if(unblockMessageResponse.Messages.Any())
|
||||
if (unblockMessageResponse.Messages.Any())
|
||||
{
|
||||
foreach(var message in unblockMessageResponse.Messages)
|
||||
foreach (var message in unblockMessageResponse.Messages)
|
||||
{
|
||||
try
|
||||
{
|
||||
await UnblockIpAsync(message.Body, cancellationToken);
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Failed to unblock IP.");
|
||||
}
|
||||
|
||||
@@ -26,18 +26,18 @@ namespace Bit.Admin.HostedServices
|
||||
_blockIpQueueClient = new QueueClient(_globalSettings.Storage.ConnectionString, "blockip");
|
||||
_unblockIpQueueClient = new QueueClient(_globalSettings.Storage.ConnectionString, "unblockip");
|
||||
|
||||
while(!cancellationToken.IsCancellationRequested)
|
||||
while (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
var blockMessages = await _blockIpQueueClient.ReceiveMessagesAsync(maxMessages: 32);
|
||||
if(blockMessages.Value?.Any() ?? false)
|
||||
if (blockMessages.Value?.Any() ?? false)
|
||||
{
|
||||
foreach(var message in blockMessages.Value)
|
||||
foreach (var message in blockMessages.Value)
|
||||
{
|
||||
try
|
||||
{
|
||||
await BlockIpAsync(message.MessageText, cancellationToken);
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Failed to block IP.");
|
||||
}
|
||||
@@ -46,15 +46,15 @@ namespace Bit.Admin.HostedServices
|
||||
}
|
||||
|
||||
var unblockMessages = await _unblockIpQueueClient.ReceiveMessagesAsync(maxMessages: 32);
|
||||
if(unblockMessages.Value?.Any() ?? false)
|
||||
if (unblockMessages.Value?.Any() ?? false)
|
||||
{
|
||||
foreach(var message in unblockMessages.Value)
|
||||
foreach (var message in unblockMessages.Value)
|
||||
{
|
||||
try
|
||||
{
|
||||
await UnblockIpAsync(message.MessageText, cancellationToken);
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Failed to unblock IP.");
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Bit.Admin.HostedServices
|
||||
|
||||
public async Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
if(_executingTask == null)
|
||||
if (_executingTask == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -78,14 +78,14 @@ namespace Bit.Admin.HostedServices
|
||||
request.Content = new StringContent(bodyContent, Encoding.UTF8, "application/json");
|
||||
|
||||
var response = await _httpClient.SendAsync(request, cancellationToken);
|
||||
if(!response.IsSuccessStatusCode)
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var responseString = await response.Content.ReadAsStringAsync();
|
||||
var accessRuleResponse = JsonConvert.DeserializeObject<AccessRuleResponse>(responseString);
|
||||
if(!accessRuleResponse.Success)
|
||||
if (!accessRuleResponse.Success)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -95,12 +95,12 @@ namespace Bit.Admin.HostedServices
|
||||
|
||||
protected async Task UnblockIpAsync(string message, CancellationToken cancellationToken)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(message))
|
||||
if (string.IsNullOrWhiteSpace(message))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(message.Contains(".") || message.Contains(":"))
|
||||
if (message.Contains(".") || message.Contains(":"))
|
||||
{
|
||||
// IP address messages
|
||||
var request = new HttpRequestMessage();
|
||||
@@ -113,19 +113,19 @@ namespace Bit.Admin.HostedServices
|
||||
$"configuration_target=ip&configuration_value={message}");
|
||||
|
||||
var response = await _httpClient.SendAsync(request, cancellationToken);
|
||||
if(!response.IsSuccessStatusCode)
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var responseString = await response.Content.ReadAsStringAsync();
|
||||
var listResponse = JsonConvert.DeserializeObject<ListResponse>(responseString);
|
||||
if(!listResponse.Success)
|
||||
if (!listResponse.Success)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach(var rule in listResponse.Result)
|
||||
foreach (var rule in listResponse.Result)
|
||||
{
|
||||
await DeleteAccessRuleAsync(rule.Id, cancellationToken);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Bit.Admin.HostedServices
|
||||
await Task.Delay(20000);
|
||||
|
||||
var maxMigrationAttempts = 10;
|
||||
for(var i = 1; i <= maxMigrationAttempts; i++)
|
||||
for (var i = 1; i <= maxMigrationAttempts; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -41,9 +41,9 @@ namespace Bit.Admin.HostedServices
|
||||
// TODO: Maybe flip a flag somewhere to indicate migration is complete??
|
||||
break;
|
||||
}
|
||||
catch(SqlException e)
|
||||
catch (SqlException e)
|
||||
{
|
||||
if(i >= maxMigrationAttempts)
|
||||
if (i >= maxMigrationAttempts)
|
||||
{
|
||||
_logger.LogError(e, "Database failed to migrate.");
|
||||
throw e;
|
||||
|
||||
Reference in New Issue
Block a user