mirror of
https://github.com/EFForg/rayhunter.git
synced 2026-07-17 05:18:11 -07:00
add rayhunter version to web UI, better row colors
This commit is contained in:
@@ -7,6 +7,7 @@ use axum::extract::State;
|
|||||||
use axum::http::StatusCode;
|
use axum::http::StatusCode;
|
||||||
use axum::Json;
|
use axum::Json;
|
||||||
use log::error;
|
use log::error;
|
||||||
|
use rayhunter::util::RuntimeMetadata;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use tokio::process::Command;
|
use tokio::process::Command;
|
||||||
|
|
||||||
@@ -14,6 +15,7 @@ use tokio::process::Command;
|
|||||||
pub struct SystemStats {
|
pub struct SystemStats {
|
||||||
pub disk_stats: DiskStats,
|
pub disk_stats: DiskStats,
|
||||||
pub memory_stats: MemoryStats,
|
pub memory_stats: MemoryStats,
|
||||||
|
pub runtime_metadata: RuntimeMetadata,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SystemStats {
|
impl SystemStats {
|
||||||
@@ -21,6 +23,7 @@ impl SystemStats {
|
|||||||
Ok(Self {
|
Ok(Self {
|
||||||
disk_stats: DiskStats::new(qmdl_path).await?,
|
disk_stats: DiskStats::new(qmdl_path).await?,
|
||||||
memory_stats: MemoryStats::new().await?,
|
memory_stats: MemoryStats::new().await?,
|
||||||
|
runtime_metadata: RuntimeMetadata::new(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,31 +15,40 @@
|
|||||||
timeStyle: "long",
|
timeStyle: "long",
|
||||||
dateStyle: "short",
|
dateStyle: "short",
|
||||||
});
|
});
|
||||||
let normal_row_color = i % 2 == 0 ? "bg-white" : "bg-gray-100";
|
let alternating_row_color = $derived(i % 2 == 0 ? "bg-white" : "bg-gray-100");
|
||||||
let row_color = current ? "bg-green-100" : normal_row_color;
|
let status_row_color = $derived.by(() => {
|
||||||
|
const num_warnings = entry.get_num_warnings();
|
||||||
|
if (num_warnings !== undefined && num_warnings > 0) {
|
||||||
|
return "bg-red-100";
|
||||||
|
}
|
||||||
|
return current ? "bg-green-100" : alternating_row_color
|
||||||
|
});
|
||||||
let analysis_visible = $state(false);
|
let analysis_visible = $state(false);
|
||||||
|
function toggle_analysis_visibility() {
|
||||||
|
analysis_visible = !analysis_visible;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<tr class="{row_color}">
|
<tr class="{status_row_color}">
|
||||||
<th class="font-bold p-2 bg-blue-100" scope='row'>{entry.name}</th>
|
<th class="font-bold p-2 bg-blue-100" scope='row'>{entry.name}</th>
|
||||||
<td class="p-2">{date_formatter.format(entry.start_time)}</td>
|
<td class="p-2">{date_formatter.format(entry.start_time)}</td>
|
||||||
<td class="p-2">{date_formatter.format(entry.last_message_time)}</td>
|
<td class="p-2">{date_formatter.format(entry.last_message_time)}</td>
|
||||||
<td class="p-2">{entry.qmdl_size_bytes}</td>
|
<td class="p-2">{entry.qmdl_size_bytes}</td>
|
||||||
<td class="p-2"><DownloadLink url={entry.getPcapUrl()} text="pcap" /></td>
|
<td class="p-2"><DownloadLink url={entry.get_pcap_url()} text="pcap" /></td>
|
||||||
<td class="p-2"><DownloadLink url={entry.getQmdlUrl()} text="qmdl" /></td>
|
<td class="p-2"><DownloadLink url={entry.get_qmdl_url()} text="qmdl" /></td>
|
||||||
<td class="p-2"><AnalysisStatus onclick={() => { analysis_visible = !analysis_visible; }} entry={entry} /></td>
|
<td class="p-2"><AnalysisStatus onclick={toggle_analysis_visibility} entry={entry} /></td>
|
||||||
{#if current}
|
{#if current}
|
||||||
<td class="p-2"></td>
|
<td class="p-2"></td>
|
||||||
{:else}
|
{:else}
|
||||||
<td class="p-2">
|
<td class="p-2">
|
||||||
<DeleteButton
|
<DeleteButton
|
||||||
prompt={`Are you sure you want to delete entry ${entry.name}?`}
|
prompt={`Are you sure you want to delete entry ${entry.name}?`}
|
||||||
url={entry.getDeleteUrl()}
|
url={entry.get_delete_url()}
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
{/if}
|
{/if}
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="{normal_row_color} border-b {analysis_visible ? '' : 'collapse'}">
|
<tr class="{alternating_row_color} border-b {analysis_visible ? '' : 'collapse'}">
|
||||||
<td class="font-bold p-2 bg-blue-100"></td>
|
<td class="font-bold p-2 bg-blue-100"></td>
|
||||||
<td class="border-t border-dashed p-2" colspan="7">
|
<td class="border-t border-dashed p-2" colspan="7">
|
||||||
<AnalysisView {entry} />
|
<AnalysisView {entry} />
|
||||||
|
|||||||
@@ -10,6 +10,12 @@
|
|||||||
<p class="text-xl">System Stats</p>
|
<p class="text-xl">System Stats</p>
|
||||||
<table class="table-auto border">
|
<table class="table-auto border">
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<tr class="border">
|
||||||
|
<th class="border">
|
||||||
|
Rayhunter version
|
||||||
|
</th>
|
||||||
|
<td class="border">{stats.runtime_metadata.rayhunter_version}</td>
|
||||||
|
</tr>
|
||||||
<tr class="border">
|
<tr class="border">
|
||||||
<th class="border">
|
<th class="border">
|
||||||
Storage
|
Storage
|
||||||
|
|||||||
@@ -69,19 +69,26 @@ export class ManifestEntry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getPcapUrl(): string {
|
get_num_warnings(): number | undefined {
|
||||||
|
if (this.analysis_report === undefined || typeof(this.analysis_report) === 'string') {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return this.analysis_report.statistics.num_warnings;
|
||||||
|
}
|
||||||
|
|
||||||
|
get_pcap_url(): string {
|
||||||
return `/api/pcap/${this.name}`;
|
return `/api/pcap/${this.name}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
getQmdlUrl(): string {
|
get_qmdl_url(): string {
|
||||||
return `/api/qmdl/${this.name}`;
|
return `/api/qmdl/${this.name}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
getAnalysisReportUrl(): string {
|
get_analysis_report_url(): string {
|
||||||
return `/api/analysis-report/${this.name}`;
|
return `/api/analysis-report/${this.name}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
getDeleteUrl(): string {
|
get_delete_url(): string {
|
||||||
return `/api/delete-recording/${this.name}`;
|
return `/api/delete-recording/${this.name}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
export interface SystemStats {
|
export interface SystemStats {
|
||||||
disk_stats: DiskStats;
|
disk_stats: DiskStats;
|
||||||
memory_stats: MemoryStats;
|
memory_stats: MemoryStats;
|
||||||
|
runtime_metadata: RuntimeMetadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RuntimeMetadata {
|
||||||
|
rayhunter_version: string,
|
||||||
|
system_os: string,
|
||||||
|
arch: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DiskStats {
|
export interface DiskStats {
|
||||||
|
|||||||
Reference in New Issue
Block a user