mirror of
https://github.com/pithings/unkernel.git
synced 2026-12-02 01:59:43 +08:00
With net.tailscale.exitNode (--tailscale-exit-node, setExitNode() at run time) a tailnet device that offers 0.0.0.0/0 takes all the guest's other IPv4 traffic and its DNS in place of the backend; while it is not usable that traffic is refused. WireGuard's source check is now the longest prefix across peers. The page lists the tailnet's devices, picks the exit node from a select box in Settings and the top bar panel, and shows a set-up node's status and live controls apart from the setup form. The README gains a section on joining a tailnet.
30 lines
1.5 KiB
TypeScript
30 lines
1.5 KiB
TypeScript
// 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"),
|
|
};
|
|
}
|