import React, { useState, useEffect } from 'react'; import { Card, CardContent, CardHeader, CardTitle } from './ui/card'; import { Button } from './ui/button'; import { AlertCircle, CheckCircle2, ExternalLink, Globe, Info, MonitorPlay, Server, ShieldAlert, Wifi } from 'lucide-react'; export default function SystemDiagnostics() { const [diagnostics, setDiagnostics] = useState({ isIframe: false, hasWebUSB: false, hasWebBluetooth: false, userAgent: '', screenSize: '', network: { online: navigator.onLine, type: (navigator as any).connection?.effectiveType || 'unknown', downlink: (navigator as any).connection?.downlink || 0, rtt: (navigator as any).connection?.rtt || 0, } }); const [networkChecks, setNetworkChecks] = useState({ dns: { status: 'pending', detail: 'Checking DNS resolution...' }, outbound: { status: 'pending', detail: 'Checking outbound connectivity...' }, local: { status: 'pending', detail: 'Checking local dev server...' }, }); useEffect(() => { setDiagnostics(prev => ({ ...prev, isIframe: window.self !== window.top, hasWebUSB: 'usb' in navigator, hasWebBluetooth: 'bluetooth' in navigator, userAgent: navigator.userAgent, screenSize: `${window.innerWidth}x${window.innerHeight}`, })); // Run Network Checks const runChecks = async () => { // 1. DNS Check (via Cloudflare DoH) try { const start = Date.now(); const res = await fetch('https://cloudflare-dns.com/dns-query?name=google.com&type=A', { headers: { 'accept': 'application/dns-json' } }); if (res.ok) { setNetworkChecks(prev => ({ ...prev, dns: { status: 'success', detail: `Resolved google.com in ${Date.now() - start}ms` } })); } else { throw new Error(); } } catch { setNetworkChecks(prev => ({ ...prev, dns: { status: 'error', detail: 'DNS Resolution Failed (DoH Blocked)' } })); } // 2. Outbound Check try { const res = await fetch('https://www.google.com/favicon.ico', { mode: 'no-cors' }); setNetworkChecks(prev => ({ ...prev, outbound: { status: 'success', detail: 'Outbound HTTPS (443) Reachable' } })); } catch { setNetworkChecks(prev => ({ ...prev, outbound: { status: 'error', detail: 'Outbound Traffic Restricted' } })); } // 3. Local Check try { const res = await fetch(window.location.origin + '/favicon.ico', { mode: 'no-cors' }); setNetworkChecks(prev => ({ ...prev, local: { status: 'success', detail: `Local Server (${window.location.port}) Reachable` } })); } catch { setNetworkChecks(prev => ({ ...prev, local: { status: 'error', detail: 'Local Connectivity Blocked' } })); } }; runChecks(); }, []); return (

System Diagnostics & Debugger

Environment Context
{diagnostics.isIframe ? ( ) : ( )} {diagnostics.isIframe ? 'Running in iFrame (Restricted)' : 'Top-level Window (Unrestricted)'}
{diagnostics.isIframe && (

Hardware APIs like WebUSB and WebBluetooth are often blocked inside iframes. Open the app in a new tab to use RTL-SDR.

)}
WebUSB (RTL-SDR)
{diagnostics.hasWebUSB ? ( ) : ( )} {diagnostics.hasWebUSB ? 'Supported' : 'Not Supported'}

Required for RTL-SDR hardware integration.

Web Bluetooth
{diagnostics.hasWebBluetooth ? ( ) : ( )} {diagnostics.hasWebBluetooth ? 'Supported' : 'Not Supported'}

Required for BLE scanning fallback.

Network Security & Connectivity
Interface
Status {diagnostics.network.online ? 'Online' : 'Offline'}
Type {diagnostics.network.type}
Latency {diagnostics.network.rtt}ms
DNS & Resolution
{networkChecks.dns.status === 'success' ? ( ) : networkChecks.dns.status === 'error' ? ( ) : (
)} {networkChecks.dns.detail}

Verified via Cloudflare DNS-over-HTTPS (DoH)

Connectivity Probes
{networkChecks.outbound.status === 'success' ? ( ) : (
)} {networkChecks.outbound.detail}
{networkChecks.local.status === 'success' ? ( ) : (
)} {networkChecks.local.detail}

Security Note: Browsers restrict direct socket access. Port scanning and firewall status are inferred via connectivity success/failure to known endpoints. No native OS firewall API is available to web applications.

External Modules & Integrations

ParseX Forensic EML/MHT Viewer

Standalone module for deep analysis of EML and MHT files.

Syntax Color Reference

Visual reference for syntax highlighting color schemes.

System Information
User Agent {diagnostics.userAgent}
Screen Resolution {diagnostics.screenSize}
Protocol {window.location.protocol}
); }