feat: add support to default authtoken location of major platforms

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
This commit is contained in:
Syrone Wong 2022-08-14 14:23:50 +08:00
commit 9e0b691cf7

View file

@ -7,7 +7,21 @@ var token;
if (process.env.ZU_CONTROLLER_TOKEN) { if (process.env.ZU_CONTROLLER_TOKEN) {
token = process.env.ZU_CONTROLLER_TOKEN; token = process.env.ZU_CONTROLLER_TOKEN;
} else { } else {
if (process.platform === "unix") {
token = fs.readFileSync("/var/lib/zerotier-one/authtoken.secret", "utf8"); token = fs.readFileSync("/var/lib/zerotier-one/authtoken.secret", "utf8");
} else if (process.platform === "win32") {
token = fs.readFileSync(
"C:\\ProgramData\\ZeroTier\\One\\authtoken.secret",
"utf8"
);
} else if (process.platform === "darwin") {
token = fs.readFileSync(
"/Library/Application Support/ZeroTier/One/authtoken.secret",
"utf8"
);
} else {
throw `Unsupported platform ${process.platform}`;
}
} }
module.exports = axios.create({ module.exports = axios.create({