Add trap logging, dashboard, EF migrations and Dockerfile
This commit is contained in:
1 parent
f9161f48e7
commit
b561924efa
26 files changed
+784
-62
No files matched your search
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="de">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@inherits LayoutComponentBase
|
||||
@inherits LayoutComponentBase
|
||||
|
||||
@Body
|
||||
<main class="page">
|
||||
@Body
|
||||
</main>
|
||||
@@ -1,20 +0,0 @@
|
||||
#blazor-error-ui {
|
||||
color-scheme: light only;
|
||||
background: lightyellow;
|
||||
bottom: 0;
|
||||
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
|
||||
box-sizing: border-box;
|
||||
display: none;
|
||||
left: 0;
|
||||
padding: 0.6rem 1.25rem 0.7rem 1.25rem;
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
#blazor-error-ui .dismiss {
|
||||
cursor: pointer;
|
||||
position: absolute;
|
||||
right: 0.75rem;
|
||||
top: 0.5rem;
|
||||
}
|
||||
@@ -1,7 +1,91 @@
|
||||
@page "/"
|
||||
@using Flypaper.Core
|
||||
@using Flypaper.Storage
|
||||
@inject DashboardQueries Queries
|
||||
@inject ConnectionGovernor Governor
|
||||
|
||||
<PageTitle>Flypaper</PageTitle>
|
||||
<HeadContent>
|
||||
<meta http-equiv="refresh" content="30" />
|
||||
</HeadContent>
|
||||
|
||||
<h1>Flypaper</h1>
|
||||
<header class="top">
|
||||
<h1>Flypaper</h1>
|
||||
<span class="muted">Stand @_loadedAt.ToString("HH:mm:ss") · aktualisiert alle 30 s</span>
|
||||
</header>
|
||||
|
||||
<p>Dashboard folgt.</p>
|
||||
@if (_data is { } data)
|
||||
{
|
||||
<section class="metrics">
|
||||
<div class="metric"><span class="label">Fänge gesamt</span><span class="value">@data.TotalCatches.ToString("N0")</span></div>
|
||||
<div class="metric"><span class="label">Letzte 24 h</span><span class="value">@data.CatchesLast24Hours.ToString("N0")</span></div>
|
||||
<div class="metric"><span class="label">Aktiv</span><span class="value">@Governor.ActiveConnections.ToString("N0")</span></div>
|
||||
<div class="metric"><span class="label">Eindeutige IPs</span><span class="value">@data.UniqueIps.ToString("N0")</span></div>
|
||||
<div class="metric"><span class="label">Haltezeit gesamt</span><span class="value">@FormatDuration(data.TotalHoldTime)</span></div>
|
||||
<div class="metric"><span class="label">Abgelehnt</span><span class="value">@data.Rejected.ToString("N0")</span></div>
|
||||
</section>
|
||||
|
||||
<section class="tops">
|
||||
<TopTable Title="Top 10 IPs" KeyLabel="IP" Entries="data.TopIps" />
|
||||
<TopTable Title="Top 10 Ziele" KeyLabel="Ziel" Entries="data.TopTargets" />
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<h2>Letzte 50 Fänge</h2>
|
||||
@if (data.Recent.Count == 0)
|
||||
{
|
||||
<p class="muted">Noch nichts gefangen.</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="scroll">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Zeit</th>
|
||||
<th>IP</th>
|
||||
<th>Ziel</th>
|
||||
<th>User-Agent</th>
|
||||
<th class="num">Dauer</th>
|
||||
<th class="num">Bytes</th>
|
||||
<th>Ausgang</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var trapEvent in data.Recent)
|
||||
{
|
||||
<tr>
|
||||
<td class="nowrap">@trapEvent.StartedAt.ToLocalTime().ToString("dd.MM. HH:mm:ss")</td>
|
||||
<td class="mono">@trapEvent.RemoteIp</td>
|
||||
<td class="mono clip" title="@trapEvent.Target">@trapEvent.Target</td>
|
||||
<td class="clip" title="@trapEvent.ClientInfo">@trapEvent.ClientInfo</td>
|
||||
<td class="num">@FormatDuration(TimeSpan.FromMilliseconds(trapEvent.DurationMs))</td>
|
||||
<td class="num">@trapEvent.BytesSent.ToString("N0")</td>
|
||||
<td><span class="outcome @trapEvent.Outcome.ToString().ToLowerInvariant()">@trapEvent.Outcome</span></td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
</section>
|
||||
}
|
||||
|
||||
@code {
|
||||
private DashboardData? _data;
|
||||
private DateTime _loadedAt;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_data = await Queries.GetAsync();
|
||||
_loadedAt = DateTime.Now;
|
||||
}
|
||||
|
||||
internal static string FormatDuration(TimeSpan duration) => duration switch
|
||||
{
|
||||
{ TotalDays: >= 1 } => $"{(int)duration.TotalDays} d {duration.Hours} h",
|
||||
{ TotalHours: >= 1 } => $"{duration.Hours} h {duration.Minutes} min",
|
||||
{ TotalMinutes: >= 1 } => $"{duration.Minutes} min {duration.Seconds} s",
|
||||
_ => $"{duration.TotalSeconds:0.0} s"
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
@using Flypaper.Storage
|
||||
|
||||
<section class="card">
|
||||
<h2>@Title</h2>
|
||||
@if (Entries.Count == 0)
|
||||
{
|
||||
<p class="muted">Keine Daten.</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>@KeyLabel</th>
|
||||
<th class="num">Fänge</th>
|
||||
<th class="num">Haltezeit</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var entry in Entries)
|
||||
{
|
||||
<tr>
|
||||
<td class="mono clip" title="@entry.Key">@entry.Key</td>
|
||||
<td class="num">@entry.Count.ToString("N0")</td>
|
||||
<td class="num">@Home.FormatDuration(entry.HoldTime)</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</section>
|
||||
|
||||
@code {
|
||||
[Parameter, EditorRequired] public required string Title { get; set; }
|
||||
|
||||
[Parameter, EditorRequired] public required string KeyLabel { get; set; }
|
||||
|
||||
[Parameter, EditorRequired] public required IReadOnlyList<TopEntry> Entries { get; set; }
|
||||
}
|
||||
Reference in new issue
Block a user