w4c-workflows-api/Services/Security/IHostAddressResolver.cs

20 lines
661 B
C#
Raw Permalink Normal View History

2026-09-11 22:02:46 +00:00
using System.Net;
namespace w4c_workflows.Services.Security;
/// <summary>
/// Resolves a host name to the addresses a request could actually reach.
/// Abstracted so the egress guard can be unit-tested without touching DNS.
/// </summary>
public interface IHostAddressResolver
{
Task<IReadOnlyList<IPAddress>> ResolveAsync(string host, CancellationToken ct);
}
/// <summary>Production resolver backed by <see cref="Dns"/>.</summary>
public sealed class DnsHostAddressResolver : IHostAddressResolver
{
public async Task<IReadOnlyList<IPAddress>> ResolveAsync(string host, CancellationToken ct)
=> await Dns.GetHostAddressesAsync(host, ct);
}