diff --git a/api/endpoints/agent.php b/api/endpoints/agent.php index c192576..c1cd30f 100644 --- a/api/endpoints/agent.php +++ b/api/endpoints/agent.php @@ -213,7 +213,9 @@ switch ($agentAction) { foreach ($agents as &$a) { $a['capabilities'] = json_decode($a['capabilities'] ?? '[]', true); } - agent_ok(['agents' => $agents, 'my_ip' => $_SERVER['REMOTE_ADDR'] ?? '']); + $realIp = $_SERVER['HTTP_CF_CONNECTING_IP'] ?? $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['REMOTE_ADDR'] ?? ''; + $realIp = trim(explode(',', $realIp)[0]); + agent_ok(['agents' => $agents, 'my_ip' => $realIp]); // ── LATEST METRICS (for dashboard display) ─────────────────────────────── case 'status': diff --git a/public_html/index.html b/public_html/index.html index d920156..5e53939 100644 --- a/public_html/index.html +++ b/public_html/index.html @@ -1741,12 +1741,16 @@ function speak(text) { // ── AGENT DETECTION & BROWSER INSTALL ───────────────────────────────── let _agentOnline = false; +let _myAgent = null; function detectOS() { const ua = navigator.userAgent; const p = (navigator.platform || '').toLowerCase(); - if (p.includes('mac')) return 'mac'; + // Tablets — check before desktop OS (iPads spoof MacIntel) + if (/iPad|Android/.test(ua) || (p.includes('mac') && navigator.maxTouchPoints > 1)) return 'tablet'; + if (/iPhone/.test(ua)) return 'tablet'; if (p.includes('win') || ua.includes('Windows')) return 'windows'; + if (p.includes('mac') || ua.includes('Macintosh')) return 'mac'; if (p.includes('linux') || ua.includes('Linux')) return 'linux'; return 'unknown'; } @@ -1765,12 +1769,19 @@ async function checkAgentStatus() { const cnt = document.getElementById('net-agent-count'); if (cnt) cnt.textContent = online.length + ' AGENT' + (online.length !== 1 ? 'S' : '') + ' ONLINE'; const myIp = data.my_ip || ''; - const myAgent = online.find(a => a.ip_address === myIp); - _agentOnline = !!myAgent; + // Match by exact IP first, then by same /24 subnet (handles NAT behind same router) + const mySubnet = myIp.split('.').slice(0,3).join('.'); + _myAgent = online.find(a => a.ip_address === myIp) + || online.find(a => a.ip_address && a.ip_address.startsWith(mySubnet + '.')); + _agentOnline = !!_myAgent; if (btn) { - if (_agentOnline) { + const isTablet = detectOS() === 'tablet'; + if (isTablet) { + btn.title = 'JARVIS Agent — not available for tablets'; + btn.style.opacity = '0.5'; + } else if (_agentOnline) { btn.classList.add('agent-online'); - btn.title = 'Agent active: ' + myAgent.hostname; + btn.title = 'Agent active: ' + _myAgent.hostname; } else { btn.classList.remove('agent-online'); btn.title = 'Click to install JARVIS Agent on this machine'; @@ -1885,24 +1896,35 @@ function openAgentModal() { const baseUrl = 'https://jarvis.orbishosting.com/agent'; const jUrl = 'https://jarvis.orbishosting.com'; - if (_agentOnline) { + if (os === 'tablet') { + title.textContent = '● JARVIS — TABLET / MOBILE'; + content.innerHTML = + '
'+i.cmd+'' + '↓ DOWNLOAD INSTALLER' + - '