NetworkScanFacts.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. using RackPeek.Domain.Resources.Services.Networking;
  2. namespace RackPeek.Domain.Discovery;
  3. /// <summary>
  4. /// One responding host, as the sweep saw it. <see cref="OpenPorts" /> records only
  5. /// what liveness probing happened to touch — port probing stops at the first answer,
  6. /// so this is evidence the host is alive, never a port inventory.
  7. /// </summary>
  8. public sealed record NetworkHostFact(
  9. string Ip,
  10. string? Mac,
  11. string? Hostname,
  12. bool AnsweredPing,
  13. IReadOnlyList<int> OpenPorts);
  14. /// <summary>How to sweep. The defaults suit a quiet home /24.</summary>
  15. public sealed record NetworkScanOptions {
  16. public required Cidr Cidr { get; init; }
  17. /// <summary>TCP ports probed to catch hosts that do not answer ping.</summary>
  18. public IReadOnlyList<int> Ports { get; init; } = WellKnownPorts.Defaults;
  19. public TimeSpan PingTimeout { get; init; } = TimeSpan.FromMilliseconds(300);
  20. public TimeSpan PortTimeout { get; init; } = TimeSpan.FromMilliseconds(500);
  21. /// <summary>Cap on each alive host's reverse-DNS lookup — resolvers that silently
  22. /// drop PTR queries would otherwise stall the whole result on the OS default.</summary>
  23. public TimeSpan DnsTimeout { get; init; } = TimeSpan.FromSeconds(2);
  24. /// <summary>How many hosts are probed at once.</summary>
  25. public int Concurrency { get; init; } = 128;
  26. }