1
0
mirror of https://github.com/bitwarden/server synced 2025-12-18 09:13:19 +00:00

add x-platform support with netcore 2.0

This commit is contained in:
Kyle Spearrin
2017-07-31 16:58:27 -04:00
parent d6d9ceab87
commit 3880edfb79
12 changed files with 80 additions and 25 deletions

View File

@@ -9,6 +9,7 @@ namespace Bit.Core.Services
{
private readonly CloudQueue _blockIpQueue;
private readonly CloudQueue _unblockIpQueue;
private bool _didInit = false;
public AzureQueueBlockIpService(
GlobalSettings globalSettings)
@@ -17,14 +18,12 @@ namespace Bit.Core.Services
var queueClient = storageAccount.CreateCloudQueueClient();
_blockIpQueue = queueClient.GetQueueReference("blockip");
_blockIpQueue.CreateIfNotExists();
_unblockIpQueue = queueClient.GetQueueReference("unblockip");
_unblockIpQueue.CreateIfNotExists();
}
public async Task BlockIpAsync(string ipAddress, bool permanentBlock)
{
await InitAsync();
var message = new CloudQueueMessage(ipAddress);
await _blockIpQueue.AddMessageAsync(message);
@@ -33,5 +32,17 @@ namespace Bit.Core.Services
await _unblockIpQueue.AddMessageAsync(message, null, new TimeSpan(12, 0, 0), null, null);
}
}
private async Task InitAsync()
{
if(_didInit)
{
return;
}
await _blockIpQueue.CreateIfNotExistsAsync();
await _unblockIpQueue.CreateIfNotExistsAsync();
_didInit = true;
}
}
}