fix(bgp): отображать только подтверждённые показатели сессий

This commit is contained in:
Denozordec committed 2026-09-30 16:56:28 +07:00
1 parent 7046808429
commit 8fdc4b917b
13 files changed
+148 -169

No files matched your search

+4 -4
View File
@@ -1,11 +1,11 @@
import type { BgpSessionRow } from "@/lib/bgp/types"
export function fmtBgpNum(n: number): string {
export function fmtBgpNum(n: number | null): string {
if (n === null) return "—"
if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(1)}M`
if (n >= 1_000) return `${(n / 1_000).toFixed(0)}k`
return String(n)
}
export function rscBgpSnippet(s: BgpSessionRow): string {
return `/routing bgp connection\nadd name=peer-as${s.remoteAs} remote.address=${s.peerIp}/32 \\\n remote.as=${s.remoteAs} local.role=${s.type === "eBGP" ? "ebgp" : "ibgp"} \\\n output.filter-chain=export-filter input.filter=import-filter \\\n routing-table=main`
export function sumBgpCounters(values: (number | null)[]): number | null {
return values.some(n => n === null) ? null : values.reduce<number>((sum, n) => sum + (n ?? 0), 0)
}