mirror of
https://github.com/volodymyrsmirnov/MalwareMultiScan.git
synced 2025-08-25 14:01:13 +00:00
finalize refactoring & ready for the PR
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
using System.Net;
|
||||
using EasyNetQ;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using MongoDB.Driver;
|
||||
|
||||
namespace MalwareMultiScan.Api.Extensions
|
||||
{
|
||||
internal static class ServiceCollectionExtensions
|
||||
{
|
||||
public static void AddMongoDb(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
services.AddSingleton(
|
||||
serviceProvider =>
|
||||
{
|
||||
var db = new MongoClient(configuration.GetConnectionString("Mongo"));
|
||||
|
||||
return db.GetDatabase(
|
||||
configuration.GetValue<string>("DatabaseName"));
|
||||
});
|
||||
}
|
||||
|
||||
public static void AddRabbitMq(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
services.AddSingleton(x =>
|
||||
RabbitHutch.CreateBus(configuration.GetConnectionString("RabbitMQ")));
|
||||
}
|
||||
|
||||
public static void AddDockerForwardedHeadersOptions(this IServiceCollection services)
|
||||
{
|
||||
services.Configure<ForwardedHeadersOptions>(options =>
|
||||
{
|
||||
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
|
||||
options.KnownNetworks.Add(new IPNetwork(IPAddress.Parse("::ffff:10.0.0.0"), 104));
|
||||
options.KnownNetworks.Add(new IPNetwork(IPAddress.Parse("::ffff:192.168.0.0"), 112));
|
||||
options.KnownNetworks.Add(new IPNetwork(IPAddress.Parse("::ffff:172.16.0.0"), 108));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user