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

Function renderWifiInterfaceSwitch

web/scripts/ragnar_modern.js:8921–8969  ·  view source on GitHub ↗
(interfaces = [])

Source from the content-addressed store, hash-verified

8919 if (action === 'start') {
8920 const body = {
8921 action: 'start',
8922 peer_ip: (document.getElementById('bgpc-peer').value || '').trim(),
8923 peer_as: parseInt(document.getElementById('bgpc-peeras').value, 10),
8924 local_as: parseInt(document.getElementById('bgpc-localas').value, 10),
8925 router_id: (document.getElementById('bgpc-rid').value || '').trim(),
8926 };
8927 d = await postAPI('/api/net/bgp-collector', body);
8928 } else {
8929 d = await postAPI('/api/net/bgp-collector', { action });
8930 }
8931 if (!out) return;
8932 if (!d.success) { out.innerHTML = '<span class="text-red-300">' + escapeHtml(d.error || 'failed') + '</span>'; return; }
8933 if (action === 'rib') {
8934 const rib = d.rib || { total: 0, routes: [] };
8935 let h = '<div class="text-xs text-gray-400 mb-1">RIB: ' + rib.total + ' prefixes · session ' + escapeHtml(d.state || '?') + '</div>';
8936 if (rib.routes && rib.routes.length) {
8937 h += '<table class="w-full text-xs"><tr class="text-gray-500 text-left"><th class="pr-3">Prefix</th><th class="pr-3">Origin AS</th><th class="pr-3">AS-path</th><th>Flapping</th></tr>';
8938 for (const r of rib.routes) {
8939 h += '<tr><td class="pr-3 font-mono">' + escapeHtml(r.prefix) + '</td><td class="pr-3">' + escapeHtml(String(r.origin_as ?? '?')) + '</td><td class="pr-3 font-mono text-gray-400">' + escapeHtml((r.as_path || []).join(' ')) + '</td><td>' + (r.flapping ? '<span class="text-red-300">yes</span>' : '<span class="text-gray-500">no</span>') + '</td></tr>';
8940 }
8941 h += '</table>';
8942 } else { h += '<div class="text-gray-500 text-xs">no prefixes learned yet</div>'; }
8943 out.innerHTML = h;
8944 return;
8945 }
8946 const st = (d.status || {});
8947 const cls = _BGP_STATE_STYLE[st.state] || 'text-gray-400';
8948 let h = '<div>Session: <span class="' + cls + ' font-semibold">' + escapeHtml(st.state || 'Idle') + '</span>';
8949 if (st.peer_ip) h += ' <span class="text-gray-400">peer ' + escapeHtml(st.peer_ip) + ' AS' + escapeHtml(String(st.peer_as ?? '?')) + '</span>';
8950 if (st.rib && typeof st.rib.total === 'number') h += ' · <span class="text-gray-400">' + st.rib.total + ' prefixes' + (st.rib.flapping ? ', ' + st.rib.flapping + ' flapping' : '') + '</span>';
8951 h += '</div>';
8952 if (action === 'start') addConsoleMessage('BGP collector starting toward ' + (st.peer_ip || '?') + ' (receive-only)', 'info');
8953 if (action === 'stop') addConsoleMessage('BGP collector stopped', 'info');
8954 out.innerHTML = h;
8955 } catch (e) {
8956 if (out) out.innerHTML = '<span class="text-red-300">' + escapeHtml(e.message) + '</span>';
8957 }
8958}
8959async function owdReflector(action) {
8960 const span = document.getElementById('owd-reflector-status');
8961 try {
8962 const d = await postAPI('/api/net/owd-reflector', { action });
8963 if (!span) return;
8964 if (!d.success) { span.innerHTML = '<span class="text-red-300">' + escapeHtml(d.error || 'failed') + '</span>'; return; }
8965 if (d.running || d.already_running) span.innerHTML = '<span class="text-green-400">reflecting on udp/' + (d.port || '?') + '</span>';
8966 else span.innerHTML = '<span class="text-gray-500">stopped</span>';
8967 } catch (e) { if (span) span.innerHTML = '<span class="text-red-300">' + escapeHtml(e.message) + '</span>'; }
8968}
8969async function runPathAsymmetry() {
8970 const out = document.getElementById('pa-results');
8971 if (!out) return;
8972 const target = (document.getElementById('pa-target').value || '').trim();

Callers 2

refreshWifiStatusFunction · 0.70
loadWifiInterfacesFunction · 0.70

Calls 5

filterMethod · 0.80
setWifiInterfaceMetadataFunction · 0.70
getActiveWifiInterfaceFunction · 0.70
setSelectedWifiInterfaceFunction · 0.70

Tested by

no test coverage detected