feat: implement authenticated NAT mediator (#11)
quality-gate / quality (push) Successful in 59s
quality-gate / quality (push) Successful in 59s
Closes #11
This commit is contained in:
@@ -133,12 +133,19 @@ builder.Services
|
||||
.BindConfiguration(UdpMediatorOptions.SectionName)
|
||||
.ValidateDataAnnotations()
|
||||
.Validate(
|
||||
options => IPAddress.TryParse(options.ListenAddress, out _),
|
||||
$"{UdpMediatorOptions.SectionName}:ListenAddress must be an IP address.")
|
||||
options => IPAddress.TryParse(options.ListenAddress, out IPAddress? address)
|
||||
&& address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork,
|
||||
$"{UdpMediatorOptions.SectionName}:ListenAddress must be an IPv4 address.")
|
||||
.Validate(
|
||||
options => string.IsNullOrWhiteSpace(options.Ipv6ListenAddress)
|
||||
|| (IPAddress.TryParse(options.Ipv6ListenAddress, out IPAddress? address)
|
||||
&& address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6),
|
||||
$"{UdpMediatorOptions.SectionName}:Ipv6ListenAddress must be an IPv6 address when configured.")
|
||||
.ValidateOnStart();
|
||||
builder.Services.AddSingleton<UdpMediatorService>();
|
||||
if (!isOpenApiGeneration)
|
||||
{
|
||||
builder.Services.AddSingleton<NatMediationProcessor>();
|
||||
builder.Services.AddHostedService(static services =>
|
||||
services.GetRequiredService<UdpMediatorService>());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user