diff --git a/aarch64/app/html/index.html b/aarch64/app/html/index.html index 85545be..f9d13f9 100644 --- a/aarch64/app/html/index.html +++ b/aarch64/app/html/index.html @@ -511,6 +511,16 @@ /localapi:/.test(txt); } + // If an auth URL appears AFTER the last Running state, re-auth is needed + // (handles stale Running entries in syslog after reinstall or token expiry) + if (isRunning && latestUrl) { + var lastRunIdx = txt.lastIndexOf('-> Running'); + var urlSnippet = latestUrl.substring(0, 60); + var lastUrlIdx = -1, upos = 0, uidx; + while ((uidx = txt.indexOf(urlSnippet, upos)) !== -1) { lastUrlIdx = uidx; upos = uidx + 1; } + if (lastUrlIdx > lastRunIdx) isRunning = false; + } + if (isRunning) return { state: 'connected', url: null, ip: tsIP, node: node, tailnet: tailnet, version: version }; if (latestUrl) return { state: 'connecting', url: latestUrl, ip: null, node: null, tailnet: null, version: version }; if (/Starting Tailscale|tailscaled.*start|logtail started/.test(txt)) return { state: 'connecting', url: null, ip: null, node: null, tailnet: null, version: version }; diff --git a/aarch64_ROOT/app/html/index.html b/aarch64_ROOT/app/html/index.html index e84d4ea..4c84f7e 100644 --- a/aarch64_ROOT/app/html/index.html +++ b/aarch64_ROOT/app/html/index.html @@ -511,6 +511,16 @@ /localapi:/.test(txt); } + // If an auth URL appears AFTER the last Running state, re-auth is needed + // (handles stale Running entries in syslog after reinstall or token expiry) + if (isRunning && latestUrl) { + var lastRunIdx = txt.lastIndexOf('-> Running'); + var urlSnippet = latestUrl.substring(0, 60); + var lastUrlIdx = -1, upos = 0, uidx; + while ((uidx = txt.indexOf(urlSnippet, upos)) !== -1) { lastUrlIdx = uidx; upos = uidx + 1; } + if (lastUrlIdx > lastRunIdx) isRunning = false; + } + if (isRunning) return { state: 'connected', url: null, ip: tsIP, node: node, tailnet: tailnet, version: version }; if (latestUrl) return { state: 'connecting', url: latestUrl, ip: null, node: null, tailnet: null, version: version }; if (/Starting Tailscale|tailscaled.*start|logtail started/.test(txt)) return { state: 'connecting', url: null, ip: null, node: null, tailnet: null, version: version }; diff --git a/aarch64_custom/app/html/index.html b/aarch64_custom/app/html/index.html index ead4afb..ff3ab46 100644 --- a/aarch64_custom/app/html/index.html +++ b/aarch64_custom/app/html/index.html @@ -519,6 +519,16 @@ /localapi:/.test(txt); } + // If an auth URL appears AFTER the last Running state, re-auth is needed + // (handles stale Running entries in syslog after reinstall or token expiry) + if (isRunning && latestUrl) { + var lastRunIdx = txt.lastIndexOf('-> Running'); + var urlSnippet = latestUrl.substring(0, 60); + var lastUrlIdx = -1, upos = 0, uidx; + while ((uidx = txt.indexOf(urlSnippet, upos)) !== -1) { lastUrlIdx = uidx; upos = uidx + 1; } + if (lastUrlIdx > lastRunIdx) isRunning = false; + } + if (isRunning) return { state: 'connected', url: null, ip: tsIP, node: node, tailnet: tailnet, version: version }; if (latestUrl) return { state: 'connecting', url: latestUrl, ip: null, node: null, tailnet: null, version: version }; if (/Starting Tailscale|tailscaled.*start|logtail started/.test(txt)) return { state: 'connecting', url: null, ip: null, node: null, tailnet: null, version: version }; diff --git a/arm/app/html/index.html b/arm/app/html/index.html index e84d4ea..4c84f7e 100644 --- a/arm/app/html/index.html +++ b/arm/app/html/index.html @@ -511,6 +511,16 @@ /localapi:/.test(txt); } + // If an auth URL appears AFTER the last Running state, re-auth is needed + // (handles stale Running entries in syslog after reinstall or token expiry) + if (isRunning && latestUrl) { + var lastRunIdx = txt.lastIndexOf('-> Running'); + var urlSnippet = latestUrl.substring(0, 60); + var lastUrlIdx = -1, upos = 0, uidx; + while ((uidx = txt.indexOf(urlSnippet, upos)) !== -1) { lastUrlIdx = uidx; upos = uidx + 1; } + if (lastUrlIdx > lastRunIdx) isRunning = false; + } + if (isRunning) return { state: 'connected', url: null, ip: tsIP, node: node, tailnet: tailnet, version: version }; if (latestUrl) return { state: 'connecting', url: latestUrl, ip: null, node: null, tailnet: null, version: version }; if (/Starting Tailscale|tailscaled.*start|logtail started/.test(txt)) return { state: 'connecting', url: null, ip: null, node: null, tailnet: null, version: version }; diff --git a/arm_ROOT/app/html/index.html b/arm_ROOT/app/html/index.html index e84d4ea..4c84f7e 100644 --- a/arm_ROOT/app/html/index.html +++ b/arm_ROOT/app/html/index.html @@ -511,6 +511,16 @@ /localapi:/.test(txt); } + // If an auth URL appears AFTER the last Running state, re-auth is needed + // (handles stale Running entries in syslog after reinstall or token expiry) + if (isRunning && latestUrl) { + var lastRunIdx = txt.lastIndexOf('-> Running'); + var urlSnippet = latestUrl.substring(0, 60); + var lastUrlIdx = -1, upos = 0, uidx; + while ((uidx = txt.indexOf(urlSnippet, upos)) !== -1) { lastUrlIdx = uidx; upos = uidx + 1; } + if (lastUrlIdx > lastRunIdx) isRunning = false; + } + if (isRunning) return { state: 'connected', url: null, ip: tsIP, node: node, tailnet: tailnet, version: version }; if (latestUrl) return { state: 'connecting', url: latestUrl, ip: null, node: null, tailnet: null, version: version }; if (/Starting Tailscale|tailscaled.*start|logtail started/.test(txt)) return { state: 'connecting', url: null, ip: null, node: null, tailnet: null, version: version }; diff --git a/arm_custom/app/html/index.html b/arm_custom/app/html/index.html index ead4afb..ff3ab46 100644 --- a/arm_custom/app/html/index.html +++ b/arm_custom/app/html/index.html @@ -519,6 +519,16 @@ /localapi:/.test(txt); } + // If an auth URL appears AFTER the last Running state, re-auth is needed + // (handles stale Running entries in syslog after reinstall or token expiry) + if (isRunning && latestUrl) { + var lastRunIdx = txt.lastIndexOf('-> Running'); + var urlSnippet = latestUrl.substring(0, 60); + var lastUrlIdx = -1, upos = 0, uidx; + while ((uidx = txt.indexOf(urlSnippet, upos)) !== -1) { lastUrlIdx = uidx; upos = uidx + 1; } + if (lastUrlIdx > lastRunIdx) isRunning = false; + } + if (isRunning) return { state: 'connected', url: null, ip: tsIP, node: node, tailnet: tailnet, version: version }; if (latestUrl) return { state: 'connecting', url: latestUrl, ip: null, node: null, tailnet: null, version: version }; if (/Starting Tailscale|tailscaled.*start|logtail started/.test(txt)) return { state: 'connecting', url: null, ip: null, node: null, tailnet: null, version: version };