Review PowerDnsHandler
This commit is contained in:
parent
0f9f127494
commit
c36c22d5ca
2 changed files with 15 additions and 8 deletions
|
|
@ -2,6 +2,7 @@ using System.Buffers;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Connections;
|
using Microsoft.AspNetCore.Connections;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Toolkit.HighPerformance;
|
using Microsoft.Toolkit.HighPerformance;
|
||||||
using Microsoft.Toolkit.HighPerformance.Buffers;
|
using Microsoft.Toolkit.HighPerformance.Buffers;
|
||||||
|
|
||||||
|
|
@ -11,10 +12,12 @@ namespace pdns_dhcp.PowerDns;
|
||||||
|
|
||||||
public class PowerDnsHandler : ConnectionHandler
|
public class PowerDnsHandler : ConnectionHandler
|
||||||
{
|
{
|
||||||
|
private readonly ILogger<PowerDnsHandler> _logger;
|
||||||
private readonly DnsRepository _repository;
|
private readonly DnsRepository _repository;
|
||||||
|
|
||||||
public PowerDnsHandler(DnsRepository repository)
|
public PowerDnsHandler(DnsRepository repository, ILogger<PowerDnsHandler> logger)
|
||||||
{
|
{
|
||||||
|
_logger = logger;
|
||||||
_repository = repository;
|
_repository = repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,20 +103,25 @@ public class PowerDnsHandler : ConnectionHandler
|
||||||
{
|
{
|
||||||
return method switch
|
return method switch
|
||||||
{
|
{
|
||||||
InitializeMethod init => HandleInitializeMethod(init),
|
InitializeMethod { Parameters: { } init } => HandleInitialize(init),
|
||||||
LookupMethod lookup => HandleLookupMethod(lookup),
|
LookupMethod { Parameters: { } lookup } => HandleLookup(lookup),
|
||||||
|
|
||||||
_ => ValueTask.FromResult<Reply>(new BoolReply(false))
|
_ => ValueTask.FromResult<Reply>(new BoolReply(false))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private ValueTask<Reply> HandleInitializeMethod(InitializeMethod method)
|
private ValueTask<Reply> HandleInitialize(InitializeMethodParameters method)
|
||||||
{
|
{
|
||||||
return ValueTask.FromResult(BoolReply.True);
|
return ValueTask.FromResult(BoolReply.True);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ValueTask<Reply> HandleLookupMethod(LookupMethod method)
|
private ValueTask<Reply> HandleLookup(LookupMethodParameters method)
|
||||||
{
|
{
|
||||||
|
switch (method.Qtype.ToLowerInvariant())
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
_logger.LogWarning("Unhandled QType {QType}", method.Qtype);
|
||||||
return ValueTask.FromResult(BoolReply.False);
|
return ValueTask.FromResult(BoolReply.False);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
using System.Text.Json;
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace pdns_dhcp.PowerDns;
|
namespace pdns_dhcp.PowerDns;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue