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

Function verifyServiceRestart

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

Source from the content-addressed store, hash-verified

7815 });
7816 sel.dataset.filled = '1';
7817 }).catch(() => {});
7818}
7819async function runArpCheck() {
7820 const out = document.getElementById('arp-results');
7821 if (!out) return;
7822 const btn = (typeof event !== 'undefined' && event && event.target) ? event.target : null;
7823 const ifaceSel = document.getElementById('arp-check-iface');
7824 const iface = ifaceSel && ifaceSel.value ? ifaceSel.value : '';
7825 _ndBusy(btn, true, 'Checking…');
7826 out.classList.remove('hidden');
7827 out.innerHTML = '<p class="text-sm text-gray-400">Reading neighbour table…</p>';
7828 try {
7829 _arpFillIfaces();
7830 const d = await fetchAPI('/api/net/arp-check' + (iface ? '?interface=' + encodeURIComponent(iface) : ''));
7831 if (!d || d.success === false) {
7832 out.innerHTML = '<p class="text-sm text-red-400">Error: ' + escapeHtml((d && d.error) || 'failed') + '</p>';
7833 return;
7834 }
7835 const [cls, label] = _ARP_VERDICT_STYLE[d.verdict] || _ARP_VERDICT_STYLE.unknown;
7836 const gw = d.gateway || {};
7837 const mismatch = gw.baseline && gw.mac && gw.baseline !== gw.mac;
7838 let html = `<div class="mb-2 px-3 py-2 rounded border ${cls} text-sm">${label}</div>`;
7839 html += '<table class="min-w-full text-sm text-gray-300 whitespace-nowrap"><tbody>' +
7840 `<tr class="border-t border-slate-800"><td class="px-3 py-1.5 text-gray-500">Interface</td><td class="px-3 py-1.5 font-mono">${escapeHtml(d.interface || 'default route')}</td></tr>` +
7841 `<tr class="border-t border-slate-800"><td class="px-3 py-1.5 text-gray-500">Gateway</td><td class="px-3 py-1.5 font-mono">${escapeHtml(gw.ip || '—')}</td></tr>` +
7842 `<tr class="border-t border-slate-800"><td class="px-3 py-1.5 text-gray-500">Current MAC</td><td class="px-3 py-1.5 font-mono ${mismatch ? 'text-red-400' : ''}">${escapeHtml(gw.mac || '—')}</td></tr>` +
7843 `<tr class="border-t border-slate-800"><td class="px-3 py-1.5 text-gray-500">Trusted MAC</td><td class="px-3 py-1.5 font-mono">${escapeHtml(gw.baseline || '—')}${gw.learned ? ' <span class="text-xs text-gray-500">(learned now)</span>' : ''}</td></tr>` +
7844 (gw.fhrp_shape ? `<tr class="border-t border-slate-800"><td class="px-3 py-1.5 text-gray-500">FHRP</td><td class="px-3 py-1.5">${escapeHtml(gw.fhrp_shape)} virtual MAC ${gw.fhrp_confirmed ? '<span class="text-green-400">✓ confirmed (expected HSRP/VRRP gateway)</span>' : '<span class="text-amber-300">shape match — confirm via FHRP Watch</span>'}</td></tr>` : '') +
7845 `<tr class="border-t border-slate-800"><td class="px-3 py-1.5 text-gray-500">Neighbours</td><td class="px-3 py-1.5">${d.neighbor_count != null ? d.neighbor_count : '—'}</td></tr>` +
7846 '</tbody></table>';
7847 if (d.impersonators && d.impersonators.length) {
7848 html += '<p class="text-xs text-gray-400 mt-2">One MAC answering for many IPs:</p><ul class="text-xs text-gray-400 list-disc pl-5">' +
7849 d.impersonators.map(i => {
7850 const ips = i.ips || [];
7851 return '<li class="font-mono">' + escapeHtml(i.mac) + ' → ' + escapeHtml(ips.slice(0, 6).join(', ')) + (ips.length > 6 ? '…' : '') + '</li>';
7852 }).join('') + '</ul>';
7853 }
7854 if (d.reasons && d.reasons.length) {
7855 html += '<ul class="text-xs text-gray-400 mt-2 list-disc pl-5">' +
7856 d.reasons.map(r => '<li>' + escapeHtml(r) + '</li>').join('') + '</ul>';
7857 }
7858 out.innerHTML = html;
7859 } catch (e) {
7860 out.innerHTML = '<p class="text-sm text-red-400">Failed: ' + escapeHtml(e.message) + '</p>';
7861 } finally {
7862 _ndBusy(btn, false);
7863 }
7864}
7865
7866// ---- DHCP Guardian card (rogue DHCP + starvation, detection-only) ----------
7867const _DHCP_VERDICT_STYLE = {
7868 clean: ['bg-green-950/40 border-green-900 text-green-400', '✓ No rogue DHCP server or starvation detected'],
7869 suspicious: ['bg-amber-950/50 border-amber-800 text-amber-300', '⚠ DHCP anomaly — review below'],
7870 rogue: ['bg-red-950/60 border-red-800 text-red-300', '🛑 Rogue / fake DHCP server detected'],
7871 starvation: ['bg-red-950/60 border-red-800 text-red-300', '🛑 DHCP starvation (pool-exhaustion) detected'],
7872 unknown: ['bg-slate-800 border-slate-700 text-slate-400', '— Could not determine'],
7873};
7874function _dhcpFillIfaces() {

Callers 2

performUpdateFunction · 0.70
autoStashAndUpdateFunction · 0.70

Calls 3

checkServiceFunction · 0.85
addConsoleMessageFunction · 0.70
updateElementFunction · 0.70

Tested by

no test coverage detected