Fix agent detection: real client IP via CF header, tablet/iPad support, subnet fallback match

This commit is contained in:
2026-05-30 03:23:12 +00:00
parent 62c7878615
commit e08b80a6c6
2 changed files with 45 additions and 19 deletions
+3 -1
View File
@@ -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':