Something went wrong. Try again.
An experimental port of NetBSD, FreeBSD, OpenBSD, and XNU to unkernel unkernel.dev
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930// SPDX-License-Identifier: MIT// Copyright (C) 2026 Pooya Parsa <pooya@pi0.io>// The CLI's --tailscale* flags as a net.tailscale spec (without the saved// state, which the CLI reads from --tailscale-state itself). Tailscale is// on only when a --tailscale* flag asks for it: TS_AUTHKEY in the// environment supplies the key then and never turns it on by itself (many// machines with Tailscale tooling export one).
import type { TailscaleSpec } from "../core/devices.ts";
/** The flags that ask for Tailscale (any of them). */export const TAILSCALE_FLAGS = ["tailscale", "tailscale-authkey", "tailscale-state", "tailscale-login-server", "tailscale-hostname", "tailscale-accept-routes", "tailscale-rewrite", "tailscale-exit-node"];
/** The spec for these arguments, or undefined when no --tailscale* flag is there. */export function tailscaleArgs(args: readonly string[], env: Record<string, string | undefined>): TailscaleSpec | undefined { if (!TAILSCALE_FLAGS.some((f) => args.includes(`--${f}`))) return undefined; const opt = (name: string) => { const i = args.indexOf(`--${name}`); return i >= 0 ? args[i + 1] : undefined; }; return { authKey: opt("tailscale-authkey") ?? (env.TS_AUTHKEY || undefined), controlURL: opt("tailscale-login-server"), hostname: opt("tailscale-hostname") ?? "unkernel", acceptRoutes: args.includes("--tailscale-accept-routes"), exitNode: opt("tailscale-exit-node") || undefined, guestAddress: !args.includes("--tailscale-rewrite"), };}