-
Notifications
You must be signed in to change notification settings - Fork 1
/
Program.cs
34 lines (28 loc) · 1.13 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
global using Microsoft.AspNetCore.Connections;
global using Microsoft.AspNetCore.StaticFiles;
global using System.Runtime.InteropServices;
global using System.Text;
using Microsoft.AspNetCore.Server.Kestrel.Core;
var builder = WebApplication.CreateSlimBuilder(args);
builder.Services.AddTransient<GeminiRequestHandler>();
builder.WebHost.ConfigureKestrel(o =>
{
o.ListenAnyIP(1965, b =>
{
b.Protocols = HttpProtocols.None;
b.UseHttps(Path.Combine(AppContext.BaseDirectory, "certificate.pfx"), "", o =>
{
o.SslProtocols = System.Security.Authentication.SslProtocols.Tls12 | System.Security.Authentication.SslProtocols.Tls13;
o.AllowAnyClientCertificate();
});
b.UseConnectionHandler(() => b.ApplicationServices.GetRequiredService<GeminiRequestHandler>());
});
});
var app = builder.Build();
app.Run();
public static class Ext
{
public static IConnectionBuilder UseConnectionHandler<T>(this IConnectionBuilder connectionBuilder, Func<T> factory)
where T : ConnectionHandler => connectionBuilder.Run(connection
=> factory().OnConnectedAsync(connection));
}