fix(api): показывать подтверждённые метрики OSPF
This commit is contained in:
1 parent
e3791f3496
commit
af05ad5cda
13 files changed
+120
-55
No files matched your search
+2
-2
@@ -1,10 +1,10 @@
|
||||
type InterfaceCost = { serverId: number; interface: string; areaId: string; cost: number }
|
||||
type InterfaceCost = { serverId: number; interface: string; areaId: string; cost: number | null }
|
||||
export const ospfCostKey = (serverId: number, iface: string, areaId: string) => JSON.stringify([serverId, iface, areaId])
|
||||
export function buildOspfCostIndex(interfaces: InterfaceCost[]): Map<string, number | null> {
|
||||
const result = new Map<string, number | null>()
|
||||
for (const iface of interfaces) {
|
||||
const key = ospfCostKey(iface.serverId, iface.interface, iface.areaId)
|
||||
const cost = Number.isInteger(iface.cost) && iface.cost >= 1 && iface.cost <= 65535 ? iface.cost : null
|
||||
const cost = iface.cost !== null && Number.isInteger(iface.cost) && iface.cost >= 0 && iface.cost <= 65535 ? iface.cost : null
|
||||
result.set(key, result.has(key) && result.get(key) !== cost ? null : cost)
|
||||
}
|
||||
return result
|
||||
|
||||
Reference in new issue
Block a user