init static method
- required String stateDir,
- TailscaleLogLevel logLevel = TailscaleLogLevel.silent,
Configures the Tailscale library. Call this once at app startup, alongside other library initializers.
stateDir is an app-owned directory where Tailscale persists
its node identity, keys, and profile data under a tailscale/
subdirectory. The library creates that subdirectory 0700 and
stores the node private key in an owner-only (0600) database.
On a fresh install this directory is empty; after the first
successful up, it contains credentials that let subsequent
launches reconnect without an auth key.
Pick somewhere durable but excluded from cloud backups — the
directory holds the node's WireGuard private key, and a key that
leaks into iCloud/Google backups can be restored onto another
device and silently impersonate this node. Prefer the application
support directory (getApplicationSupportDirectory()) over the
documents directory, which on iOS is included in iCloud backups
and visible in the Files app, and on Android is reachable via
Auto Backup. Mark the directory excluded from backup:
NSURLIsExcludedFromBackupKey on iOS; dataExtractionRules /
fullBackupContent rules on Android. For nodes that should not
persist identity at all, register an ephemeral node instead.
Implementation
static void init({
required String stateDir,
TailscaleLogLevel logLevel = TailscaleLogLevel.silent,
}) {
if (stateDir.trim().isEmpty) {
throw const TailscaleUsageException('stateDir must not be empty.');
}
final normalizedStateDir = p.normalize(p.absolute(stateDir));
try {
ensurePosixFdTransportAvailable();
} catch (error) {
throw TailscaleUsageException(
'POSIX fd transport is not available on this platform.',
cause: error,
);
}
_stateBaseDir = normalizedStateDir;
native.duneSetLogLevel(logLevel.nativeValue);
}