Phases two and three ship together, because their code grew in the same files. With consent the app asks the router to open 80, 443 and a high port for ten minutes (UPnP, NAT-PMP or PCP), and the server, holding a single-use ticket bound to the caller's own address, connects back and must get an HMAC only the app can give; the mappings are removed after the run and remembered until then, so a crash cannot leave one open. Hairpin is tried from inside. Two STUN servers, the outside one first, tell easy from hard NAT. Mail gets port 25 to Gmail and Outlook, the reverse name and five blocklists through the user's own resolver, network-wide UCEPROTECT listings counted as a caution. DNS, speed against the server (four at a time, twelve an hour per address) and the device follow, and six uses (website, home from outside, files, game server, fediverse, mail) close the run as possible, possible with a named workaround, or can't tell. Findings can be shared after reading the exact JSON: a file per submission under the unit's state directory, ten a day per address, deletable by the token the app keeps, swept after twelve months; /privacy says all of it in English and Italian. QR codes lead to the downloads. Every language carries every string. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012CzABvBkbcFqoHdmi8b9WB
71 lines
2.4 KiB
C#
71 lines
2.4 KiB
C#
using Avalonia;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Headless;
|
|
using Avalonia.Media.Imaging;
|
|
using Avalonia.Threading;
|
|
|
|
using MeWeb.App;
|
|
using MeWeb.App.Services;
|
|
using MeWeb.App.ViewModels;
|
|
using MeWeb.App.Views;
|
|
using MeWeb.Core.Checks;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
var output = args.Length > 0 ? args[0] : Path.Combine("dist", "screenshots");
|
|
var codes = args.Length > 1 ? args[1].Split(',', StringSplitOptions.RemoveEmptyEntries) : Languages.All.Select(l => l.Code).ToArray();
|
|
Directory.CreateDirectory(output);
|
|
|
|
var session = HeadlessUnitTestSession.StartNew(typeof(ScreenshotEntry));
|
|
await session.Dispatch(async () =>
|
|
{
|
|
var run = await App.Services.GetRequiredService<CheckRunner>().Run((_, _) => { }, CancellationToken.None);
|
|
Console.WriteLine($"run: {string.Join(", ", run.Findings.Select(f => $"{f.Id}={f.Outcome}"))}");
|
|
foreach (var (width, height, label) in new[] { (1100, 1500, "desktop"), (400, 2600, "phone") })
|
|
{
|
|
foreach (var code in codes)
|
|
{
|
|
Localizer.Instance.SetLanguage(Languages.Find(code) ?? Languages.Fallback);
|
|
Shoot(width, height, $"main-{label}-{code}", model => model.Replay(run));
|
|
if (label != "desktop") continue;
|
|
Shoot(width, 900, $"contacts-{code}", model => model.ShowContacts = true);
|
|
Shoot(width, 900, $"share-{code}", model =>
|
|
{
|
|
model.Replay(run);
|
|
model.OpenShareCommand.Execute(null);
|
|
});
|
|
}
|
|
}
|
|
return 0;
|
|
}, CancellationToken.None);
|
|
Environment.Exit(0);
|
|
|
|
void Shoot(int width, int height, string name, Action<MainViewModel> prepare)
|
|
{
|
|
var model = App.Services.GetRequiredService<MainViewModel>();
|
|
var view = new MainView { DataContext = model };
|
|
var window = new Window { Width = width, Height = height, Content = view };
|
|
window.Show();
|
|
model.AvailableWidth = width;
|
|
prepare(model);
|
|
for (var i = 0; i < 6; i++) Dispatcher.UIThread.RunJobs();
|
|
var frame = window.CaptureRenderedFrame();
|
|
var path = Path.Combine(output, $"{name}.png");
|
|
if (frame is not null)
|
|
{
|
|
using var file = File.Create(path);
|
|
frame.Save(file, new PngBitmapEncoderOptions());
|
|
}
|
|
Console.WriteLine($"{path} {(frame is null ? "no frame" : "ok")}");
|
|
window.Close();
|
|
}
|
|
|
|
public static class ScreenshotEntry
|
|
{
|
|
public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure<MeWeb.App.App>()
|
|
.UseSkia()
|
|
.UseHarfBuzz()
|
|
.WithInterFont()
|
|
.UseHeadless(new AvaloniaHeadlessPlatformOptions { UseHeadlessDrawing = false });
|
|
}
|