70 lines
1.3 KiB
C#
70 lines
1.3 KiB
C#
namespace MeWeb.Core.Checks;
|
|||
|
|
|
||
|
|
public enum CheckId
|
||
|
|
{
|
||
|
|
Online,
|
||
|
|
Connection,
|
||
|
|
Addresses,
|
||
|
|
Provider,
|
||
|
|
Router,
|
||
|
|
Nat,
|
||
|
|
History,
|
||
|
|
}
|
||
|
|
|
||
|
|
public enum Outcome
|
||
|
|
{
|
||
|
|
Waiting,
|
||
|
|
Running,
|
||
|
|
Good,
|
||
|
|
Caution,
|
||
|
|
Bad,
|
||
|
|
Unknown,
|
||
|
|
Info,
|
||
|
|
}
|
||
|
|
|
||
|
|
public enum NatKind
|
||
|
|
{
|
||
|
|
Unknown,
|
||
|
|
Direct,
|
||
|
|
HomeRouter,
|
||
|
|
DoubleNat,
|
||
|
|
Shared,
|
||
|
|
Translated,
|
||
|
|
NoIpv4,
|
||
|
|
}
|
||
|
|
|
||
|
|
public class Fact
|
||
|
|
{
|
||
|
|
public string Label { get; set; }
|
||
|
|
public string Text { get; set; }
|
||
|
|
public string Key { get; set; }
|
||
|
|
public List<string> Args { get; set; } = [];
|
||
|
|
public decimal? Amount { get; set; }
|
||
|
|
public string Currency { get; set; }
|
||
|
|
public string Link { get; set; }
|
||
|
|
public string Basis { get; set; }
|
||
|
|
public string Date { get; set; }
|
||
|
|
}
|
||
|
|
|
||
|
|
public class Finding
|
||
|
|
{
|
||
|
|
public CheckId Id { get; set; }
|
||
|
|
public Outcome Outcome { get; set; }
|
||
|
|
public string Summary { get; set; }
|
||
|
|
public List<string> Args { get; set; } = [];
|
||
|
|
public List<Fact> Facts { get; set; } = [];
|
||
|
|
|
||
|
|
public static Finding Running(CheckId id) => new() { Id = id, Outcome = Outcome.Running };
|
||
|
|
|
||
|
|
public Finding With(string label, string text)
|
||
|
|
{
|
||
|
|
if (!string.IsNullOrEmpty(text)) Facts.Add(new Fact { Label = label, Text = text });
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
public Finding WithKey(string label, string key, params string[] args)
|
||
|
|
{
|
||
|
|
Facts.Add(new Fact { Label = label, Key = key, Args = [.. args] });
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
}
|