From 4d05f18c4c79252ac030d854efc395ec58fb3318 Mon Sep 17 00:00:00 2001 From: LowderPlay Date: Tue, 18 Aug 2026 19:57:56 +0500 Subject: [PATCH] feat: multiple verdicts (#83) * feat: multiple verdicts * chore: bump version --- Cargo.lock | 2 +- frontend/src/lib/api/probe.ts | 5 +- .../lib/components/result/ProbeTable.svelte | 56 ++++--- website/Cargo.toml | 2 +- .../20260818000000_probe_verdicts.sql | 9 ++ website/src/api/probe.rs | 153 +++++++++--------- 6 files changed, 130 insertions(+), 97 deletions(-) create mode 100644 website/migrations/20260818000000_probe_verdicts.sql diff --git a/Cargo.lock b/Cargo.lock index fd96753..d6e1f82 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4706,7 +4706,7 @@ dependencies = [ [[package]] name = "website" -version = "1.2.0" +version = "1.2.1" dependencies = [ "dotenvy", "env_logger", diff --git a/frontend/src/lib/api/probe.ts b/frontend/src/lib/api/probe.ts index e70e573..7ca7afc 100644 --- a/frontend/src/lib/api/probe.ts +++ b/frontend/src/lib/api/probe.ts @@ -32,13 +32,14 @@ export type ProbeResult = { region?: string | null; provider?: string | null; asn?: string | null; - verdict: + verdicts: ( | "uncertain" | "dns_spoofing" | "sni_block" | "tspu_block" | "whitelist" - | "ok"; + | "ok" + )[]; host_results: ProbeHostResult[] | null; target_hop: number | null; dns: { diff --git a/frontend/src/lib/components/result/ProbeTable.svelte b/frontend/src/lib/components/result/ProbeTable.svelte index c32a84e..4560f74 100644 --- a/frontend/src/lib/components/result/ProbeTable.svelte +++ b/frontend/src/lib/components/result/ProbeTable.svelte @@ -110,6 +110,19 @@ const verdictStyles = { border: "border-neutral-400/20", }, }; + +type VerdictStyle = keyof typeof verdictStyles; + +function probeVerdicts( + probe: ProbeResult, + isStaticBlocked: boolean, +): VerdictStyle[] { + return probe.verdicts.map((verdict) => + isStaticBlocked && probe.host_results?.length !== 0 && verdict === "ok" + ? "cdn_block" + : verdict, + ); +}
@@ -169,7 +182,7 @@ const verdictStyles = { {#each probes as probe (probe.probe_id)} - {@const style = verdictStyles[(isStaticBlocked && probe.host_results?.length !== 0 && probe.verdict === "ok") ? "cdn_block" : probe.verdict]} + {@const verdicts = probeVerdicts(probe, isStaticBlocked)} {@const isExpanded = !!expandedRows[probe.probe_id]} {probe.asn || ""}
- {#if probe.verdict === "whitelist"} - event.stopPropagation()} - class={`inline-flex items-center gap-1.5 px-2 py-1 rounded border ${style.bg} ${style.border} ${style.class} text-xs font-bold transition-colors hover:bg-amber-500/20 hover:border-amber-500/50 hover:text-amber-400`} - > - - {style.text} - - {:else} -
- - {style.text} -
- {/if} +
+ {#each verdicts as verdict} + {@const style = verdictStyles[verdict]} + {#if verdict === "whitelist"} + event.stopPropagation()} + class={`inline-flex items-center gap-1.5 px-2 py-1 rounded border ${style.bg} ${style.border} ${style.class} text-xs font-bold transition-colors hover:bg-amber-500/20 hover:border-amber-500/50 hover:text-amber-400`} + > + + {style.text} + + {:else} +
+ + {style.text} +
+ {/if} + {/each} +
{#if isExpanded} @@ -216,7 +234,7 @@ const verdictStyles = { {#if isExpanded} -