mirror of
https://github.com/volodymyrsmirnov/MalwareMultiScan.git
synced 2025-08-24 21:42:23 +00:00
42 lines
1.6 KiB
C#
42 lines
1.6 KiB
C#
|
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));
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
}
|