From b6e5d81dc0b689273c53c2a4448842f441435282 Mon Sep 17 00:00:00 2001 From: Niklas Haiden Date: Sat, 21 Nov 2026 19:19:44 +0100 Subject: [PATCH] feat: status dots show whether a link's address answers With STATUS_CHECKS=true the server requests the address of every link of the open dashboard once a minute and the tile shows a green dot or a red ring. Off by default: users choose the addresses, so a user could find out which hosts and ports the server reaches. --- .env.example | 5 ++++ README.md | 8 +++++ src/components/link-tile.tsx | 19 +++++++++++- src/lib/dashboard.functions.ts | 20 +++++++++++++ src/lib/status.test.ts | 52 +++++++++++++++++++++++++++++++++ src/lib/status.ts | 45 +++++++++++++++++++++++++++++ src/routes/index.tsx | 53 ++++++++++++++++++++++++++++------ 7 files changed, 192 insertions(+), 10 deletions(-) create mode 100644 src/lib/status.test.ts create mode 100644 src/lib/status.ts diff --git a/.env.example b/.env.example index 6f6e7e0..1dc2dcc 100644 --- a/.env.example +++ b/.env.example @@ -19,5 +19,10 @@ OIDC_CLIENT_ID= OIDC_CLIENT_SECRET= OIDC_PROVIDER_NAME=SSO +# Set to "true" to show on every link whether its address answers. The server then +# calls the addresses that users save as links, once a minute. Leave it off when +# people you do not trust can sign up: they could probe your network with it. +STATUS_CHECKS=false + # SearXNG instance (must be reachable from the browser and from this server) SEARXNG_URL= diff --git a/README.md b/README.md index 5c8ca1f..c03119c 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ Build it yourself: `docker build -t dahoam .` | `DISABLE_SIGNUP` | `true` closes email/password registration. Set it after you made your account. | | `OIDC_DISCOVERY_URL`, `OIDC_CLIENT_ID`, `OIDC_CLIENT_SECRET` | Turns on the SSO button. Redirect URI: `/api/auth/callback/sso` | | `OIDC_PROVIDER_NAME` | Text on the SSO button ("Continue with …") | +| `STATUS_CHECKS` | `true` shows on every link whether its address answers. Off by default, see Notes. | | `SEARXNG_URL` | Your SearXNG instance. Makes SearXNG selectable in Settings. | ## Use @@ -71,6 +72,8 @@ Build it yourself: `docker build -t dahoam .` site's `/favicon.ico`. When the library has a light version of the icon (`github-light`), that one is used, because the cards are dark. Or type in the field to search that library and click an icon, paste an image URL, or upload your own image (PNG, JPEG, WebP, AVIF or SVG, up to 1 MB). +- **Status** (with `STATUS_CHECKS=true`): a green dot on a link means that its address + answers, a red ring that it does not. Checked once a minute. - **Search**: `/` focuses the bar. `!w cats` uses DuckDuckGo bangs. `/settings`, `/add link`, `/add card`, `/add dashboard` and `/sign out` run commands. - **Open a link from the search bar**: type the start of its name (`jel` for Jellyfin). The @@ -87,6 +90,11 @@ Build it yourself: `docker build -t dahoam .` - Suggestions come from DuckDuckGo, or from SearXNG (`/autocompleter`) when it is the selected engine. The server fetches them, the browser never calls those hosts directly. +- Status checks: the server requests each link's address (a GET, redirects are not + followed, the answer is thrown away) and tells the browser only up or down. Up is any + answer below 500, and also a certificate that the server does not trust. Because users + choose the addresses, a user can find out which hosts and ports the server can reach. + Turn it on for people you trust, together with `DISABLE_SIGNUP=true`. - SSO does not take over an existing password account with the same email (Better Auth blocks it, because password emails are not verified). Use one or the other per email. - Icon lookups send the link name to the jsDelivr CDN. The link dialog also loads the diff --git a/src/components/link-tile.tsx b/src/components/link-tile.tsx index 0c4a77b..f54fa6e 100644 --- a/src/components/link-tile.tsx +++ b/src/components/link-tile.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef, useState } from "react" +import { createContext, useContext, useEffect, useRef, useState } from "react" import { useDndContext } from "@dnd-kit/core" import { useSortable } from "@dnd-kit/sortable" import { CSS } from "@dnd-kit/utilities" @@ -16,6 +16,9 @@ export type HomeLink = { lightIcon: string | null } +/** Per link id: does its address answer? No entry: not checked (yet). */ +export const StatusContext = createContext>>({}) + type IconProps = { link: HomeLink; className?: string } /** Starts the fallback chain again when the link changes. */ @@ -98,6 +101,7 @@ export function LinkTile({ transition, isDragging, } = useSortable({ id: link.id, disabled: { droppable: cardDragged } }) + const up = useContext(StatusContext)[link.id] return (
+ {up !== undefined && ( + // at the lower right corner of the icon. Filled green or a red ring: + // the shape differs too, not only the color. + + {!up && , not reachable} + + )}
- setCard("new")} - onAddLink={(c) => setLink({ cardId: c.id })} - onEditLink={setLink} - onEditCard={setCard} - /> + + setCard("new")} + onAddLink={(c) => setLink({ cardId: c.id })} + onEditLink={setLink} + onEditCard={setCard} + /> +