| 12725 | const d = await fetchAPI('/api/net/bgp-watch' + qs); |
| 12726 | if (!d || d.success === false) { |
| 12727 | const msg = (d && d.error) || 'failed'; |
| 12728 | let extra = ''; |
| 12729 | if (d && d.missing_tool) extra = ' <button onclick="installNetTool(\'tcpdump\', this, runBgpWatch)" class="ml-2 underline text-cyan-400">Install tcpdump</button>'; |
| 12730 | out.innerHTML = '<p class="text-sm text-red-400">Error: ' + escapeHtml(msg) + extra + '</p>'; |
| 12731 | return; |
| 12732 | } |
| 12733 | const [cls, label] = _BGP_VERDICT_STYLE[d.verdict] || _BGP_VERDICT_STYLE.unknown; |
| 12734 | let html = `<div class="mb-2 px-3 py-2 rounded border ${cls} text-sm">${label}</div>`; |
| 12735 | html += `<p class="text-xs text-gray-500 mb-2">Interface: ${escapeHtml(d.interface || '—')} · ${d.seconds}s · ${d.messages} BGP msgs (${d.updates} UPDATE @ ${d.update_per_s}/s, ${d.notifications} NOTIFICATION) · ${d.prefix_total} prefixes${d.learned ? ' · <span class="text-gray-400">baseline learned now</span>' : ''}</p>`; |
| 12736 | if (d.note) html += `<p class="text-xs text-gray-500 mb-2">${escapeHtml(d.note)}</p>`; |
| 12737 | if (d.enrich_note) html += `<p class="text-xs text-gray-500 mb-2">${escapeHtml(d.enrich_note)}</p>`; |
| 12738 | const asnNames = d.asn_names || {}; |
| 12739 | if (d.peers && d.peers.length) { |
| 12740 | const tp = d.trusted_peers || []; |
| 12741 | html += `<p class="text-xs mb-1 text-gray-400">Peers: ` + |
| 12742 | d.peers.map(a => { |
| 12743 | const nm = asnNames[a] ? ` <span class="text-gray-500">(${escapeHtml(asnNames[a])})</span>` : ''; |
| 12744 | return `<span class="font-mono ${tp.length && tp.indexOf(a) < 0 ? 'text-amber-300' : 'text-gray-200'}">AS${a}</span>${nm}`; |
| 12745 | }).join(', ') + |