TailscaleStatus.fromJson constructor
Parses a status snapshot from the JSON shape produced by Go's
ipnstate.Status.
Missing or malformed fields fall back to safe defaults (empty lists, NodeState.noState) rather than throwing — callers should treat the result as a best-effort view of the engine's reported state.
Implementation
factory TailscaleStatus.fromJson(Map<String, dynamic> json) {
final self = json['Self'] as Map<String, dynamic>?;
return TailscaleStatus(
state: NodeState.parse(json['BackendState'] as String?),
authUrl: _parseUri(json['AuthURL']),
stableNodeId: _parseNonEmptyString(self?['ID']),
tailscaleIPs: _parseIPs(self?['TailscaleIPs']),
health: (json['Health'] as List?)?.cast<String>() ?? const [],
magicDNSSuffix:
(json['CurrentTailnet'] as Map<String, dynamic>?)?['MagicDNSSuffix']
as String?,
);
}