Add Opt-Out of unique hostname enforcing
This commit is contained in:
parent
a12471c9e5
commit
fe275467e8
3 changed files with 18 additions and 6 deletions
|
|
@ -2,6 +2,10 @@ using System.Net;
|
|||
using System.Net.NetworkInformation;
|
||||
using System.Net.Sockets;
|
||||
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
using pdns_dhcp.Options;
|
||||
|
||||
using Timeout = System.Threading.Timeout;
|
||||
|
||||
namespace pdns_dhcp.Dns;
|
||||
|
|
@ -10,10 +14,16 @@ public class DnsRepository
|
|||
{
|
||||
private static ReadOnlySpan<int> Lifetimes => [600, 3600];
|
||||
|
||||
private readonly PowerDnsOptions _options;
|
||||
private readonly ReaderWriterLockSlim _recordLock = new();
|
||||
private readonly List<DnsRecord> _records = [];
|
||||
private readonly SemaphoreSlim _syncLock = new(1, 1);
|
||||
|
||||
public DnsRepository(IOptions<PowerDnsOptions> options)
|
||||
{
|
||||
_options = options.Value;
|
||||
}
|
||||
|
||||
public List<DnsRecord> Find(Predicate<DnsRecord> query)
|
||||
{
|
||||
bool enteredLock = false;
|
||||
|
|
@ -124,11 +134,10 @@ public class DnsRepository
|
|||
{
|
||||
list.AddLast(i);
|
||||
}
|
||||
// Opt-In to disallow duplicate FQDN?
|
||||
//else if (StringComparer.InvariantCultureIgnoreCase.Equals(record.FQDN, query.FQDN))
|
||||
//{
|
||||
// list.AddLast(i);
|
||||
//}
|
||||
else if (_options.UniqueHostnames && StringComparer.OrdinalIgnoreCase.Equals(record.FQDN, query.FQDN))
|
||||
{
|
||||
list.AddLast(i);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ namespace pdns_dhcp.Options;
|
|||
|
||||
public class PowerDnsOptions
|
||||
{
|
||||
public PowerDnsListenerOptions Listener { get; set; } = default!;
|
||||
public PowerDnsListenerOptions Listener { get; init; } = default!;
|
||||
|
||||
public bool UniqueHostnames { get; init; } = true;
|
||||
}
|
||||
|
||||
public record class PowerDnsListenerOptions(string Socket);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
}
|
||||
},
|
||||
"PowerDns": {
|
||||
"UniqueHostnames": true,
|
||||
"Listener": {
|
||||
"Socket": "/run/pdns-dhcp/pdns.sock"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue