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

Function pairBluetoothDevice

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

Source from the content-addressed store, hash-verified

9987 out.innerHTML = '<p class="text-sm text-red-400">Failed: ' + escapeHtml(e.message) + '</p>';
9988 } finally {
9989 _ndBusy(btn, false);
9990 }
9991}
9992async function stpTrustBaseline() {
9993 try {
9994 await postAPI('/api/net/stp-baseline', { action: 'reset' });
9995 addConsoleMessage('STP baseline reset — re-learning current root(s) & bridges', 'info');
9996 await runStpWatch();
9997 } catch (e) {
9998 addConsoleMessage('Failed to reset STP baseline: ' + e.message, 'error');
9999 }
10000}
10001
10002// ---- MRP Watch (MVRP / MMRP / GVRP / GMRP registration protocols) ----
10003const _MRP_VERDICT_STYLE = {
10004 clean: ['bg-green-950/40 border-green-900 text-green-400', '✓ No MVRP / MMRP / GVRP / GMRP registration traffic observed'],
10005 observed: ['bg-sky-950/40 border-sky-900 text-sky-300', 'ℹ Registration protocol(s) in use — inventory only, nothing abusive'],
10006 suspicious: ['bg-amber-950/50 border-amber-800 text-amber-300', '⚠ Registration burst / structural anomaly — possible VLAN-hopping setup'],
10007 attack: ['bg-red-950/60 border-red-800 text-red-300', '🛑 LeaveAll flood — forced network-wide re-registration (the standards-based VTP bomb)'],
10008 unknown: ['bg-slate-800 border-slate-700 text-slate-400', '— Could not determine'],
10009};
10010const _MRP_SEV_STYLE = { high: 'text-red-300', medium: 'text-amber-300', low: 'text-sky-300', info: 'text-gray-400' };
10011function _mrpFillIfaces() {
10012 const sel = document.getElementById('mrp-iface');
10013 if (!sel || sel.dataset.filled === '1') return Promise.resolve();
10014 return fetchAPI('/api/net/interfaces').then(x => {
10015 (x.interfaces || []).forEach(i => {
10016 const o = document.createElement('option');
10017 o.value = i.name;
10018 const tag = i.type === 'wifi' ? ' (WiFi)' : i.type === 'ethernet' ? ' (LAN)' : (i.type ? ' (' + i.type + ')' : '');
10019 o.textContent = i.name + tag;
10020 sel.appendChild(o);
10021 });
10022 sel.dataset.filled = '1';
10023 }).catch(() => {});
10024}
10025async function runMrpWatch() {
10026 const out = document.getElementById('mrp-results');
10027 if (!out) return;
10028 const btn = (typeof event !== 'undefined' && event && event.target) ? event.target : null;
10029 const iface = (document.getElementById('mrp-iface') || {}).value || '';
10030 const secs = (document.getElementById('mrp-secs') || {}).value || '20';
10031 const kv = ((document.getElementById('mrp-known-vlans') || {}).value || '').trim();
10032 _ndBusy(btn, true, 'Listening…');
10033 out.classList.remove('hidden');
10034 out.innerHTML = '<p class="text-sm text-gray-400">Passively capturing MVRP / MMRP / GVRP / GMRP…</p>';
10035 try {
10036 _mrpFillIfaces();
10037 let qs = '?seconds=' + encodeURIComponent(secs) + (iface ? '&interface=' + encodeURIComponent(iface) : '');
10038 if (kv) qs += '&known_vlans=' + encodeURIComponent(kv);
10039 const d = await fetchAPI('/api/net/mrp-watch' + qs);
10040 if (!d || d.success === false) {
10041 let extra = '';
10042 if (d && d.missing_tool) extra = ' <button onclick="installNetTool(\'tcpdump\', this, runMrpWatch)" class="ml-2 underline text-cyan-400">Install tcpdump</button>';
10043 out.innerHTML = '<p class="text-sm text-red-400">Error: ' + escapeHtml((d && d.error) || 'failed') + extra + '</p>';
10044 return;
10045 }
10046 const [cls, label] = _MRP_VERDICT_STYLE[d.verdict] || _MRP_VERDICT_STYLE.unknown;

Callers

nothing calls this directly

Calls 5

errorMethod · 0.80
fetchAPIFunction · 0.70
addConsoleMessageFunction · 0.70
displayBluetoothDevicesFunction · 0.70

Tested by

no test coverage detected