fix(map): исправить маршруты и легенду, показать трафик пользователей
Docker images / prepare-release (push) Successful in 11s
Docker images / backend-test (push) Successful in 10m33s
Docker images / frontend-image (push) Successful in 2m13s
Docker images / updater-image (push) Successful in 39s
Docker images / netflow-agent-image (push) Successful in 31s
Docker images / backend-image (push) Successful in 2m2s
Docker images / publish-release (push) Successful in 11s
Docker images / notify-webhook (push) Successful in 2s
Docker images / prepare-release (push) Successful in 11s
Docker images / backend-test (push) Successful in 10m33s
Docker images / frontend-image (push) Successful in 2m13s
Docker images / updater-image (push) Successful in 39s
Docker images / netflow-agent-image (push) Successful in 31s
Docker images / backend-image (push) Successful in 2m2s
Docker images / publish-release (push) Successful in 11s
Docker images / notify-webhook (push) Successful in 2s
This commit is contained in:
1 parent
589fc782f9
commit
2ca40fbb4d
14 files changed
+296
-132
No files matched your search
@@ -85,9 +85,9 @@ import {
|
||||
import { isFreshMapTrafficSample, useMapInterfaceTraffic } from "@/hooks/use-map-interface-traffic"
|
||||
import { useTrafficLive } from "@/hooks/use-traffic-live"
|
||||
import { formatBytes } from "@/lib/fmt-rate"
|
||||
import type { FlowMapCountryServiceGroup, FlowMapInterfaceTraffic, FlowMapHop, FlowMapService, FlowMapServiceEdge, FlowMapServicePath } from "@mmapp/contracts/traffic-flow"
|
||||
import type { FlowMapCountryServiceGroup, FlowMapHopsDto, FlowMapInterfaceTraffic, FlowMapHop, FlowMapService, FlowMapServiceEdge, FlowMapServicePath } from "@mmapp/contracts/traffic-flow"
|
||||
import { ServiceBrandIcon } from "@/components/network-map/service-brand-icon"
|
||||
import { InspectorMetrics, NodeHistory, ServiceInspector } from "@/components/network-map/inspector-traffic"
|
||||
import { InspectorMetrics, InspectorUsers, NodeHistory, ServiceInspector, serviceUsers } from "@/components/network-map/inspector-traffic"
|
||||
import { Spinner } from "@/components/ui/spinner"
|
||||
import { CountryFlagSvg } from "@/components/network-map/country-flag-svg"
|
||||
import { Button } from "@/components/ui/button"
|
||||
@@ -100,7 +100,7 @@ import {
|
||||
CableIcon, ActivityIcon,
|
||||
} from "lucide-react"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { formatServicePathLabel, formatServicePathTitle } from "@/lib/format-service-path-label"
|
||||
import { formatServicePathLabel, formatServicePathTitle, servicePathKey } from "@/lib/format-service-path-label"
|
||||
import Link from "next/link"
|
||||
import { MapBottomPanel, MapTimeline, type MapBottomTab, type MapEventRow } from "@/components/network-map/map-bottom-panel"
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
|
||||
@@ -364,11 +364,8 @@ function destDisplayLabel(node: FlowMapService | undefined, mode: DestMode, fall
|
||||
return countryName(node.label)
|
||||
}
|
||||
|
||||
function servicePathKey(p: Pick<FlowMapServicePath, "clientId" | "viaId" | "enId" | "serviceId">): string {
|
||||
return `${p.clientId}|${p.viaId}|${p.enId}|${p.serviceId}`
|
||||
}
|
||||
|
||||
function greMatchesPath(e: GreMapEdge, h: { viaId: string; enId: string }): boolean {
|
||||
if (!h.enId || h.viaId === h.enId) return false
|
||||
const ids = new Set([e.fromServer.id, e.toServer.id])
|
||||
return ids.has(h.viaId) && ids.has(h.enId)
|
||||
}
|
||||
@@ -636,7 +633,7 @@ function ServicePathList({
|
||||
paths: FlowMapServicePath[]
|
||||
servers: Server[]
|
||||
services: FlowMapService[]
|
||||
highlight: { viaId: string; enId: string; serviceId: string } | null
|
||||
highlight: FlowMapServicePath | null
|
||||
viaMode: "via" | "service"
|
||||
destMode: DestMode
|
||||
onToggle: (p: FlowMapServicePath) => void
|
||||
@@ -652,18 +649,15 @@ function ServicePathList({
|
||||
const en = servers.find((s) => s.id === p.enId)
|
||||
const svc = services.find((s) => s.id === p.serviceId)
|
||||
const destLabel = destDisplayLabel(svc, destMode, p.serviceId)
|
||||
const label = formatServicePathLabel(p, viaMode, {
|
||||
const label = p.enId ? formatServicePathLabel(p, viaMode, {
|
||||
viaName: via?.name,
|
||||
viaSite: via?.site,
|
||||
enName: en?.name,
|
||||
serviceLabel: destLabel,
|
||||
})
|
||||
}) : [p.viaName || p.viaId, p.viaIface, "наблюдение IPFIX"].filter(Boolean).join(" · ")
|
||||
const title = formatServicePathTitle(label, destLabel)
|
||||
const active = Boolean(
|
||||
highlight
|
||||
&& highlight.viaId === p.viaId
|
||||
&& highlight.enId === p.enId
|
||||
&& highlight.serviceId === p.serviceId,
|
||||
highlight && servicePathKey(highlight) === rowKey,
|
||||
)
|
||||
return (
|
||||
<button type="button"
|
||||
@@ -906,6 +900,7 @@ function NetworkMapContent() {
|
||||
}, [apiFetch, useLiveData, hasIxNodes])
|
||||
const [speedProbes, setSpeedProbes] = useState<GreSpeedProbeSnapshot[]>([])
|
||||
const [mapHops, setMapHops] = useState<FlowMapHop[]>([])
|
||||
const [mapNodeUsers, setMapNodeUsers] = useState<FlowMapHopsDto["nodeUsers"]>()
|
||||
const [interfaceTraffic, setInterfaceTraffic] = useState<FlowMapInterfaceTraffic[]>()
|
||||
const [mapServices, setMapServices] = useState<FlowMapService[]>([])
|
||||
const [mapServiceEdges, setMapServiceEdges] = useState<FlowMapServiceEdge[]>([])
|
||||
@@ -1116,7 +1111,7 @@ function NetworkMapContent() {
|
||||
const expandedCountry = expandedCountryId
|
||||
? mapCountries.find((c) => c.id === expandedCountryId) ?? null
|
||||
: null
|
||||
const [highlightedPath, setHighlightedPath] = useState<{ viaId: string; enId: string; serviceId: string } | null>(null)
|
||||
const [highlightedPath, setHighlightedPath] = useState<FlowMapServicePath | null>(null)
|
||||
const selWanIdx=urlState.wan
|
||||
function setSelWanIdx(value:React.SetStateAction<number|null>){const next=typeof value==="function"?value(selWanIdx):value;updateUrl({wan:next==null?null:String(next)})}
|
||||
const [hoveredId, setHoveredId] = useState<string | null>(null)
|
||||
@@ -1168,6 +1163,7 @@ function NetworkMapContent() {
|
||||
if (!useLiveData) {
|
||||
queueMicrotask(() => {
|
||||
setMapHops([])
|
||||
setMapNodeUsers(undefined)
|
||||
setInterfaceTraffic(undefined)
|
||||
setMapServices(MOCK_MAP_SERVICES)
|
||||
setMapServiceEdges(MOCK_MAP_SERVICE_EDGES)
|
||||
@@ -1198,6 +1194,7 @@ function NetworkMapContent() {
|
||||
if (cancelled||request!==epoch) return
|
||||
const res=networkMapFlowSchema.parse(raw)
|
||||
setMapHops(res.hops)
|
||||
setMapNodeUsers(res.nodeUsers)
|
||||
setInterfaceTraffic(res.interfaceTraffic)
|
||||
setMapServices(res.services)
|
||||
setMapServiceEdges(res.serviceEdges)
|
||||
@@ -1438,9 +1435,11 @@ function NetworkMapContent() {
|
||||
? destEdges.filter(edge => nodePosById[edge.fromId] && visibleMapServices.some(service => service.id === edge.toId))
|
||||
: []
|
||||
|
||||
const selectedExitEdges = destEdges.filter(edge => edge.toId === liveSelectedService?.id)
|
||||
const selectedDestEdges = destEdges.filter(edge => edge.toId === liveSelectedService?.id)
|
||||
const selectedDestPaths = (selectedNestedService ? expandedCountryGroup?.paths ?? [] : destPaths)
|
||||
.filter(p => p.serviceId === liveSelectedService?.id).sort((a, b) => b.bps - a.bps)
|
||||
const unassignedBytes = liveSelectedService
|
||||
? liveSelectedService.bytes - selectedExitEdges.reduce((sum, edge) => sum + edge.bytes, 0)
|
||||
? liveSelectedService.bytes - selectedDestEdges.reduce((sum, edge) => sum + edge.bytes, 0)
|
||||
: 0
|
||||
|
||||
const nodes = mapServers
|
||||
@@ -1786,14 +1785,7 @@ function NetworkMapContent() {
|
||||
}
|
||||
|
||||
function togglePathHighlight(p: FlowMapServicePath) {
|
||||
setHighlightedPath((prev) => (
|
||||
prev
|
||||
&& prev.viaId === p.viaId
|
||||
&& prev.enId === p.enId
|
||||
&& prev.serviceId === p.serviceId
|
||||
? null
|
||||
: { viaId: p.viaId, enId: p.enId, serviceId: p.serviceId }
|
||||
))
|
||||
setHighlightedPath(prev => prev && servicePathKey(prev) === servicePathKey(p) ? null : p)
|
||||
}
|
||||
|
||||
function openWanJhSpeedDetail(ev: React.SyntheticEvent<SVGElement>, edge: WanJhEdge) {
|
||||
@@ -2017,8 +2009,8 @@ function NetworkMapContent() {
|
||||
const tablePaths = filterService ? (selectedNestedService ? expandedCountryGroup?.paths ?? [] : destPaths).filter(p => p.serviceId === filterService.id) : destPaths
|
||||
const flowRows = [...tablePaths].sort((a, b) => b.bps - a.bps).slice(0, 100).map(p => ({
|
||||
id: servicePathKey(p),
|
||||
client: p.clientName || p.viaName || p.viaId,
|
||||
exit: p.enName || p.enId,
|
||||
client: p.clientId === "—" ? "Без привязки" : p.clientName,
|
||||
exit: p.enName || p.enId || `IPFIX · ${p.viaName || p.viaId}`,
|
||||
dest: filterService?.label ?? destDisplayLabel(destNodes.find(svc => svc.id === p.serviceId), destMode, p.serviceId),
|
||||
rate: rateOf(p.bytes, p.bps),
|
||||
volume: formatBytes(p.bytes),
|
||||
@@ -2092,7 +2084,7 @@ function NetworkMapContent() {
|
||||
servers={mapServers}
|
||||
tunnels={mapGreTunnels}
|
||||
downRoutes={[...new Set(greEdges.filter((e) => e.tunnel.status === "down").map((e) => `${mapCardName(e.fromServer.name, 999).text} → ${mapCardName(e.toServer.name, 999).text}`))]}
|
||||
exits={[...destEdges.reduce((m, e) => m.set(e.fromId, (m.get(e.fromId) ?? 0) + e.bps), new Map<string, number>())].map(([id, bps]) => ({ name: mapCardName(mapServers.find((s) => s.id === id)?.name ?? id, 999).text, bps }))}
|
||||
exits={[...destEdges.filter(e => !e.observedOnly).reduce((m, e) => m.set(e.fromId, (m.get(e.fromId) ?? 0) + e.bps), new Map<string, number>())].map(([id, bps]) => ({ name: mapCardName(mapServers.find((s) => s.id === id)?.name ?? id, 999).text, bps }))}
|
||||
liveLink={busiestLiveLink}
|
||||
netflowBytes={mapTotalBytes > 0 ? mapTotalBytes : useLiveData && flowReadAt ? 0 : null}
|
||||
windowSec={mapWindowSec}
|
||||
@@ -2286,10 +2278,11 @@ function NetworkMapContent() {
|
||||
</g>
|
||||
))}
|
||||
|
||||
{/* ── Ленты NetFlow: Exit → назначения (толщина — скорость) ── */}
|
||||
{/* Ленты NetFlow от выходов и экспортёров к назначениям. */}
|
||||
{destRibbons.map(({ edge, d, w }) => {
|
||||
const hop = destinationRate(edge)
|
||||
const pathHit = Boolean(highlightedPath && highlightedPath.enId === edge.fromId && highlightedPath.serviceId === edge.toId)
|
||||
const selectedDestinationId = highlightedPath?.serviceId.split("|")[0]
|
||||
const pathHit = Boolean(highlightedPath && (highlightedPath.enId || highlightedPath.viaId) === edge.fromId && selectedDestinationId === edge.toId)
|
||||
const hl = pathHit || (!highlightedPath && (selectedService?.id === edge.toId || selected?.id === edge.fromId || expandedCountryId === edge.toId))
|
||||
const countryDim = !hl && Boolean(expandedCountryGroup) && edge.toId !== expandedCountryId
|
||||
const svc = visibleMapServices.find((s) => s.id === edge.toId)
|
||||
@@ -2297,12 +2290,14 @@ function NetworkMapContent() {
|
||||
const clientLabel = edge.clients?.map((c) => c.name).filter(Boolean).join(", ") || edge.clientName || "—"
|
||||
const rate = hopHasRate(hop) ? ` · ${formatNetflowRate(hop)} (${formatNetflowDir(hop)})` : ""
|
||||
return (
|
||||
<g key={`${edge.fromId}|${edge.toId}`} data-map-ribbon opacity={highlightedPath && !pathHit ? 0.08 : hl ? 0.75 : countryDim ? 0.12 : 0.42}
|
||||
<g key={`${edge.fromId}|${edge.toId}`} data-map-ribbon data-observation={edge.observedOnly || undefined} opacity={highlightedPath && !pathHit ? 0.08 : hl ? 0.75 : countryDim ? 0.12 : 0.42}
|
||||
style={{ transition: "opacity 0.3s", cursor: "pointer" }}
|
||||
onPointerDown={(ev) => { ev.stopPropagation() }}
|
||||
onClick={(ev) => { ev.stopPropagation(); if (svc) selectService(svc) }}>
|
||||
<title>{`${clientLabel} → ${enName} → ${destDisplayLabel(svc, destMode, edge.toId)}${rate}`}</title>
|
||||
<path d={d} fill="none" stroke="var(--chart-4)" strokeWidth={w} />
|
||||
<title>{edge.observedOnly
|
||||
? `Наблюдение IPFIX · ${enName} → ${destDisplayLabel(svc, destMode, edge.toId)}${rate} · выход не подтверждён`
|
||||
: `${clientLabel} → ${enName} → ${destDisplayLabel(svc, destMode, edge.toId)}${rate}`}</title>
|
||||
<path d={d} fill="none" stroke="var(--chart-4)" strokeWidth={w} strokeDasharray={edge.observedOnly ? "7 4" : undefined} />
|
||||
<path d={d} fill="none" stroke="transparent" strokeWidth={Math.max(12, w)} />
|
||||
{showAnimDots && !reducedMotion && hopHasRate(hop) && (
|
||||
<circle r="2.5" fill="var(--foreground)" opacity="0.7" pointerEvents="none">
|
||||
@@ -2809,8 +2804,8 @@ function NetworkMapContent() {
|
||||
</>
|
||||
) : liveSelectedService && (destMode === "services" || selectedNestedService) ? (
|
||||
<ServiceInspector key={liveSelectedService.id} service={liveSelectedService}
|
||||
paths={(selectedNestedService ? expandedCountryGroup?.paths ?? [] : destPaths).filter(p => p.serviceId === liveSelectedService.id).sort((a, b) => b.bps - a.bps)}
|
||||
exits={selectedNestedService ? [] : selectedExitEdges}
|
||||
paths={selectedDestPaths}
|
||||
exits={selectedNestedService ? [] : selectedDestEdges}
|
||||
exitName={id => mapServers.find(s => s.id === id)?.name ?? id}
|
||||
country={selectedNestedService ? expandedCountry?.label : undefined}
|
||||
base={useLiveData ? backendUrl : null} refresh={flowRefresh} windowLabel={mapWindow} flowAt={flowReadAt} stale={Boolean(flowError)}
|
||||
@@ -2896,6 +2891,7 @@ function NetworkMapContent() {
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<InspectorUsers users={serviceUsers(liveSelectedService, selectedDestPaths)} windowLabel={mapWindow} />
|
||||
{expandedCountryGroup && liveSelectedService.id === expandedCountryGroup.countryId && (
|
||||
<div>
|
||||
<p className="text-xs font-semibold text-muted-foreground mb-2">Сервисы в стране</p>
|
||||
@@ -2920,7 +2916,7 @@ function NetworkMapContent() {
|
||||
</div>
|
||||
)}
|
||||
<div>
|
||||
<p className="text-xs font-semibold text-muted-foreground mb-2">Выход</p>
|
||||
<p className="text-xs font-semibold text-muted-foreground mb-2">Выходы и наблюдения</p>
|
||||
<div className="flex flex-col gap-3">
|
||||
{unassignedBytes > 0 && (
|
||||
<div className="flex items-center justify-between text-xs">
|
||||
@@ -2928,16 +2924,13 @@ function NetworkMapContent() {
|
||||
<span className="font-mono">{formatNetflowRate({ bps: liveSelectedService.bps * unassignedBytes / liveSelectedService.bytes })}</span>
|
||||
</div>
|
||||
)}
|
||||
{selectedExitEdges.map((e) => {
|
||||
{selectedDestEdges.map((e) => {
|
||||
const src = mapServers.find((s) => s.id === e.fromId)
|
||||
const enPaths = destPaths
|
||||
.filter((p) => p.serviceId === liveSelectedService.id && p.enId === e.fromId)
|
||||
.slice()
|
||||
.sort((a, b) => b.bps - a.bps)
|
||||
const enPaths = selectedDestPaths.filter(p => (p.enId || p.viaId) === e.fromId)
|
||||
return (
|
||||
<div key={`${e.fromId}|${e.toId}`} className="flex flex-col gap-1.5">
|
||||
<div className="flex items-center justify-between text-xs">
|
||||
<span className="font-mono truncate">{src?.name ?? e.fromId}</span>
|
||||
<span className="font-mono truncate">{src?.name ?? e.fromId}{e.observedOnly && " · IPFIX"}</span>
|
||||
<span className="font-mono text-emerald-400 tabular-nums">
|
||||
{formatNetflowRate({ bytes: e.bytes, bps: e.bps, bpsFwd: e.bpsFwd, bpsRev: e.bpsRev })}
|
||||
</span>
|
||||
@@ -2995,6 +2988,7 @@ function NetworkMapContent() {
|
||||
]} />
|
||||
})()}
|
||||
<NodeHistory key={selected.id} id={selected.id} base={useLiveData ? backendUrl : null} refresh={flowRefresh} degraded={selected.status === "degraded"} />
|
||||
<InspectorUsers users={mapNodeUsers && (mapNodeUsers[selected.id] ?? [])} windowLabel={mapWindow} />
|
||||
{(() => {
|
||||
const res = srvResMap[selected.id]
|
||||
const ram = res?.ramUsed != null && res.ramTotal ? Math.round(res.ramUsed / res.ramTotal * 100) : null
|
||||
|
||||
Reference in new issue
Block a user