mirror of
https://github.com/alexhopeoconnor/dnsmasq-webui.git
synced 2026-10-19 00:01:42 +10:00
- EffectiveConfigFieldRef as value type; PendingDnsmasqChange/PendingOptionChange/PendingManagedHostsChange - Multi-file save plan (DnsmasqSaveWritePlan, DnsmasqManagedBackup) and backup/restore in save flow - Hosts integrated into effective-config save; Hosts.razor uses shared save modal - IEffectiveConfigDescriptorProvider + IEffectiveConfigFieldBuilder (DI); descriptors from EffectiveConfigSections - IEffectiveConfigPageEditor, shared descriptor resolution; addn-hosts/dhcp-host descriptor fix - DnsmasqConfText, IEffectiveConfigDirectiveSerializer; DnsmasqConfigService uses serializer for writes - IStructuredOptionValueHandler/Registry, DhcpHostOptionValueHandler; Dhcp.razor index-based DeleteRow fix - SaveService: roll back partial writes on failure; SaveModal: WriteFailed shows backups and Restore button
37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using DnsmasqWebUI.Infrastructure.Services.Dnsmasq.Config.Abstractions;
|
|
using DnsmasqWebUI.Models.Dhcp;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace DnsmasqWebUI.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
public class DhcpController : ControllerBase
|
|
{
|
|
private readonly IDnsmasqConfigService _configService;
|
|
private readonly ILogger<DhcpController> _logger;
|
|
|
|
public DhcpController(IDnsmasqConfigService configService, ILogger<DhcpController> logger)
|
|
{
|
|
_configService = configService;
|
|
_logger = logger;
|
|
}
|
|
|
|
[HttpGet("hosts")]
|
|
public async Task<ActionResult<IReadOnlyList<DhcpHostEntry>>> GetHosts(CancellationToken ct)
|
|
{
|
|
try
|
|
{
|
|
_logger.LogDebug("Get DHCP hosts");
|
|
var entries = await _configService.ReadDhcpHostsAsync(ct);
|
|
return Ok(entries);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Get DHCP hosts failed");
|
|
return StatusCode(500, new { error = ex.Message });
|
|
}
|
|
}
|
|
}
|