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);
|
|
|
|
|
2017-12-14 01:25:16 +08:00
|
|
|
let _token = process.env.ZT_TOKEN;
|
2017-12-13 22:05:07 +08:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|