From 41b067cbb42dbe2dbe2b1644d7e647e915fd4ebd Mon Sep 17 00:00:00 2001 From: AliveDevil Date: Fri, 17 Nov 2023 17:23:39 +0100 Subject: [PATCH] Types --- src/pdns-dhcp/Kea/KeaDhcp4Lease.cs | 8 ++++---- src/pdns-dhcp/Kea/KeaDhcp6Lease.cs | 18 +++++++++--------- src/pdns-dhcp/Services/DhcpLeaseWatcher.cs | 14 ++++++-------- .../Services/IDhcpLeaseWatcherFactory.cs | 8 ++++++++ src/pdns-dhcp/Services/PowerDnsBackend.cs | 12 ++---------- 5 files changed, 29 insertions(+), 31 deletions(-) create mode 100644 src/pdns-dhcp/Services/IDhcpLeaseWatcherFactory.cs diff --git a/src/pdns-dhcp/Kea/KeaDhcp4Lease.cs b/src/pdns-dhcp/Kea/KeaDhcp4Lease.cs index fb9ac95..c5186f4 100644 --- a/src/pdns-dhcp/Kea/KeaDhcp4Lease.cs +++ b/src/pdns-dhcp/Kea/KeaDhcp4Lease.cs @@ -5,13 +5,13 @@ public record struct KeaDhcp4Lease( string Address, string HWAddr, string? ClientId, - UInt32 ValidLifetime, - UInt64 Expire, + uint ValidLifetime, + ulong Expire, string SubnetId, byte FqdnFwd, byte FqdnRev, string Hostname, - UInt32 State, + uint State, string UserContext, - UInt32 PoolId + uint PoolId ); diff --git a/src/pdns-dhcp/Kea/KeaDhcp6Lease.cs b/src/pdns-dhcp/Kea/KeaDhcp6Lease.cs index e35ddc5..c56b9fa 100644 --- a/src/pdns-dhcp/Kea/KeaDhcp6Lease.cs +++ b/src/pdns-dhcp/Kea/KeaDhcp6Lease.cs @@ -4,20 +4,20 @@ namespace pdns_dhcp.Kea; public record struct KeaDhcp6Lease( string Address, string DUId, - UInt32 ValidLifetime, - UInt64 Expire, + uint ValidLifetime, + ulong Expire, string SubnetId, - UInt32 PrefLifetime, + uint PrefLifetime, LeaseType LeaseType, - UInt32 IAId, - Byte PrefixLen, + uint IAId, + byte PrefixLen, byte FqdnFwd, byte FqdnRev, string Hostname, string HWAddr, - UInt32 State, + uint State, string UserContext, - UInt16? HWType, - UInt32? HWAddrSource, - UInt32 PoolId + ushort? HWType, + uint? HWAddrSource, + uint PoolId ); diff --git a/src/pdns-dhcp/Services/DhcpLeaseWatcher.cs b/src/pdns-dhcp/Services/DhcpLeaseWatcher.cs index a4a7bb0..90bfaf9 100644 --- a/src/pdns-dhcp/Services/DhcpLeaseWatcher.cs +++ b/src/pdns-dhcp/Services/DhcpLeaseWatcher.cs @@ -1,4 +1,3 @@ -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Options; @@ -6,18 +5,17 @@ using pdns_dhcp.Options; namespace pdns_dhcp.Services; -public class DhcpLeaseWatcher : IHostedService +public class DhcpLeaseWatcher : BackgroundService { public DhcpLeaseWatcher(IOptions options) { + var dhcpOptions = options.Value; + if (dhcpOptions.Kea is { } keaOptions) + { + } } - public Task StartAsync(CancellationToken cancellationToken) - { - throw new NotImplementedException(); - } - - public Task StopAsync(CancellationToken cancellationToken) + protected override Task ExecuteAsync(CancellationToken stoppingToken) { throw new NotImplementedException(); } diff --git a/src/pdns-dhcp/Services/IDhcpLeaseWatcherFactory.cs b/src/pdns-dhcp/Services/IDhcpLeaseWatcherFactory.cs new file mode 100644 index 0000000..f305944 --- /dev/null +++ b/src/pdns-dhcp/Services/IDhcpLeaseWatcherFactory.cs @@ -0,0 +1,8 @@ +using Stl.Interception; + +namespace pdns_dhcp.Services; + +public interface IDhcpLeaseWatcherFactory : IRequiresFullProxy +{ + +} diff --git a/src/pdns-dhcp/Services/PowerDnsBackend.cs b/src/pdns-dhcp/Services/PowerDnsBackend.cs index a4e0cb3..f92d349 100644 --- a/src/pdns-dhcp/Services/PowerDnsBackend.cs +++ b/src/pdns-dhcp/Services/PowerDnsBackend.cs @@ -1,6 +1,3 @@ -using System.Net.Sockets; - -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Options; @@ -9,7 +6,7 @@ using pdns_dhcp.PowerDns; namespace pdns_dhcp.Services; -public class PowerDnsBackend : IHostedService +public class PowerDnsBackend : BackgroundService { private readonly PowerDnsOptions _options; @@ -18,12 +15,7 @@ public class PowerDnsBackend : IHostedService _options = options.Value; } - public Task StartAsync(CancellationToken cancellationToken) - { - throw new NotImplementedException(); - } - - public Task StopAsync(CancellationToken cancellationToken) + protected override Task ExecuteAsync(CancellationToken stoppingToken) { throw new NotImplementedException(); }