INetworkProbe.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using RackPeek.Domain.Resources.Services.Networking;
  2. namespace RackPeek.Domain.Discovery;
  3. /// <summary>
  4. /// Network IO for the sweep. The IO half of network discovery, mirroring
  5. /// <see cref="IDockerClient" /> / <see cref="IProxmoxClient" />: everything here is
  6. /// untestable-by-design plumbing, and every decision made about what comes back
  7. /// lives in <see cref="NetworkScanner" /> and the pure parsers.
  8. /// </summary>
  9. public interface INetworkProbe {
  10. /// <summary>
  11. /// True when this platform can sweep at all. The browser (WASM viewer) cannot —
  12. /// its sockets are sandboxed — and without this guard a scan there would report
  13. /// an empty network instead of the truth. Mirrors <see cref="ISystemProbe.IsSupported" />.
  14. /// </summary>
  15. bool IsSupported { get; }
  16. /// <summary>True when the host answers an ICMP echo within the timeout.</summary>
  17. Task<bool> PingAsync(string ip, TimeSpan timeout, CancellationToken cancellationToken = default);
  18. /// <summary>True when a TCP connect to the port completes within the timeout.</summary>
  19. Task<bool> TryConnectAsync(string ip, int port, TimeSpan timeout, CancellationToken cancellationToken = default);
  20. /// <summary>
  21. /// The host's ARP table, raw, in whichever format this platform produces — the
  22. /// sweep's pings populate it, and <see cref="ArpTableParser" /> reads either
  23. /// format. Null when it cannot be read; MACs are an enrichment, not a requirement.
  24. /// </summary>
  25. Task<string?> ReadArpAsync(CancellationToken cancellationToken = default);
  26. /// <summary>The host's reverse-DNS name, or null when it has none worth keeping.</summary>
  27. Task<string?> ReverseDnsAsync(string ip, TimeSpan timeout, CancellationToken cancellationToken = default);
  28. /// <summary>
  29. /// The subnet of the first up, non-loopback IPv4 interface with a gateway — what
  30. /// `--cidr` defaults to. Null when the machine has no such interface.
  31. /// </summary>
  32. Cidr? LocalSubnet();
  33. }