Cleanup Namespaces
This commit is contained in:
parent
9b49f880a2
commit
6c901ea46b
21 changed files with 230 additions and 31 deletions
51
Program.cs
51
Program.cs
|
|
@ -1,34 +1,73 @@
|
|||
using DotNetDDI.Data;
|
||||
using DotNetDDI.Integrations.Kea;
|
||||
using DotNetDDI.Integrations.PowerDns;
|
||||
using DotNetDDI.Options;
|
||||
using DotNetDDI.Services.Dhcp;
|
||||
using DotNetDDI.Services.Dns;
|
||||
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using netddi.Data;
|
||||
using Microsoft.AspNetCore.Connections;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Services.AddSystemd();
|
||||
|
||||
// Add services to the container.
|
||||
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");
|
||||
builder.Services.AddDbContext<ApplicationDbContext>(options =>
|
||||
options.UseSqlite(connectionString));
|
||||
options.UseSqlite(connectionString));
|
||||
builder.Services.AddDatabaseDeveloperPageExceptionFilter();
|
||||
|
||||
builder.Services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
|
||||
.AddEntityFrameworkStores<ApplicationDbContext>();
|
||||
.AddEntityFrameworkStores<ApplicationDbContext>();
|
||||
builder.Services.AddRazorPages();
|
||||
|
||||
builder.Services.Configure<DhcpOptions>(builder.Configuration.GetRequiredSection("Dhcp"));
|
||||
builder.Services.Configure<PowerDnsOptions>(builder.Configuration.GetRequiredSection("PowerDns"));
|
||||
|
||||
builder.Services.AddHostedService<DhcpWatcher>();
|
||||
builder.Services.AddHostedService<DhcpQueueWorker>();
|
||||
|
||||
builder.Services.AddSingleton<DhcpLeaseQueue>();
|
||||
builder.Services.AddSingleton<DnsRepository>();
|
||||
|
||||
builder.Services.AddDhcpWatcherFactory();
|
||||
builder.Services.AddKeaFactory();
|
||||
|
||||
builder.WebHost.ConfigureKestrel((context, options) =>
|
||||
{
|
||||
options.UseSystemd(_ => throw new InvalidOperationException("SystemD Socket Activation is not supported by Kestrel."));
|
||||
|
||||
var pdnsOptions = context.Configuration.GetRequiredSection("PowerDns:Listener").Get<PowerDnsListenerOptions>();
|
||||
ArgumentNullException.ThrowIfNull(pdnsOptions);
|
||||
var path = PathEx.ExpandPath(pdnsOptions.Socket);
|
||||
FileInfo file = new(path);
|
||||
file.Directory!.Create();
|
||||
file.Delete();
|
||||
options.ListenUnixSocket(path, options =>
|
||||
{
|
||||
options.UseConnectionHandler<PowerDnsHandler>();
|
||||
});
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseMigrationsEndPoint();
|
||||
app.UseMigrationsEndPoint();
|
||||
}
|
||||
else
|
||||
{
|
||||
app.UseExceptionHandler("/Error");
|
||||
app.UseExceptionHandler("/Error");
|
||||
}
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthorization();
|
||||
if (app.Configuration.GetValue("Admin:Authentication", true))
|
||||
{
|
||||
app.UseAuthorization();
|
||||
}
|
||||
|
||||
app.UseStaticFiles();
|
||||
app.MapRazorPages();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue