dms_tailscalectl/tailscalectl/lib.js
vybe c9d1baf7c4 fix: remove ESM export from lib.js for QML compatibility
QML's JS engine does not support ES module export/import syntax.
Replace bare export with a CommonJS guard that only runs under Node.js,
so the plugin loads in QML while tests still work.
2026-05-18 18:39:39 +00:00

21 lines
661 B
JavaScript

function parsePeers(peerMap) {
if (!peerMap) return []
return Object.keys(peerMap).map(function (key) {
var p = peerMap[key]
return {
hostname: p.HostName || key,
ip: (p.TailscaleIPs && p.TailscaleIPs.length) ? p.TailscaleIPs[0] : "",
online: p.Online || false,
exitNode: p.ExitNodeOption || false
}
})
}
function makeExitNodeCommand(hostname) {
return ["tailscale", "set", "--exit-node=" + hostname]
}
// CommonJS export for Node.js tests (ignored by QML)
if (typeof module !== "undefined" && module.exports) {
module.exports = { parsePeers, makeExitNodeCommand }
}