ztncui/controllers/token.js

26 lines
525 B
JavaScript
Raw Normal View History

2017-12-13 22:05:07 +08:00
/*
ztncui - ZeroTier network controller UI
Copyright (C) 2017 Key Networks (https://key-networks.com)
Licensed under GPLv3 - see LICENSE for details.
*/
const fs = require('fs');
const util = require('util');
const readFile = util.promisify(fs.readFile);
let _token = null;
exports.get = async function() {
if (_token) {
return _token;
} else {
try {
_token = await readFile('/var/lib/zerotier-one/authtoken.secret', 'utf8');
return _token;
} catch(err) {
throw(err);
}
}
}