Improve setup: detect missing Tailscale Funnel and document requirement

This commit is contained in:
Peter Steinberger
2025-11-24 11:35:12 +01:00
parent 4001fb58b0
commit a2b73ec571
2 changed files with 14 additions and 2 deletions

View File

@@ -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 isnt 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

View File

@@ -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);