112 lines
4.9 KiB
C#
112 lines
4.9 KiB
C#
using MeWeb.Core.Checks;
|
|||
|
|
using MeWeb.Core.History;
|
||
|
|
using MeWeb.Core.Knowledge;
|
||
|
|
using MeWeb.Core.Mail;
|
||
|
|
using MeWeb.Core.Net;
|
||
|
|
using MeWeb.Core.Router;
|
||
|
|
using MeWeb.Shared;
|
||
|
|
|
||
|
|
namespace MeWeb.Screenshots;
|
||
|
|
|
||
|
|
public class StorePhone : SystemPlatform
|
||
|
|
{
|
||
|
|
public override DeviceKind Device => DeviceKind.Phone;
|
||
|
|
|
||
|
|
public override string Name => "android";
|
||
|
|
}
|
||
|
|
|
||
|
|
public static class StoreRun
|
||
|
|
{
|
||
|
|
const string PhoneAddress = "192.168.1.23";
|
||
|
|
const string PhoneAddressV6 = "2001:db8:4d2:1a00:5c3e:9bff:fe12:3456";
|
||
|
|
const string RouterInside = "192.168.1.1";
|
||
|
|
const string RouterOutside = "100.64.12.34";
|
||
|
|
const string SharedExit = "203.0.113.45";
|
||
|
|
const uint ExampleAsn = 64500;
|
||
|
|
const string ExampleProvider = "Example Net";
|
||
|
|
|
||
|
|
public static RunReport Finished(KnowledgeBase knowledge)
|
||
|
|
{
|
||
|
|
var run = new RunReport
|
||
|
|
{
|
||
|
|
StartedAt = new DateTimeOffset(2026, 11, 2, 18, 30, 0, TimeSpan.Zero),
|
||
|
|
Device = DeviceKind.Phone,
|
||
|
|
Online = new OnlineReport { State = OnlineState.Online },
|
||
|
|
Local = new LocalSnapshot
|
||
|
|
{
|
||
|
|
Interfaces = [new LocalInterface { Name = "wlan0", Kind = LinkKind.Wifi, SpeedMbps = 866, Addresses = [PhoneAddress, PhoneAddressV6], Gateways = [RouterInside, "fe80::1"] }],
|
||
|
|
Dns = [RouterInside],
|
||
|
|
},
|
||
|
|
PublicV4 = SharedExit,
|
||
|
|
PublicV6 = PhoneAddressV6,
|
||
|
|
NetworkV4 = new AsnEntry { Number = ExampleAsn, Name = ExampleProvider },
|
||
|
|
NetworkV6 = new AsnEntry { Number = ExampleAsn, Name = ExampleProvider },
|
||
|
|
BlockV4 = new RegistryBlock { Name = "EXAMPLENET-HOME", Status = BlockStatus.Assigned },
|
||
|
|
BlockV6 = new RegistryBlock { Name = "EXAMPLENET-HOME", Status = BlockStatus.Assigned },
|
||
|
|
Router = new RouterReport { Gateway = RouterInside, Upnp = Answer.Answered, UpnpVersion = 2, WanAddress = RouterOutside },
|
||
|
|
Hops =
|
||
|
|
[
|
||
|
|
new Hop { Distance = 1, Address = RouterInside, Kind = AddressKind.Private },
|
||
|
|
new Hop { Distance = 2, Address = "100.64.0.1", Kind = AddressKind.Shared },
|
||
|
|
new Hop { Distance = 3, Address = "198.51.100.17", Kind = AddressKind.Public },
|
||
|
|
new Hop { Distance = 4, Address = "198.51.100.90", Kind = AddressKind.Public },
|
||
|
|
new Hop { Distance = 5, Address = "192.0.2.80", Kind = AddressKind.Public, IsDestination = true },
|
||
|
|
],
|
||
|
|
Stun = new StunReport
|
||
|
|
{
|
||
|
|
LocalPort = 49731,
|
||
|
|
FirstServer = $"{Endpoints.SecondStunHost}:{Endpoints.SecondStunPort}",
|
||
|
|
FirstMapped = $"{SharedExit}:40071",
|
||
|
|
SecondServer = $"{Endpoints.StunHost}:{Endpoints.StunPort}",
|
||
|
|
SecondMapped = $"{SharedExit}:40071",
|
||
|
|
Behaviour = NatBehaviour.Easy,
|
||
|
|
Ports = new PortReport { Pattern = PortPattern.Block, Low = 40071, High = 40086, BlockLow = 38912, BlockSize = 2048, Hairpin = false, LifetimeDone = true, KeptAtLeast = 120 },
|
||
|
|
},
|
||
|
|
Mail = new MailReport
|
||
|
|
{
|
||
|
|
Port25 = PortState.Blocked,
|
||
|
|
ReverseName = "203-0-113-45.home.example.net",
|
||
|
|
ReverseLooksDynamic = true,
|
||
|
|
ReverseConfirmed = true,
|
||
|
|
Listings =
|
||
|
|
[
|
||
|
|
new Listing { List = "Spamhaus ZEN", State = ListingState.Listed, Residential = true, Code = "127.0.0.10" },
|
||
|
|
new Listing { List = "SpamCop", State = ListingState.Clean },
|
||
|
|
new Listing { List = "Barracuda", State = ListingState.Clean },
|
||
|
|
],
|
||
|
|
},
|
||
|
|
Dns = new DnsReport { Resolvers = [RouterInside], Validates = true, Hijacks = false, Ipv6Names = true },
|
||
|
|
DeviceReport = new DeviceReport { Kind = DeviceKind.Phone, System = "Android 15 (API 35, Arm64)", Cores = 8, MemoryMb = 7680, FreeDiskGb = 64, OnBattery = true },
|
||
|
|
Speed = new SpeedReport { DownMbps = 312.4, UpMbps = 48.7, DownBytes = 12 * 1024 * 1024, UpBytes = 4 * 1024 * 1024, RoundTripMs = 21 },
|
||
|
|
History = new HistorySummary { Checks = 3, Since = new DateTimeOffset(2026, 10, 19, 9, 0, 0, TimeSpan.Zero), AddressesSeen = 1, Changes = 0 },
|
||
|
|
};
|
||
|
|
var (nat, kind) = Verdicts.Nat(run.Local, run.Router, run.PublicV4, run.PublicV6, run.Hops);
|
||
|
|
run.Nat = kind;
|
||
|
|
run.Findings =
|
||
|
|
[
|
||
|
|
Verdicts.Online(run.Online, run.Local),
|
||
|
|
Verdicts.Connection(run.Local, null, knowledge),
|
||
|
|
Verdicts.Addresses(run.PublicV4, run.PublicV6, run.Local, run.Router),
|
||
|
|
Verdicts.Provider(knowledge, run.NetworkV4, run.NetworkV6, run.BlockV4, run.BlockV6, true, false, run),
|
||
|
|
Verdicts.Router(run.Router, run.Local),
|
||
|
|
nat,
|
||
|
|
Verdicts.Behaviour(run.Stun, run.Nat, false),
|
||
|
|
Verdicts.Mail(run.Mail, true),
|
||
|
|
Verdicts.Dns(run.Dns),
|
||
|
|
Verdicts.Speed(run.Speed),
|
||
|
|
Verdicts.Device(run.DeviceReport),
|
||
|
|
Verdicts.History(run.History),
|
||
|
|
];
|
||
|
|
run.Uses = Uses.Decide(run);
|
||
|
|
return run;
|
||
|
|
}
|
||
|
|
|
||
|
|
public static RunReport Early(RunReport finished) => new()
|
||
|
|
{
|
||
|
|
StartedAt = finished.StartedAt,
|
||
|
|
Device = finished.Device,
|
||
|
|
Local = finished.Local,
|
||
|
|
DeviceReport = finished.DeviceReport,
|
||
|
|
Findings = [.. finished.Findings.Where(f => f.Id is CheckId.Connection or CheckId.Device)],
|
||
|
|
};
|
||
|
|
}
|