mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-28 06:05:24 +00:00
fix: host status shows online when the port answers and only warns on a failed login
This commit is contained in:
1 parent
c28cb1bfc6
commit
49acec4770
14 files changed
+141
-141
No files matched your search
@@ -24,7 +24,7 @@ function StatusDot({ status }: { status: string }) {
|
||||
status === "online"
|
||||
? getAccentColor()
|
||||
: status === "reachable"
|
||||
? `color-mix(in srgb, ${getAccentColor()} 40%, transparent)`
|
||||
? "#fbbf24"
|
||||
: status === "offline"
|
||||
? "#ef4444"
|
||||
: "#6b7280";
|
||||
|
||||
@@ -60,14 +60,14 @@ function HostStatusWidget({
|
||||
: online
|
||||
? getAccentColor()
|
||||
: reachable
|
||||
? `color-mix(in srgb, ${getAccentColor()} 40%, transparent)`
|
||||
? "#fbbf24"
|
||||
: "#ef4444";
|
||||
const onlineLabel = !statusInfo
|
||||
? t("common.unknown")
|
||||
: online
|
||||
? t("common.online")
|
||||
: reachable
|
||||
? t("common.reachable", { defaultValue: "Reachable" })
|
||||
? t("common.signInFailed")
|
||||
: t("common.offline");
|
||||
|
||||
return (
|
||||
|
||||
@@ -368,7 +368,8 @@ export class MetricsPoller {
|
||||
const message = error instanceof Error ? error.message : "";
|
||||
const isAuthError = /authentication|permission denied/i.test(message);
|
||||
|
||||
if (!authenticated) {
|
||||
// A timeout or a dropped connection says nothing about the login.
|
||||
if (!authenticated && (isAuthError || hostKeyChanged)) {
|
||||
this.ctx.hosts.status.reportLogin(host.id, {
|
||||
ok: false,
|
||||
hostKeyChanged,
|
||||
|
||||
@@ -154,6 +154,19 @@ describe("MetricsPoller", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("does not report a login for a connection that timed out", async () => {
|
||||
collectMetrics.mockRejectedValue(new Error("Timed out while waiting"));
|
||||
const { fake, poller } = setup();
|
||||
|
||||
poller.registerViewer(7, "viewer-a", "user-1");
|
||||
await flush();
|
||||
|
||||
expect(fake.statusReports).toEqual([]);
|
||||
expect(fake.emitted.at(-1)?.payload).toMatchObject({
|
||||
state: "unreachable",
|
||||
});
|
||||
});
|
||||
|
||||
it("marks a changed host key", async () => {
|
||||
collectMetrics.mockRejectedValue(new Error("Host key changed"));
|
||||
const { fake, poller, state } = setup();
|
||||
|
||||
@@ -142,9 +142,7 @@ function buildNodeSvg(
|
||||
? "rgb(16,185,129)"
|
||||
: resolveCssVar("--accent-brand", "rgb(16,185,129)");
|
||||
} else if (status === "reachable") {
|
||||
statusColor = useRealColors
|
||||
? "rgba(16,185,129,0.4)"
|
||||
: `color-mix(in srgb, ${resolveCssVar("--accent-brand", "rgb(16,185,129)")} 40%, transparent)`;
|
||||
statusColor = "rgb(251,191,36)";
|
||||
} else if (isOffline) {
|
||||
statusColor = useRealColors ? "rgb(239,68,68)" : "rgba(16,185,129,0.2)";
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user