fix: bigint overflow

This commit is contained in:
Lemon
2024-07-29 20:32:31 +08:00
parent 79c341d12e
commit b537a513b3

View File

@@ -17,7 +17,9 @@ var callServiceList = rpc.declare({
params: ['name'],
expect: { '': {} }
});
function enquoteBigNumber(str) {
return str.replace(/("\w+"):\s*(\d+)/g, '$1:"$2"');
}
function getStatus() {
var status = {};
return Promise.resolve(callServiceList('tailscale')).then(function (res) {
@@ -28,7 +30,7 @@ function getStatus() {
}
return fs.exec("/usr/sbin/tailscale", ["status", "--json"]);
}).then(function(res) {
var tailscaleStatus = JSON.parse(res.stdout);
var tailscaleStatus = JSON.parse(enquoteBigNumber(res.stdout));
if (!tailscaleStatus.AuthURL && tailscaleStatus.BackendState == "NeedsLogin") {
fs.exec("/usr/sbin/tailscale", ["login"]);
}