Files
unkernel/js/core/tailscale-load.ts
Pooya Parsa d382f7fa9b js: add a pure-JS Tailscale network device (work in progress)
The guest joins a tailnet from Node or the page: ts2021 control over
WebSocket, DERP relays, WireGuard and the packet filter in JS, loaded as
a separate chunk only when the option is used. SDK net option, CLI
--tailscale* flags and a page panel. Relay only; exit nodes, IPv6 and
real peer traffic are not covered yet.
2026-11-28 22:06:18 +00:00

21 lines
1005 B
TypeScript

// SPDX-License-Identifier: MIT
// Copyright (C) 2026 Pooya Parsa <pooya@pi0.io>
// The Tailscale client (tailscale/client.ts), imported on demand, so that
// it is a chunk of its own that only `net.tailscale` loads. Only the
// entries' platforms (node/platform.ts, web/platform.ts) and the public
// index import this module; the kernel workers must not (their bundles
// have no chunks to load: the node runs on the owner, devices.ts).
import type { TailscaleClient, TailscaleClientOptions } from "./tailscale/client.ts";
/** Imports the Tailscale client module (TailscaleClient, tailscaleFromSpec, ...). */
export function loadTailscale(): Promise<typeof import("./tailscale/client.ts")> {
return import("./tailscale/client.ts");
}
/** A TailscaleClient (its module imported first); call start() on it. */
export async function createTailscaleClient(opts: TailscaleClientOptions): Promise<TailscaleClient> {
const { TailscaleClient } = await loadTailscale();
return new TailscaleClient(opts);
}