From 049906067687ad00f78c1a1532a6e9ff97dd6a27 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Wed, 25 Feb 2026 12:11:43 -0800 Subject: [PATCH] Use dynamic hostname instead of toes.local --- scripts/config.sh | 4 ++-- src/cli/http.ts | 3 ++- src/server/index.tsx | 2 +- src/server/mdns.ts | 16 ++++++++-------- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/scripts/config.sh b/scripts/config.sh index 29ee41a..ec275ae 100755 --- a/scripts/config.sh +++ b/scripts/config.sh @@ -2,8 +2,8 @@ # It isn't enough to modify this yet. # You also need to manually update the toes.service file. -HOST="${HOST:-toes@toes.local}" -URL="${URL:-http://toes.local}" +HOST="${HOST:-toes@$(hostname).local}" +URL="${URL:-http://$(hostname).local}" DEST="${DEST:-~/toes}" DATA_DIR="${DATA_DIR:-~/data}" APPS_DIR="${APPS_DIR:-~/apps}" diff --git a/src/cli/http.ts b/src/cli/http.ts index 68d5455..90290ba 100644 --- a/src/cli/http.ts +++ b/src/cli/http.ts @@ -1,6 +1,7 @@ import type { Manifest } from '@types' +import { hostname } from 'os' -const DEFAULT_HOST = process.env.DEV ? 'http://localhost:3000' : 'http://toes.local' +const DEFAULT_HOST = process.env.DEV ? 'http://localhost:3000' : `http://${hostname()}.local` const normalizeUrl = (url: string) => url.startsWith('http://') || url.startsWith('https://') ? url : `http://${url}` diff --git a/src/server/index.tsx b/src/server/index.tsx index ce5bbcb..eb41e6b 100644 --- a/src/server/index.tsx +++ b/src/server/index.tsx @@ -89,7 +89,7 @@ async function buildBinary(name: string): Promise { return promise } -// Install script: curl -fsSL http://toes.local/install | bash +// Install script: curl -fsSL http://.local/install | bash app.get('/install', c => { if (!TOES_URL) return c.text('TOES_URL is not configured', 500) const script = INSTALL_SCRIPT.replace('__TOES_URL__', TOES_URL) diff --git a/src/server/mdns.ts b/src/server/mdns.ts index e8a74a4..9879abb 100644 --- a/src/server/mdns.ts +++ b/src/server/mdns.ts @@ -1,6 +1,6 @@ import type { Subprocess } from 'bun' import { toSubdomain } from '@urls' -import { networkInterfaces } from 'os' +import { hostname, networkInterfaces } from 'os' import { hostLog } from './tui' const _publishers = new Map() @@ -24,7 +24,7 @@ export function cleanupStalePublishers() { if (!isEnabled) return try { - const result = Bun.spawnSync(['pkill', '-f', 'avahi-publish.*toes\\.local']) + const result = Bun.spawnSync(['pkill', '-f', `avahi-publish.*${hostname()}\\.local`]) if (result.exitCode === 0) { hostLog('mDNS: cleaned up stale avahi-publish processes') } @@ -41,22 +41,22 @@ export function publishApp(name: string) { return } - const hostname = `${toSubdomain(name)}.toes.local` + const host = `${toSubdomain(name)}.${hostname()}.local` try { - const proc = Bun.spawn(['avahi-publish', '-a', hostname, '-R', ip], { + const proc = Bun.spawn(['avahi-publish', '-a', host, '-R', ip], { stdout: 'ignore', stderr: 'ignore', }) _publishers.set(name, proc) - hostLog(`mDNS: published ${hostname} -> ${ip}`) + hostLog(`mDNS: published ${host} -> ${ip}`) proc.exited.then(() => { _publishers.delete(name) }) } catch { - hostLog(`mDNS: failed to publish ${hostname}`) + hostLog(`mDNS: failed to publish ${host}`) } } @@ -68,7 +68,7 @@ export function unpublishApp(name: string) { proc.kill() _publishers.delete(name) - hostLog(`mDNS: unpublished ${toSubdomain(name)}.toes.local`) + hostLog(`mDNS: unpublished ${toSubdomain(name)}.${hostname()}.local`) } export function unpublishAll() { @@ -76,7 +76,7 @@ export function unpublishAll() { for (const [name, proc] of _publishers) { proc.kill() - hostLog(`mDNS: unpublished ${toSubdomain(name)}.toes.local`) + hostLog(`mDNS: unpublished ${toSubdomain(name)}.${hostname()}.local`) } _publishers.clear() }