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

Function applyHardwareProfile

web/scripts/ragnar_modern.js:7404–7433  ·  view source on GitHub ↗
(profileId)

Source from the content-addressed store, hash-verified

7402 (x.interfaces || []).forEach(i => {
7403 const o = document.createElement('option');
7404 o.value = i.name;
7405 const tag = i.type === 'wifi' ? ' (WiFi)' : i.type === 'ethernet' ? ' (LAN)' : (i.type ? ' (' + i.type + ')' : '');
7406 o.textContent = i.name + tag;
7407 sel.appendChild(o);
7408 });
7409 sel.dataset.filled = '1';
7410 }).catch(() => {});
7411}
7412async function runSnmpWatch() {
7413 const out = document.getElementById('snmp-results');
7414 if (!out) return;
7415 const btn = (typeof event !== 'undefined' && event && event.target) ? event.target : null;
7416 const ifaceSel = document.getElementById('snmp-iface');
7417 const iface = ifaceSel && ifaceSel.value ? ifaceSel.value : '';
7418 const secsEl = document.getElementById('snmp-secs');
7419 const secs = secsEl && secsEl.value ? secsEl.value : '12';
7420 _ndBusy(btn, true, 'Listening…');
7421 out.classList.remove('hidden');
7422 out.innerHTML = '<p class="text-sm text-gray-400">Passively capturing SNMP (UDP 161/162) on the segment…</p>';
7423 try {
7424 _snmpFillIfaces();
7425 const qs = '?seconds=' + encodeURIComponent(secs) + (iface ? '&interface=' + encodeURIComponent(iface) : '');
7426 const d = await fetchAPI('/api/net/snmp-watch' + qs);
7427 if (!d || d.success === false) {
7428 const msg = (d && d.error) || 'failed';
7429 let extra = '';
7430 if (d && d.missing_tool) extra = ' <button onclick="installNetTool(\'tcpdump\', this, runSnmpWatch)" class="ml-2 underline text-cyan-400">Install tcpdump</button>';
7431 out.innerHTML = '<p class="text-sm text-red-400">Error: ' + escapeHtml(msg) + extra + '</p>';
7432 return;
7433 }
7434 const [cls, label] = _SNMP_VERDICT_STYLE[d.verdict] || _SNMP_VERDICT_STYLE.unknown;
7435 let html = `<div class="mb-2 px-3 py-2 rounded border ${cls} text-sm">${label}</div>`;
7436 html += `<p class="text-xs text-gray-500 mb-2">Interface: ${escapeHtml(d.interface || '—')} · ${d.snmp_count} msgs (${d.rate}/s) · ${d.insecure ? '<span class="text-red-300">insecure v1/v2c present</span>' : 'v3-only'}${d.learned ? ' · <span class="text-gray-400">baseline learned now</span>' : ''}</p>`;

Callers 2

detectAndApplyHardwareFunction · 0.70
confirmApplyProfileFunction · 0.70

Calls 5

errorMethod · 0.80
addConsoleMessageFunction · 0.70
postAPIFunction · 0.70
displayCurrentProfileFunction · 0.70
restartServiceFunction · 0.70

Tested by

no test coverage detected