fix(ui): интегрировать макет карты сети и трафика
Docker images / prepare-release (push) Successful in 11s
Docker images / backend-test (push) Successful in 3s
Docker images / frontend-image (push) Successful in 2m14s
Docker images / updater-image (push) Successful in 40s
Docker images / netflow-agent-image (push) Successful in 34s
Docker images / backend-image (push) Successful in 16s
Docker images / publish-release (push) Successful in 10s
Docker images / notify-webhook (push) Successful in 1s
Docker images / prepare-release (push) Successful in 11s
Docker images / backend-test (push) Successful in 3s
Docker images / frontend-image (push) Successful in 2m14s
Docker images / updater-image (push) Successful in 40s
Docker images / netflow-agent-image (push) Successful in 34s
Docker images / backend-image (push) Successful in 16s
Docker images / publish-release (push) Successful in 10s
Docker images / notify-webhook (push) Successful in 1s
This commit is contained in:
1 parent
2ca40fbb4d
commit
d174bca5d6
18 files changed
+834
-220
No files matched your search
@@ -0,0 +1,7 @@
|
||||
import type { FlowTalkerDto } from "@mmapp/contracts/traffic-flow"
|
||||
|
||||
export function matchesMapService(row: Pick<FlowTalkerDto, "service" | "category" | "dstCountry">, label: string, country?: string) {
|
||||
const service = row.service === label || row.category === label && (row.service === "Прочее" || ["DNS", "SSH", "BGP"].includes(label))
|
||||
if (!service || !country) return service
|
||||
return country === "unknown" ? !row.dstCountry || row.dstCountry.toLowerCase() === "unknown" : row.dstCountry?.toUpperCase() === country.toUpperCase()
|
||||
}
|
||||
@@ -960,17 +960,16 @@ export function buildGreMapEdges(
|
||||
if (!a || !b) continue
|
||||
if (a.id === b.id) continue
|
||||
|
||||
const la = layerOfServer(a)
|
||||
const lb = layerOfServer(b)
|
||||
if (la == null || lb == null) continue
|
||||
// EN→EN, JH→JH и т.п. на карте не показываем — только межуровневые рёбра.
|
||||
if (la === lb) continue
|
||||
const aIsIx = a.type === "ix-node", bIsIx = b.type === "ix-node"
|
||||
const la = aIsIx ? roleLayer("EN") : layerOfServer(a)
|
||||
const lb = bIsIx ? roleLayer("EN") : layerOfServer(b)
|
||||
if (la == null || lb == null || la === lb && !aIsIx && !bIsIx) continue
|
||||
|
||||
// Строгий поток слева направо: HR → JH → EN.
|
||||
// Если направление туннеля против иерархии — переворачиваем визуальное ребро.
|
||||
let fromServer = a
|
||||
let toServer = b
|
||||
if (la > lb) {
|
||||
if (la > lb || la === lb && a.id > b.id) {
|
||||
fromServer = b
|
||||
toServer = a
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
import type { FlowMapService, FlowMapServiceEdge, FlowMapServicePath } from "@mmapp/contracts/traffic-flow"
|
||||
import type { Server } from "@/lib/data"
|
||||
|
||||
export function isolatedIxServers(servers: Pick<Server, "id" | "type">[], links: readonly (readonly [string, string])[]) {
|
||||
const neighbors = new Map<string, string[]>()
|
||||
for (const [from, to] of links) {
|
||||
neighbors.set(from, [...(neighbors.get(from) ?? []), to])
|
||||
neighbors.set(to, [...(neighbors.get(to) ?? []), from])
|
||||
}
|
||||
const connected = new Set(servers.filter(server => server.type === "jump-host" || server.type === "exit-node").map(server => server.id))
|
||||
for (const id of connected) for (const neighbor of neighbors.get(id) ?? []) connected.add(neighbor)
|
||||
return new Set(servers.filter(server => server.type === "ix-node" && !connected.has(server.id)).map(server => server.id))
|
||||
}
|
||||
|
||||
export function scopeMapDestinations(
|
||||
services: FlowMapService[], edges: FlowMapServiceEdge[], paths: FlowMapServicePath[],
|
||||
includes: (id: string) => boolean, userId?: string, retainUnassigned = false,
|
||||
) {
|
||||
const visiblePaths = paths.filter(path => includes(path.enId || path.viaId) && (!userId || path.clientId === userId))
|
||||
const visibleEdges = userId ? [] : edges.filter(edge => includes(edge.fromId))
|
||||
if (userId) {
|
||||
const bySource = new Map<string, FlowMapServiceEdge>()
|
||||
for (const path of visiblePaths) {
|
||||
const fromId = path.enId || path.viaId
|
||||
const key = JSON.stringify([fromId, path.serviceId, Boolean(path.enId)])
|
||||
const edge = bySource.get(key) ?? {
|
||||
fromId, toId: path.serviceId, bytes: 0, bps: 0, bpsFwd: 0, bpsRev: 0,
|
||||
...(path.enId ? {} : { observedOnly: true as const }),
|
||||
}
|
||||
edge.bytes += path.bytes
|
||||
edge.bps += path.bps
|
||||
bySource.set(key, edge)
|
||||
}
|
||||
visibleEdges.push(...bySource.values())
|
||||
}
|
||||
const totals = new Map<string, { bytes: number; bps: number }>()
|
||||
const allByService = new Map<string, number>()
|
||||
if (retainUnassigned) for (const edge of edges) allByService.set(edge.toId, (allByService.get(edge.toId) ?? 0) + edge.bytes)
|
||||
let bytes = 0
|
||||
for (const edge of visibleEdges) {
|
||||
const total = totals.get(edge.toId) ?? { bytes: 0, bps: 0 }
|
||||
total.bytes += edge.bytes
|
||||
total.bps += edge.bps
|
||||
bytes += edge.bytes
|
||||
totals.set(edge.toId, total)
|
||||
}
|
||||
if (retainUnassigned) for (const service of services) {
|
||||
const unassigned = service.bytes - (allByService.get(service.id) ?? 0)
|
||||
if (unassigned <= 0) continue
|
||||
const total = totals.get(service.id) ?? { bytes: 0, bps: 0 }
|
||||
total.bytes += unassigned
|
||||
total.bps += service.bps * unassigned / service.bytes
|
||||
bytes += unassigned
|
||||
totals.set(service.id, total)
|
||||
}
|
||||
return {
|
||||
services: services.flatMap(service => {
|
||||
const total = totals.get(service.id)
|
||||
return total ? [{ ...service, ...total, share: bytes ? total.bytes / bytes : 0 }] : []
|
||||
}).sort((a, b) => b.bytes - a.bytes || a.label.localeCompare(b.label)),
|
||||
edges: visibleEdges,
|
||||
paths: visiblePaths,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user