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 (
Hardware APIs like WebUSB and WebBluetooth are often blocked inside iframes. Open the app in a new tab to use RTL-SDR.
)}Required for RTL-SDR hardware integration.
Required for BLE scanning fallback.
Verified via Cloudflare DNS-over-HTTPS (DoH)
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.
Standalone module for deep analysis of EML and MHT files.
Visual reference for syntax highlighting color schemes.