mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-11-25 17:30:56 +08:00
Merge remote-tracking branch 'origin/main' into pr398-wire
# Conflicts: # web/package.json
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
ArrowUpNarrowWideIcon,
|
||||
ChevronLeftIcon,
|
||||
ChevronRightIcon,
|
||||
DownloadIcon,
|
||||
EraserIcon,
|
||||
FilterXIcon,
|
||||
ListChecksIcon,
|
||||
@@ -14,11 +15,14 @@ import {
|
||||
RadioTowerIcon,
|
||||
SearchIcon,
|
||||
Trash2Icon,
|
||||
UploadIcon,
|
||||
XIcon,
|
||||
} from "lucide-react";
|
||||
import { toast } from "sonner";
|
||||
|
||||
import { HttpCodeBlock } from "@/components/http-code-block";
|
||||
import { LinkTrafficDialog } from "@/components/link-traffic-dialog";
|
||||
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
@@ -44,7 +48,7 @@ import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip
|
||||
import { api } from "@/lib/api";
|
||||
import { setVisibleInterval } from "@/lib/polling";
|
||||
import { useStoredSortPreference } from "@/lib/sort-preference";
|
||||
import type { TrafficDetail, TrafficExchange, TrafficHost, TrafficResp } from "@/lib/types";
|
||||
import type { TrafficDetail, TrafficExchange, TrafficHARImportResult, TrafficHost, TrafficResp } from "@/lib/types";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { intlLocale, t } from "@/i18n";
|
||||
|
||||
@@ -135,6 +139,7 @@ export default function TrafficPage() {
|
||||
const [path, setPath] = React.useState("");
|
||||
const [pathQ, setPathQ] = React.useState("");
|
||||
const [statusFilter, setStatusFilter] = React.useState("all");
|
||||
const [rewrittenFilter, setRewrittenFilter] = React.useState("all");
|
||||
const [respMin, setRespMin] = React.useState("");
|
||||
const [respMinQ, setRespMinQ] = React.useState("");
|
||||
const [respMax, setRespMax] = React.useState("");
|
||||
@@ -158,6 +163,13 @@ export default function TrafficPage() {
|
||||
const [deleting, setDeleting] = React.useState(false);
|
||||
const [reloadTick, setReloadTick] = React.useState(0); // manual refetch trigger
|
||||
|
||||
// HAR 1.2 import/export state
|
||||
const harInputRef = React.useRef<HTMLInputElement | null>(null);
|
||||
const [harImporting, setHarImporting] = React.useState(false);
|
||||
const [harExporting, setHarExporting] = React.useState(false);
|
||||
const [harSummary, setHarSummary] = React.useState<TrafficHARImportResult | null>(null);
|
||||
const [harError, setHarError] = React.useState<string | null>(null);
|
||||
|
||||
// Debounce both filters so we don't refetch on every keystroke.
|
||||
React.useEffect(() => {
|
||||
const t = setTimeout(() => setHostQ(host.trim()), 300);
|
||||
@@ -184,13 +196,15 @@ export default function TrafficPage() {
|
||||
return () => clearTimeout(t);
|
||||
}, [respMax]);
|
||||
|
||||
const hasAdvancedFilter = Boolean(bodyQ || pathQ || respMinQ || respMaxQ) || statusFilter !== "all";
|
||||
const hasAdvancedFilter =
|
||||
Boolean(bodyQ || pathQ || respMinQ || respMaxQ) || statusFilter !== "all" || rewrittenFilter !== "all";
|
||||
const resetAdvancedFilters = () => {
|
||||
setBody("");
|
||||
setBodyQ("");
|
||||
setPath("");
|
||||
setPathQ("");
|
||||
setStatusFilter("all");
|
||||
setRewrittenFilter("all");
|
||||
setRespMin("");
|
||||
setRespMinQ("");
|
||||
setRespMax("");
|
||||
@@ -201,7 +215,7 @@ export default function TrafficPage() {
|
||||
// biome-ignore lint/correctness/useExhaustiveDependencies: these values intentionally trigger a page reset.
|
||||
React.useEffect(() => {
|
||||
setPage(0);
|
||||
}, [hostQ, queryQ, method, size, bodyQ, pathQ, statusFilter, respMinQ, respMaxQ, sort]);
|
||||
}, [hostQ, queryQ, method, size, bodyQ, pathQ, statusFilter, rewrittenFilter, respMinQ, respMaxQ, sort]);
|
||||
|
||||
// Load the current page. Auto-refresh only on page 0 (newest) so paging back
|
||||
// through history isn't yanked out from under the user.
|
||||
@@ -214,6 +228,7 @@ export default function TrafficPage() {
|
||||
body: bodyQ,
|
||||
path: pathQ,
|
||||
status: statusFilter,
|
||||
rewritten: rewrittenFilter,
|
||||
respMin: respMinQ,
|
||||
respMax: respMaxQ,
|
||||
sort: sort.field,
|
||||
@@ -243,7 +258,21 @@ export default function TrafficPage() {
|
||||
alive = false;
|
||||
stopPolling();
|
||||
};
|
||||
}, [page, size, hostQ, method, queryQ, bodyQ, pathQ, statusFilter, respMinQ, respMaxQ, sort, reloadTick]);
|
||||
}, [
|
||||
page,
|
||||
size,
|
||||
hostQ,
|
||||
method,
|
||||
queryQ,
|
||||
bodyQ,
|
||||
pathQ,
|
||||
statusFilter,
|
||||
rewrittenFilter,
|
||||
respMinQ,
|
||||
respMaxQ,
|
||||
sort,
|
||||
reloadTick,
|
||||
]);
|
||||
|
||||
// Delete traffic for the current host filter (substring) or the checked
|
||||
// hosts (exact batch), then refetch.
|
||||
@@ -349,6 +378,76 @@ export default function TrafficPage() {
|
||||
: { field, direction: "desc" },
|
||||
);
|
||||
|
||||
const handleHarFileChange = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const file = event.target.files?.[0];
|
||||
event.target.value = "";
|
||||
if (!file) return;
|
||||
setHarError(null);
|
||||
setHarSummary(null);
|
||||
if (file.size > 32 * 1024 * 1024) {
|
||||
const msg = t("HAR file exceeds the 32 MiB limit");
|
||||
setHarError(msg);
|
||||
toast.error(msg);
|
||||
return;
|
||||
}
|
||||
setHarImporting(true);
|
||||
try {
|
||||
const raw = await file.text();
|
||||
const res = await api.trafficImportHAR(raw);
|
||||
setHarSummary(res);
|
||||
const summary = t("HAR import complete: {imported} imported, {skipped} skipped, {failed} failed", {
|
||||
imported: res.imported,
|
||||
skipped: res.skipped,
|
||||
failed: res.failed,
|
||||
});
|
||||
if (res.failed > 0 || res.truncated) {
|
||||
toast.warning(summary);
|
||||
} else {
|
||||
toast.success(summary);
|
||||
}
|
||||
setPage(0);
|
||||
setReloadTick((n) => n + 1);
|
||||
} catch (e) {
|
||||
const msg = t("HAR import failed: {error}", { error: (e as Error).message });
|
||||
setHarError(msg);
|
||||
toast.error(msg);
|
||||
} finally {
|
||||
setHarImporting(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleHarExport = async () => {
|
||||
setHarExporting(true);
|
||||
try {
|
||||
const meta = await api.trafficExportHAR({
|
||||
host: hostQ,
|
||||
method,
|
||||
q: queryQ,
|
||||
body: bodyQ,
|
||||
path: pathQ,
|
||||
status: statusFilter,
|
||||
rewritten: rewrittenFilter,
|
||||
respMin: respMinQ,
|
||||
respMax: respMaxQ,
|
||||
});
|
||||
if (meta.truncated) {
|
||||
toast.warning(
|
||||
t("Exported {exported} of {matched} matching exchanges (truncated: {reason})", {
|
||||
exported: meta.exported,
|
||||
matched: meta.matched,
|
||||
reason: meta.truncatedReason ?? "limit",
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
toast.success(t("Exported {count} exchanges to HAR", { count: meta.exported }));
|
||||
}
|
||||
} catch (e) {
|
||||
toast.error((e as Error).message);
|
||||
} finally {
|
||||
setHarExporting(false);
|
||||
}
|
||||
};
|
||||
|
||||
const exchanges = React.useMemo(() => traffic?.exchanges ?? [], [traffic]);
|
||||
const total = traffic?.total ?? exchanges.length;
|
||||
const pageCount = Math.max(1, Math.ceil(total / size));
|
||||
@@ -378,9 +477,76 @@ export default function TrafficPage() {
|
||||
<span className="text-xs text-muted-foreground tabular-nums">
|
||||
{t("{count} records", { count: traffic?.count ?? 0 })}
|
||||
</span>
|
||||
<input
|
||||
ref={harInputRef}
|
||||
type="file"
|
||||
accept=".har,application/json"
|
||||
className="hidden"
|
||||
onChange={(e) => void handleHarFileChange(e)}
|
||||
/>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="h-8"
|
||||
disabled={harImporting}
|
||||
onClick={() => harInputRef.current?.click()}
|
||||
>
|
||||
{harImporting ? <Loader2Icon className="size-3.5 animate-spin" /> : <UploadIcon className="size-3.5" />}
|
||||
{harImporting ? t("Importing HAR…") : t("Import HAR")}
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="h-8"
|
||||
disabled={harExporting || !traffic?.count}
|
||||
onClick={() => void handleHarExport()}
|
||||
>
|
||||
{harExporting ? <Loader2Icon className="size-3.5 animate-spin" /> : <DownloadIcon className="size-3.5" />}
|
||||
{harExporting ? t("Exporting HAR…") : t("Export HAR")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{harError ? (
|
||||
<Alert variant="destructive" className="flex items-center justify-between gap-2 py-2">
|
||||
<AlertDescription className="text-xs">{harError}</AlertDescription>
|
||||
<Button variant="ghost" size="icon-xs" aria-label={t("Dismiss")} onClick={() => setHarError(null)}>
|
||||
<XIcon className="size-3.5" />
|
||||
</Button>
|
||||
</Alert>
|
||||
) : null}
|
||||
|
||||
{harSummary ? (
|
||||
<Alert className="flex items-start justify-between gap-2 py-2">
|
||||
<AlertDescription className="space-y-1 text-xs">
|
||||
<p>
|
||||
{t("HAR import complete: {imported} imported, {skipped} skipped, {failed} failed", {
|
||||
imported: harSummary.imported,
|
||||
skipped: harSummary.skipped,
|
||||
failed: harSummary.failed,
|
||||
})}
|
||||
</p>
|
||||
{harSummary.truncated ? (
|
||||
<p className="text-amber-600 dark:text-amber-400">
|
||||
{t("HAR import stopped early at the 32 MiB decoded body cap.")}
|
||||
</p>
|
||||
) : null}
|
||||
{harSummary.errors && harSummary.errors.length > 0 ? (
|
||||
<ul className="list-disc pl-4 text-muted-foreground">
|
||||
{harSummary.errors.slice(0, 5).map((item) => (
|
||||
<li key={`${item.index}-${item.reason}`} className="font-mono">
|
||||
#{item.index}: {item.reason}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : null}
|
||||
</AlertDescription>
|
||||
<Button variant="ghost" size="icon-xs" aria-label={t("Dismiss")} onClick={() => setHarSummary(null)}>
|
||||
<XIcon className="size-3.5" />
|
||||
</Button>
|
||||
</Alert>
|
||||
) : null}
|
||||
|
||||
{/* Toolbar */}
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<Popover open={pickerOpen} onOpenChange={setPickerOpen}>
|
||||
@@ -598,6 +764,16 @@ export default function TrafficPage() {
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Select value={rewrittenFilter} onValueChange={setRewrittenFilter}>
|
||||
<SelectTrigger size="sm" className="w-32">
|
||||
<SelectValue placeholder={t("Rewritten")} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">{t("All traffic")}</SelectItem>
|
||||
<SelectItem value="rewritten">{t("Rewritten")}</SelectItem>
|
||||
<SelectItem value="original">{t("Original")}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<div className="flex items-center gap-1 text-xs text-muted-foreground">
|
||||
<span>{t("Response size")}</span>
|
||||
<Input
|
||||
@@ -721,7 +897,17 @@ export default function TrafficPage() {
|
||||
<MethodBadge method={e.method} />
|
||||
</TableCell>
|
||||
<TableCell className="max-w-0">
|
||||
<span className="block truncate font-mono text-xs">{e.url}</span>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<span className="min-w-0 truncate font-mono text-xs">{e.url}</span>
|
||||
{e.rewritten ? (
|
||||
<Badge
|
||||
variant="outline"
|
||||
className="shrink-0 border-amber-500/30 bg-amber-500/10 px-1.5 py-0 text-[10px] font-medium text-amber-600 dark:text-amber-400"
|
||||
>
|
||||
{t("Rewritten")}
|
||||
</Badge>
|
||||
) : null}
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<span className={cn("font-mono text-xs font-semibold tabular-nums", statusTone(e.status))}>
|
||||
@@ -762,6 +948,14 @@ export default function TrafficPage() {
|
||||
<Badge variant="secondary" className={cn("font-mono tabular-nums", statusTone(selected.status))}>
|
||||
{selected.status}
|
||||
</Badge>
|
||||
{selected.rewritten ? (
|
||||
<Badge
|
||||
variant="outline"
|
||||
className="border-amber-500/30 bg-amber-500/10 text-amber-600 dark:text-amber-400"
|
||||
>
|
||||
{t("Rewritten")}
|
||||
</Badge>
|
||||
) : null}
|
||||
<span className="ml-auto text-xs text-muted-foreground tabular-nums">{fmtTime(selected.ts)}</span>
|
||||
</div>
|
||||
<SheetTitle className="break-all font-mono">{selected.host}</SheetTitle>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
/* Theme preset styles: these override CSS variables based on the selected data-theme-preset */
|
||||
@import "../styles/presets/brutalist.css";
|
||||
@import "../styles/presets/neon.css";
|
||||
@import "../styles/presets/soft-pop.css";
|
||||
@import "../styles/presets/tangerine.css";
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
# UI localization
|
||||
|
||||
English source text is the translation key. `t(key, vars)` is shared by React
|
||||
components, module constants, toasts and non-React helpers; missing keys fall back
|
||||
to English. Keep keys, `{name}` placeholders, HTML formatting tags, Go template
|
||||
actions and literal command/API examples intact when adding translations.
|
||||
|
||||
The registered locales are English (`en`), Turkish (`tr`) and Simplified Chinese
|
||||
(`zh-CN`). The Preferences language control renders `LOCALES` directly. A saved
|
||||
`artex.locale` browser preference takes priority over browser language detection;
|
||||
otherwise an exact language tag, then its base language, is matched. Chinese
|
||||
browser variants use the available Simplified Chinese dictionary. Static export
|
||||
and unsupported languages retain the English default. Switching language saves
|
||||
the preference and reloads the page, following the existing module-level design.
|
||||
|
||||
To add a locale, add `locales/<code>.json` and register it in `Locale`, `LOCALES`,
|
||||
`DICTIONARIES` and `INTL_LOCALES` in `index.ts`. Date/number formatting uses
|
||||
`intlLocale`, and the HTML `lang` attribute follows the selected locale.
|
||||
|
||||
Run `npm run test:i18n` and `npm run build:static` from `web/`. The dictionary
|
||||
checker covers every locale, checks literal call sites, requires matching keys
|
||||
including dynamic entries, and validates placeholders. Runtime tests exercise
|
||||
language detection, persistence, English fallback and prototype-safe lookups.
|
||||
|
||||
The initial Simplified Chinese dictionary reuses Chinese wording from this
|
||||
repository's parent of commit `e233c02` (the English translation migration), with
|
||||
additional translations for current functionality and normalized UI terminology.
|
||||
This only localizes interface text; backend data, user content, model responses,
|
||||
protocol identifiers and tool output are not rewritten.
|
||||
+21
-7
@@ -8,11 +8,12 @@
|
||||
// setLocale() stores the choice and reloads. That keeps t() usable anywhere (components,
|
||||
// module constants, toasts, non-React helpers) without hooks or re-render plumbing.
|
||||
//
|
||||
// To translate the UI into another language, add locales/<code>.json and list it in LOCALES.
|
||||
// To translate the UI into another language, add locales/<code>.json and register it below.
|
||||
|
||||
import tr from "./locales/tr.json";
|
||||
import zhCN from "./locales/zh-CN.json";
|
||||
|
||||
export type Locale = "tr" | "en";
|
||||
export type Locale = "tr" | "en" | "zh-CN";
|
||||
|
||||
// Used when nothing is saved and the browser language is not one of LOCALES,
|
||||
// and for the static prerender, which has no browser.
|
||||
@@ -21,6 +22,7 @@ export const DEFAULT_LOCALE: Locale = "en";
|
||||
export const LOCALES: { code: Locale; label: string }[] = [
|
||||
{ code: "tr", label: "Türkçe" },
|
||||
{ code: "en", label: "English" },
|
||||
{ code: "zh-CN", label: "简体中文" },
|
||||
];
|
||||
|
||||
const STORAGE_KEY = "artex.locale";
|
||||
@@ -28,6 +30,13 @@ const STORAGE_KEY = "artex.locale";
|
||||
const DICTIONARIES: Record<Locale, Record<string, string>> = {
|
||||
tr: tr as Record<string, string>,
|
||||
en: {},
|
||||
"zh-CN": zhCN as Record<string, string>,
|
||||
};
|
||||
|
||||
const INTL_LOCALES: Record<Locale, string> = {
|
||||
tr: "tr-TR",
|
||||
en: "en-US",
|
||||
"zh-CN": "zh-CN",
|
||||
};
|
||||
|
||||
function detectLocale(): Locale {
|
||||
@@ -35,13 +44,18 @@ function detectLocale(): Locale {
|
||||
if (typeof window === "undefined") return DEFAULT_LOCALE;
|
||||
try {
|
||||
const saved = window.localStorage.getItem(STORAGE_KEY);
|
||||
if (saved === "tr" || saved === "en") return saved;
|
||||
const match = LOCALES.find((l) => l.code === saved);
|
||||
if (match) return match.code;
|
||||
} catch {
|
||||
/* storage blocked: fall through to the browser language */
|
||||
}
|
||||
for (const lang of window.navigator.languages ?? [window.navigator.language]) {
|
||||
const base = lang?.toLowerCase().split("-")[0];
|
||||
const match = LOCALES.find((l) => l.code === base);
|
||||
const tag = lang?.toLowerCase();
|
||||
const base = tag?.split("-")[0];
|
||||
// Prefer a full BCP 47 match, then the available locale for that language.
|
||||
const match =
|
||||
LOCALES.find((l) => l.code.toLowerCase() === tag) ??
|
||||
LOCALES.find((l) => l.code.toLowerCase().split("-")[0] === base);
|
||||
if (match) return match.code;
|
||||
}
|
||||
return DEFAULT_LOCALE;
|
||||
@@ -52,7 +66,7 @@ export const locale: Locale = detectLocale();
|
||||
if (typeof document !== "undefined") document.documentElement.lang = locale;
|
||||
|
||||
/** BCP 47 tag for Intl / toLocaleString calls, e.g. date.toLocaleString(intlLocale). */
|
||||
export const intlLocale = locale === "tr" ? "tr-TR" : "en-US";
|
||||
export const intlLocale = INTL_LOCALES[locale];
|
||||
|
||||
const dict = DICTIONARIES[locale];
|
||||
|
||||
@@ -71,7 +85,7 @@ export function setLocale(next: Locale) {
|
||||
try {
|
||||
window.localStorage.setItem(STORAGE_KEY, next);
|
||||
} catch {
|
||||
/* storage blocked: the switch lasts only until the next load */
|
||||
/* storage blocked: fall back to browser-language detection on reload */
|
||||
}
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
@@ -245,6 +245,7 @@
|
||||
"All statuses": "Tüm durumlar",
|
||||
"All tasks": "Tüm görevler",
|
||||
"All tool execution records": "Tüm araç çalıştırma kayıtları",
|
||||
"All traffic": "Tüm trafik",
|
||||
"All types": "Tüm türler",
|
||||
"all used": "tümü kullanıldı",
|
||||
"All verification states": "Tüm doğrulama durumları",
|
||||
@@ -767,6 +768,7 @@
|
||||
"Discovery time": "Keşif zamanı",
|
||||
"Discovery time currently ascending, click to toggle sort direction": "Keşif zamanı şu anda artan sırada, sıralama yönünü değiştirmek için tıklayın",
|
||||
"Discovery time currently descending, click to toggle sort direction": "Keşif zamanı şu anda azalan sırada, sıralama yönünü değiştirmek için tıklayın",
|
||||
"Dismiss": "Kapat",
|
||||
"Dismiss update notice": "Güncelleme bildirimini kapat",
|
||||
"dismissed": "yok sayıldı",
|
||||
"Dismissed": "Yok sayıldı",
|
||||
@@ -925,9 +927,13 @@
|
||||
"Export failed: {error}": "Dışa aktarma başarısız: {error}",
|
||||
"Export findings": "Bulguları dışa aktar",
|
||||
"Export format": "Dışa aktarma biçimi",
|
||||
"Export HAR": "HAR dışa aktar",
|
||||
"Export scope": "Dışa aktarma kapsamı",
|
||||
"Export the {count} selected items": "Seçili {count} öğeyi dışa aktar",
|
||||
"Export the current filter results ({count} items)": "Mevcut süzgeç sonuçlarını dışa aktar ({count} öğe)",
|
||||
"Exported {count} exchanges to HAR": "{count} değişim HAR olarak dışa aktarıldı",
|
||||
"Exported {exported} of {matched} matching exchanges (truncated: {reason})": "Eşleşen {matched} değişimin {exported} tanesi dışa aktarıldı (kısaltıldı: {reason})",
|
||||
"Exporting HAR…": "HAR dışa aktarılıyor…",
|
||||
"Exporting…": "Dışa aktarılıyor…",
|
||||
"External MCP tool servers · visibility granted per agent": "Harici MCP araç sunucuları · görünürlük ajan bazında verilir",
|
||||
"Fact": "Olgu",
|
||||
@@ -1070,6 +1076,13 @@
|
||||
"greater than": "büyüktür",
|
||||
"greater than or equal": "büyük veya eşittir",
|
||||
"Handle automatically after the timeout instead of waiting": "Beklemek yerine zaman aşımından sonra otomatik olarak işle",
|
||||
"HAR export failed: {error}": "HAR dışa aktarma başarısız: {error}",
|
||||
"HAR export is not available in mock mode": "HAR dışa aktarma sahte modda kullanılamaz",
|
||||
"HAR file exceeds the 32 MiB limit": "HAR dosyası 32 MiB sınırını aşıyor",
|
||||
"HAR import complete: {imported} imported, {skipped} skipped, {failed} failed": "HAR içe aktarma tamamlandı: {imported} içe aktarıldı, {skipped} atlandı, {failed} başarısız",
|
||||
"HAR import failed: {error}": "HAR içe aktarma başarısız: {error}",
|
||||
"HAR import is not available in mock mode": "HAR içe aktarma sahte modda kullanılamaz",
|
||||
"HAR import stopped early at the 32 MiB decoded body cap.": "HAR içe aktarma 32 MiB çözülmüş gövde sınırında erken durdu.",
|
||||
"Hard delete": "Kalıcı silme",
|
||||
"Header": "Başlık",
|
||||
"Header name": "Başlık adı",
|
||||
@@ -1112,6 +1125,8 @@
|
||||
"Idle": "Boşta",
|
||||
"Ignored": "Yok sayıldı",
|
||||
"Implicit TLS": "Örtük TLS",
|
||||
"Import HAR": "HAR içe aktar",
|
||||
"Importing HAR…": "HAR içe aktarılıyor…",
|
||||
"In": "Girdi",
|
||||
"In {input} (incl. cache {cache}) · Out {output}": "Girdi {input} (önbellek {cache} dahil) · Çıktı {output}",
|
||||
"In flight": "Devam eden",
|
||||
@@ -1600,6 +1615,7 @@
|
||||
"OR (either one matches)": "OR (herhangi biri eşleşir)",
|
||||
"Ordered failover: workers share the current profile and switch after quota exhaustion or repeated provider failures.": "Sıralı yedeğe geçiş: çalışanlar geçerli profili paylaşır ve kota tükendiğinde veya sağlayıcı tekrar tekrar başarısız olduğunda geçiş yapar.",
|
||||
"origin": "başlangıç",
|
||||
"Original": "Orijinal",
|
||||
"Original status": "Önceki durum",
|
||||
"Other": "Diğer",
|
||||
"Out": "Çıktı",
|
||||
@@ -1906,6 +1922,7 @@
|
||||
"Revoked Skill \"{name}\" visibility": "\"{name}\" becerisinin görünürlüğü kaldırıldı",
|
||||
"Revoked visibility from \"{agent}\"": "\"{agent}\" için görünürlük kaldırıldı",
|
||||
"Revoked visibility to \"{name}\"": "\"{name}\" için görünürlük kaldırıldı",
|
||||
"Rewritten": "Yeniden yazılmış",
|
||||
"Rewritten by capture rules": "Yakalama kuralları tarafından yeniden yazıldı",
|
||||
"Rewritten by capture rules: {ids}": "Yakalama kuralları tarafından yeniden yazıldı: {ids}",
|
||||
"Risk": "Risk",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -102,6 +102,8 @@ import type {
|
||||
TrafficDetail,
|
||||
TrafficEvidenceRef,
|
||||
TrafficEvidenceRole,
|
||||
TrafficHARExportMeta,
|
||||
TrafficHARImportResult,
|
||||
TrafficHost,
|
||||
TrafficReplayRequest,
|
||||
TrafficReplayResult,
|
||||
@@ -840,6 +842,7 @@ export const api = {
|
||||
body?: string;
|
||||
path?: string;
|
||||
status?: string;
|
||||
rewritten?: string;
|
||||
respMin?: string;
|
||||
respMax?: string;
|
||||
sort?: string;
|
||||
@@ -854,6 +857,7 @@ export const api = {
|
||||
(opts.body ? `&body=${encodeURIComponent(opts.body)}` : "") +
|
||||
(opts.path ? `&path=${encodeURIComponent(opts.path)}` : "") +
|
||||
(opts.status && opts.status !== "all" ? `&status=${encodeURIComponent(opts.status)}` : "") +
|
||||
(opts.rewritten && opts.rewritten !== "all" ? `&rewritten=${encodeURIComponent(opts.rewritten)}` : "") +
|
||||
(opts.respMin ? `&resp_min=${encodeURIComponent(opts.respMin)}` : "") +
|
||||
(opts.respMax ? `&resp_max=${encodeURIComponent(opts.respMax)}` : "") +
|
||||
(opts.sort ? `&sort=${encodeURIComponent(opts.sort)}` : "") +
|
||||
@@ -884,6 +888,77 @@ export const api = {
|
||||
apply_rules: Boolean(req.apply_rules),
|
||||
});
|
||||
},
|
||||
// Imports a raw HAR 1.2 JSON document into the traffic store.
|
||||
trafficImportHAR: async (rawJSON: string): Promise<TrafficHARImportResult> => {
|
||||
if (MOCK) throw new Error(t("HAR import is not available in mock mode"));
|
||||
return http<TrafficHARImportResult>(`/traffic/import/har`, {
|
||||
method: "POST",
|
||||
body: rawJSON,
|
||||
});
|
||||
},
|
||||
// Exports filtered traffic as a HAR 1.2 file download and returns truncation metadata.
|
||||
trafficExportHAR: async (
|
||||
opts: {
|
||||
host?: string;
|
||||
method?: string;
|
||||
q?: string;
|
||||
body?: string;
|
||||
path?: string;
|
||||
status?: string;
|
||||
rewritten?: string;
|
||||
respMin?: string;
|
||||
respMax?: string;
|
||||
} = {},
|
||||
): Promise<TrafficHARExportMeta> => {
|
||||
if (MOCK) throw new Error(t("HAR export is not available in mock mode"));
|
||||
const qs = new URLSearchParams();
|
||||
if (opts.host) qs.set("host", opts.host);
|
||||
if (opts.method && opts.method !== "all") qs.set("method", opts.method);
|
||||
if (opts.q) qs.set("q", opts.q);
|
||||
if (opts.body) qs.set("body", opts.body);
|
||||
if (opts.path) qs.set("path", opts.path);
|
||||
if (opts.status && opts.status !== "all") qs.set("status", opts.status);
|
||||
if (opts.rewritten && opts.rewritten !== "all") qs.set("rewritten", opts.rewritten);
|
||||
if (opts.respMin) qs.set("resp_min", opts.respMin);
|
||||
if (opts.respMax) qs.set("resp_max", opts.respMax);
|
||||
const suffix = qs.toString();
|
||||
const token = getToken();
|
||||
const r = await fetch(`/api/traffic/export/har${suffix ? `?${suffix}` : ""}`, {
|
||||
headers: { ...(token ? { Authorization: `Bearer ${token}` } : {}) },
|
||||
});
|
||||
if (r.status === 401) {
|
||||
if (typeof window !== "undefined") {
|
||||
localStorage.removeItem("artex_token");
|
||||
document.cookie = "artex_token=; path=/; max-age=0";
|
||||
window.location.href = "/login";
|
||||
}
|
||||
throw new Error(t("Unauthorized"));
|
||||
}
|
||||
if (!r.ok) {
|
||||
let msg = String(r.status);
|
||||
try {
|
||||
const payload = (await r.json()) as { error?: unknown };
|
||||
if (typeof payload.error === "string" && payload.error.trim()) msg = payload.error.trim();
|
||||
} catch {
|
||||
// Keep status fallback.
|
||||
}
|
||||
throw new ApiError(t("HAR export failed: {error}", { error: msg }), r.status);
|
||||
}
|
||||
const blob = await r.blob();
|
||||
const exported = Number(r.headers.get("X-ARTEX-HAR-Exported") ?? "0") || 0;
|
||||
const matched = Number(r.headers.get("X-ARTEX-HAR-Matched") ?? "0") || 0;
|
||||
const truncated = r.headers.get("X-ARTEX-HAR-Truncated") === "true";
|
||||
const truncatedReason = r.headers.get("X-ARTEX-HAR-Truncated-Reason") ?? undefined;
|
||||
const objectUrl = URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = objectUrl;
|
||||
a.download = "artex-traffic.har";
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
a.remove();
|
||||
URL.revokeObjectURL(objectUrl);
|
||||
return { exported, matched, truncated, truncatedReason };
|
||||
},
|
||||
trafficHosts: () => get<{ hosts: TrafficHost[] }>(`/traffic/hosts`),
|
||||
trafficDeleteHost: (host: string) => del<{ deleted: number }>(`/traffic?host=${encodeURIComponent(host)}`),
|
||||
trafficDeleteHosts: (hosts: string[]) => del<{ deleted: number }>(`/traffic/hosts`, { hosts }),
|
||||
|
||||
@@ -29,6 +29,14 @@ export const THEME_PRESET_OPTIONS = [
|
||||
dark: "oklch(0.7044 0.1872 23.1858)",
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "Neon",
|
||||
value: "neon",
|
||||
primary: {
|
||||
light: "#00685f",
|
||||
dark: "#54eccd",
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "Soft Pop",
|
||||
value: "soft-pop",
|
||||
|
||||
@@ -903,6 +903,7 @@ export interface TrafficExchange {
|
||||
status: number;
|
||||
content_type: string;
|
||||
resp_len: number;
|
||||
rewritten?: boolean;
|
||||
}
|
||||
|
||||
export interface TrafficRewriteStats {
|
||||
@@ -913,6 +914,27 @@ export interface TrafficRewriteStats {
|
||||
sweeps: number;
|
||||
}
|
||||
|
||||
export interface TrafficHARImportError {
|
||||
index: number;
|
||||
url?: string;
|
||||
reason: string;
|
||||
}
|
||||
|
||||
export interface TrafficHARImportResult {
|
||||
imported: number;
|
||||
skipped: number;
|
||||
failed: number;
|
||||
truncated?: boolean;
|
||||
errors?: TrafficHARImportError[];
|
||||
}
|
||||
|
||||
export interface TrafficHARExportMeta {
|
||||
exported: number;
|
||||
matched: number;
|
||||
truncated: boolean;
|
||||
truncatedReason?: string;
|
||||
}
|
||||
|
||||
export interface TrafficResp {
|
||||
enabled: boolean;
|
||||
proxy?: string;
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
label: Neon
|
||||
value: neon
|
||||
*/
|
||||
|
||||
:root[data-theme-preset="neon"] {
|
||||
--background: #f3f8f9;
|
||||
--foreground: #14252d;
|
||||
--card: #ffffff;
|
||||
--card-foreground: var(--foreground);
|
||||
--popover: #ffffff;
|
||||
--popover-foreground: var(--foreground);
|
||||
--primary: #00685f;
|
||||
--primary-foreground: #ffffff;
|
||||
--secondary: #dcebed;
|
||||
--secondary-foreground: #19363b;
|
||||
--muted: #e6eff1;
|
||||
--muted-foreground: #456169;
|
||||
--accent: #ccefe8;
|
||||
--accent-foreground: #08483f;
|
||||
--destructive: #aa2647;
|
||||
--border: #b6cdd1;
|
||||
--input: #728d91;
|
||||
--ring: #00766d;
|
||||
--chart-1: #00776e;
|
||||
--chart-2: #385eb2;
|
||||
--chart-3: #9b3e7b;
|
||||
--chart-4: #916008;
|
||||
--chart-5: #527927;
|
||||
--sidebar: #e8f2f3;
|
||||
--sidebar-foreground: var(--foreground);
|
||||
--sidebar-primary: var(--primary);
|
||||
--sidebar-primary-foreground: var(--primary-foreground);
|
||||
--sidebar-accent: var(--accent);
|
||||
--sidebar-accent-foreground: var(--accent-foreground);
|
||||
--sidebar-border: var(--border);
|
||||
--sidebar-ring: var(--ring);
|
||||
}
|
||||
|
||||
.dark:root[data-theme-preset="neon"] {
|
||||
--background: #0e181f;
|
||||
--foreground: #e8f6f3;
|
||||
--card: #16252d;
|
||||
--card-foreground: var(--foreground);
|
||||
--popover: #192a34;
|
||||
--popover-foreground: var(--foreground);
|
||||
--primary: #54eccd;
|
||||
--primary-foreground: #082820;
|
||||
--secondary: #243743;
|
||||
--secondary-foreground: #e8f6f3;
|
||||
--muted: #1e303a;
|
||||
--muted-foreground: #adc5ca;
|
||||
--accent: #203f43;
|
||||
--accent-foreground: #a7f5e4;
|
||||
--destructive: #ffa6b6;
|
||||
--border: #3f5861;
|
||||
--input: #66848e;
|
||||
--ring: #54eccd;
|
||||
--chart-1: #54eccd;
|
||||
--chart-2: #8fb2ff;
|
||||
--chart-3: #f7a5db;
|
||||
--chart-4: #fbc477;
|
||||
--chart-5: #b3db7d;
|
||||
--sidebar: #111f27;
|
||||
--sidebar-foreground: var(--foreground);
|
||||
--sidebar-primary: var(--primary);
|
||||
--sidebar-primary-foreground: var(--primary-foreground);
|
||||
--sidebar-accent: var(--accent);
|
||||
--sidebar-accent-foreground: var(--accent-foreground);
|
||||
--sidebar-border: var(--border);
|
||||
--sidebar-ring: var(--ring);
|
||||
}
|
||||
Reference in New Issue
Block a user