From f61eba0fdd105af70cff538be6922cbdc7ec2f7b Mon Sep 17 00:00:00 2001 From: AliveDevil Date: Sat, 13 Jan 2024 21:15:14 +0100 Subject: [PATCH] Review --- src/pdns-dhcp/Program.cs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/pdns-dhcp/Program.cs b/src/pdns-dhcp/Program.cs index 1d47dd3..c7b4a15 100644 --- a/src/pdns-dhcp/Program.cs +++ b/src/pdns-dhcp/Program.cs @@ -60,26 +60,23 @@ builder.Services.Configure(options => builder.WebHost.ConfigureKestrel((context, options) => { - if (context.Configuration.GetSection("PowerDns:Listener").Get() is { } pdnsOptions) + bool isSystemd = false; + options.UseSystemd(options => + { + isSystemd = true; + options.UseConnectionHandler(); + }); + + if (!isSystemd && context.Configuration.GetRequiredSection("PowerDns:Listener").Get() is { } pdnsOptions) { var path = PathEx.ExpandPath(pdnsOptions.Socket); FileInfo file = new(path); file.Directory!.Create(); - bool isSystemd = false; - options.UseSystemd(options => + file.Delete(); + options.ListenUnixSocket(path, options => { - isSystemd = true; options.UseConnectionHandler(); }); - - if (!isSystemd) - { - file.Delete(); - options.ListenUnixSocket(path, options => - { - options.UseConnectionHandler(); - }); - } } });