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

Function initializeSocket

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

Source from the content-addressed store, hash-verified

610 return ipv4Pattern.test(ip.trim());
611}
612
613document.addEventListener('DOMContentLoaded', function() {
614 initializeSocket();
615 initializeTabs();
616 initializeMobileMenu();
617 loadInitialData();
618 setupAutoRefresh();
619 setupEpaperAutoRefresh();
620 setupEventListeners();
621 initializeThreatIntelFilters();
622 initializePwnUI();
623 initializePwnagotchiVisibility();
624 handleHeadlessMode();
625 applyRusenseTabVisibility();
626 applyTerminalVisibility();
627 applyMeshTabVisibility();
628 // localStorage gave us an instant paint above; now reconcile with the
629 // server (the shared source of truth) without blocking startup.
630 syncRusenseTabFromServer();
631 syncTerminalFromServer();
632 syncMeshTabFromServer();
633
634});
635
636
637function initializeSocket() {
638 socket = io({
639 reconnection: true,
640 reconnectionDelay: 1000,
641 reconnectionDelayMax: RECONNECT_DELAY_MAX
642 });
643
644 socket.on('connect', function() {
645 console.log('Connected to Ragnar server');
646 updateConnectionStatus(true);
647 reconnectAttempts = 0;
648 addConsoleMessage('Connected to Ragnar server', 'success');
649
650 socket.emit('request_status');
651 socket.emit('request_logs');
652 refreshPwnagotchiStatus({ silent: true });
653 });
654
655 socket.on('connected', function(data) {
656 // Server sends auth_configured flag on every socket connect
657 if (data && typeof data.auth_configured !== 'undefined') {
658 const show = data.auth_configured;
659 const logoutBtn = document.getElementById('logout-btn');
660 if (logoutBtn) logoutBtn.classList.toggle('hidden', !show);
661 const mobileLogoutBtn = document.getElementById('mobile-logout-btn');
662 if (mobileLogoutBtn) mobileLogoutBtn.classList.toggle('hidden', !show);
663 }
664 });
665
666 socket.on('disconnect', function() {
667 console.log('Disconnected from Ragnar server');
668 updateConnectionStatus(false);
669 addConsoleMessage('Disconnected from server', 'error');

Callers 1

ragnar_modern.jsFile · 0.70

Calls 15

BooleanClass · 0.85
emitMethod · 0.80
errorMethod · 0.80
updateConnectionStatusFunction · 0.70
addConsoleMessageFunction · 0.70
refreshPwnagotchiStatusFunction · 0.70
updateDashboardStatusFunction · 0.70
updateConsoleFunction · 0.70
updatePwnagotchiUIFunction · 0.70
formatPwnStateLabelFunction · 0.70
loadStableNetworkDataFunction · 0.70
displayCredentialsTableFunction · 0.70

Tested by

no test coverage detected