MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / populateAirSnitchInterfaceDropdowns

Function populateAirSnitchInterfaceDropdowns

web/scripts/ragnar_modern.js:10660–10708  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10658 const d = await fetchAPI('/api/net/oam-watch' + qs);
10659 if (!d || d.success === false) {
10660 const msg = (d && d.error) || 'failed';
10661 let extra = '';
10662 if (d && d.missing_tool) extra = ' <button onclick="installNetTool(\'tcpdump\', this, runOamWatch)" class="ml-2 underline text-cyan-400">Install tcpdump</button>';
10663 out.innerHTML = '<p class="text-sm text-red-400">Error: ' + escapeHtml(msg) + extra + '</p>';
10664 return;
10665 }
10666 const [cls, label] = _OAM_VERDICT_STYLE[d.verdict] || _OAM_VERDICT_STYLE.unknown;
10667 let html = `<div class="mb-2 px-3 py-2 rounded border ${cls} text-sm">${label}</div>`;
10668 html += `<p class="text-xs text-gray-500 mb-2">Interface: ${escapeHtml(d.interface || '—')} · ${d.seconds}s · ${d.packet_count} OAMPDU(s) · ${(d.peers || []).length} peer(s)</p>`;
10669 const findings = d.findings || [];
10670 if (findings.length) {
10671 html += '<table class="min-w-full text-xs text-gray-300 whitespace-nowrap"><thead>' +
10672 '<tr class="text-left text-gray-500"><th class="px-2 py-1">Sev</th><th class="px-2 py-1">Code</th><th class="px-2 py-1">What</th><th class="px-2 py-1">Source MAC</th><th class="px-2 py-1">#</th></tr>' +
10673 '</thead><tbody>' +
10674 findings.slice(0, 40).map(f => {
10675 const sc = _OAM_SEV_STYLE[f.severity] || 'text-gray-400';
10676 return `<tr class="border-t border-slate-800">
10677 <td class="px-2 py-1 ${sc}">${escapeHtml(f.severity || '')}</td>
10678 <td class="px-2 py-1 font-mono ${sc}">${escapeHtml(f.code || '')}</td>
10679 <td class="px-2 py-1 text-gray-300 whitespace-normal" style="min-width:16rem">${escapeHtml(f.name || '')} <span class="text-gray-600">${escapeHtml(f.klass || '')}</span><span class="block text-gray-500">${escapeHtml(f.detail || '')}</span></td>
10680 <td class="px-2 py-1 font-mono text-gray-400">${escapeHtml(f.src || '')}</td>
10681 <td class="px-2 py-1 font-mono text-gray-400">${f.count}</td>
10682 </tr>`; }).join('') +
10683 '</tbody></table>';
10684 }
10685 const peers = d.peers || [];
10686 if (peers.length) {
10687 html += '<div class="text-xs text-gray-500 mt-3 mb-1">OAM peers (session state kept across scans)</div>' +
10688 '<table class="min-w-full text-xs text-gray-300 whitespace-nowrap"><thead>' +
10689 '<tr class="text-left text-gray-500"><th class="px-2 py-1">Source MAC</th><th class="px-2 py-1">OUI</th><th class="px-2 py-1">Capabilities</th><th class="px-2 py-1">State</th><th class="px-2 py-1">PDUs</th></tr>' +
10690 '</thead><tbody>' +
10691 peers.slice(0, 20).map(p => {
10692 const st = p.remote_loopback ? '<span class="text-red-300">remote loopback</span>' : (p.operational ? '<span class="text-green-400">operational</span>' : '<span class="text-gray-400">discovery</span>');
10693 return `<tr class="border-t border-slate-800">
10694 <td class="px-2 py-1 font-mono text-gray-200">${escapeHtml(p.src)}</td>
10695 <td class="px-2 py-1 font-mono text-gray-400">${escapeHtml(p.oui || '—')}</td>
10696 <td class="px-2 py-1 text-amber-300/90">${escapeHtml((p.capabilities || []).join(', ') || '—')}</td>
10697 <td class="px-2 py-1">${st}</td>
10698 <td class="px-2 py-1 font-mono text-gray-400">${p.pdus}</td>
10699 </tr>`; }).join('') +
10700 '</tbody></table>';
10701 }
10702 if (d.reasons && d.reasons.length) {
10703 html += '<ul class="text-xs text-gray-400 mt-2 list-disc pl-5">' +
10704 d.reasons.map(r => '<li>' + escapeHtml(r) + '</li>').join('') + '</ul>';
10705 }
10706 out.innerHTML = html;
10707 } catch (e) {
10708 out.innerHTML = '<p class="text-sm text-red-400">Failed: ' + escapeHtml(e.message) + '</p>';
10709 } finally {
10710 _ndBusy(btn, false);
10711 }

Callers 1

loadTabDataFunction · 0.70

Calls 2

pushMethod · 0.80
fetchAPIFunction · 0.70

Tested by

no test coverage detected