mirror of
https://github.com/myronblair/jarvis
synced 2026-07-27 16:22:55 -05:00
Fix AGENT button showing the wrong machine: same-subnet fallback matched whichever agent happened to be first in the list, not the actual browsing machine — happens whenever a LAN client hits the dashboard via hairpin NAT/external hostname and the server sees the same reflected IP for every visitor. Exact-match only now; falls through to not-detected instead of misreporting another real machine as yours.
This commit is contained in:
@@ -1631,11 +1631,18 @@ async function checkAgentStatus() {
|
||||
sta.textContent = online.length > 0 ? online.length + ' ONLINE' : 'NONE';
|
||||
const cnt = document.getElementById('net-agent-count');
|
||||
if (cnt) cnt.textContent = online.length + ' AGENT' + (online.length !== 1 ? 'S' : '') + ' ONLINE';
|
||||
// Fixed 2026-07-07: this used to fall back to "any agent on the same /24
|
||||
// subnet" when the exact IP didn't match, meant to handle NAT — but when
|
||||
// a LAN client hits the dashboard via its external hostname (hairpin NAT,
|
||||
// or through Cloudflare), the server sees the SAME single reflected/proxy
|
||||
// IP for every visitor on the LAN, not each machine's real one. The exact
|
||||
// match then always fails, and the subnet fallback just grabbed whichever
|
||||
// agent happened to be first in the list — showing a *different real
|
||||
// machine* as "yours", not a harmless guess. Exact match only now; if it
|
||||
// fails, the button correctly falls through to "not detected" instead of
|
||||
// reporting someone else's agent as this one.
|
||||
const myIp = data.my_ip || '';
|
||||
// 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 + '.'));
|
||||
_myAgent = online.find(a => a.ip_address === myIp) || null;
|
||||
_agentOnline = !!_myAgent;
|
||||
if (btn) {
|
||||
const isTablet = detectOS() === 'tablet';
|
||||
|
||||
Reference in New Issue
Block a user