From a2b73ec5710ecc276be898d1bb5511f940e8b646 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 24 Nov 2025 11:35:12 +0100 Subject: [PATCH] Improve setup: detect missing Tailscale Funnel and document requirement --- README.md | 1 + src/index.ts | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5c43d92b9..89e39273c 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Small TypeScript CLI to send, monitor, and webhook WhatsApp messages via Twilio. - If no `--reply`, auto-reply can be configured via `~/.warelay/warelay.json` (JSON5) - Setup helper: `pnpm warelay setup --port 42873 --path /webhook/whatsapp` - Validates Twilio env, confirms `tailscale` binary, starts the webhook, enables Tailscale Funnel, and sets the Twilio incoming webhook to your Funnel URL. + - Requires Tailscale Funnel to be enabled for your tailnet/device (admin setting). If it isn’t enabled, the command will exit with instructions; alternatively expose the webhook via your own tunnel and set the Twilio URL manually. ## Config-driven auto-replies diff --git a/src/index.ts b/src/index.ts index 48c8aa11a..0a1a33da8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -280,10 +280,21 @@ async function getTailnetHostname() { async function ensureFunnel(port: number) { try { - const { stdout } = await execFileAsync('tailscale', ['funnel', `${port}`, `127.0.0.1:${port}`], { + const status = await execFileAsync('tailscale', ['funnel', 'status', '--json'], { + maxBuffer: 2_000_000 + }).then((r) => r.stdout.trim()); + + if (!status || status === '{}' || status === 'null') { + console.error( + 'Tailscale Funnel is not enabled on this tailnet/device. Enable it in the Tailscale admin console, then re-run warelay setup.' + ); + process.exit(1); + } + + const { stdout } = await execFileAsync('tailscale', ['funnel', '--yes', '--bg', `${port}`], { maxBuffer: 200_000 }); - console.log(stdout.trim()); + if (stdout.trim()) console.log(stdout.trim()); } catch (err) { console.error('Failed to enable Tailscale Funnel. Is it allowed on your tailnet?', err); process.exit(1);