|
|
@@ -819,9 +819,9 @@ export function buildTopologyModel({ routers, devices, wan, wireguard, distribut
|
|
|
// junto al enlace WAN), no como cliente LAN. La semántica server ya lo
|
|
|
// excluye de los anillos; aquí se excluye de la lista online para el
|
|
|
// fallback sin semántica y se reserva el device para el chip.
|
|
|
- const wanPeerDev = devices.find(
|
|
|
- (d) => d.online && wan.gateway && d.ip && d.ip === wan.gateway,
|
|
|
- )
|
|
|
+ const wanPeerDev =
|
|
|
+ devices.find((d) => d.online && d.wanSide) ??
|
|
|
+ devices.find((d) => d.online && wan.gateway && d.ip && d.ip === wan.gateway)
|
|
|
// Chip del wan peer, creado tras fijar la posición final de Internet.
|
|
|
let wanPeerChip: ChipNode | null = null
|
|
|
const online = devices.filter(
|
|
|
@@ -1119,7 +1119,7 @@ export function buildTopologyModel({ routers, devices, wan, wireguard, distribut
|
|
|
const gwTop = { x: gatewayNode.x, y: gatewayNode.y - gatewayNode.r }
|
|
|
const mx = (internetNode.x + gwTop.x) / 2
|
|
|
const my = (internetNode.y + gwTop.y) / 2
|
|
|
- wanPeerChip = { ...mkChip(wanPeerDev, 'internet'), x: mx + 46, y: my }
|
|
|
+ wanPeerChip = { ...mkChip(wanPeerDev, 'internet'), x: mx, y: my }
|
|
|
chips.push(wanPeerChip)
|
|
|
}
|
|
|
// APs y switches: a lo largo del vector desde el gateway hasta su posición
|
|
|
@@ -1457,6 +1457,20 @@ export function buildTopologyModel({ routers, devices, wan, wireguard, distribut
|
|
|
from: dv.node.parent ?? dv.node.routerId, to: dv.id,
|
|
|
})
|
|
|
}
|
|
|
+ // #1485/#1495: con semántica del server, el enlace wan-peer llega en
|
|
|
+ // topology.links; el chip debe existir ANTES de chipById o el enlace
|
|
|
+ // quedaría colgando de un extremo inexistente (pasaba en flotas PPPoE,
|
|
|
+ // donde el fallback por IP no casa y solo la semántica conoce el peer).
|
|
|
+ if (
|
|
|
+ !wanPeerChip && wanPeerDev && gatewayNode &&
|
|
|
+ (topology?.links ?? []).some((l) => l.kind === 'wan-peer')
|
|
|
+ ) {
|
|
|
+ const gwTop = { x: gatewayNode.x, y: gatewayNode.y - gatewayNode.r }
|
|
|
+ const mx = (internetNode.x + gwTop.x) / 2
|
|
|
+ const my = (internetNode.y + gwTop.y) / 2
|
|
|
+ wanPeerChip = { ...mkChip(wanPeerDev, 'internet'), x: mx, y: my }
|
|
|
+ chips.push(wanPeerChip)
|
|
|
+ }
|
|
|
const chipById = new Map(chips.map((c) => [c.id, c]))
|
|
|
const hubPos = (hubId: string): { x: number; y: number; r: number } | null => {
|
|
|
const rn = routerById.get(hubId)
|
|
|
@@ -1540,6 +1554,19 @@ export function buildTopologyModel({ routers, devices, wan, wireguard, distribut
|
|
|
from: sl.from, to: sl.to,
|
|
|
}
|
|
|
}
|
|
|
+ case 'wan-peer': {
|
|
|
+ // #1485/#1495: el chip ya se creó antes de chipById; aquí solo se
|
|
|
+ // dibuja el enlace Internet↔chip que emite la semántica.
|
|
|
+ if (!gatewayNode || !wanPeerChip) return null
|
|
|
+ const a = pos(internetNode.x, internetNode.y, angleTo(internetNode.x, internetNode.y, wanPeerChip.x, wanPeerChip.y), internetNode.r + 2)
|
|
|
+ return {
|
|
|
+ id: 'wan-peer', kind: 'wan-peer',
|
|
|
+ d: `M ${a.x} ${a.y} L ${wanPeerChip.x} ${wanPeerChip.y}`,
|
|
|
+ lx: 0, ly: 0, label: '',
|
|
|
+ width: 1.5, ...flowFor(30),
|
|
|
+ from: 'internet', to: wanPeerChip.id,
|
|
|
+ }
|
|
|
+ }
|
|
|
case 'uplink': {
|
|
|
const i = apNodes.findIndex((n) => n.id === sl.to)
|
|
|
const node = i >= 0 ? apNodes[i] : routerById.get(sl.to)
|