mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-27 16:54:04 +00:00
Set cloudflared token from env var or arg
This commit is contained in:
parent
71be030733
commit
b72a2d350f
4 changed files with 18 additions and 24 deletions
14
package-lock.json
generated
14
package-lock.json
generated
|
@ -36,7 +36,7 @@
|
|||
"jsonwebtoken": "~8.5.1",
|
||||
"jwt-decode": "^3.1.2",
|
||||
"limiter": "^2.1.0",
|
||||
"node-cloudflared-tunnel": "~1.0.7",
|
||||
"node-cloudflared-tunnel": "~1.0.9",
|
||||
"nodemailer": "~6.6.5",
|
||||
"notp": "~2.0.3",
|
||||
"password-hash": "~1.2.2",
|
||||
|
@ -11162,9 +11162,9 @@
|
|||
"integrity": "sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A=="
|
||||
},
|
||||
"node_modules/node-cloudflared-tunnel": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/node-cloudflared-tunnel/-/node-cloudflared-tunnel-1.0.7.tgz",
|
||||
"integrity": "sha512-2xKygxFNZZPktF73dvJTNPjFkK4ThOPMpsZf885Iqq5Eie/vxk5mFH8a8dLlDWZYYpGDc699qToJTOlrTqd3Eg==",
|
||||
"version": "1.0.9",
|
||||
"resolved": "https://registry.npmjs.org/node-cloudflared-tunnel/-/node-cloudflared-tunnel-1.0.9.tgz",
|
||||
"integrity": "sha512-d0mhIM5P2ldE2yHChehC6EvnpFCkifWRzWrW81gVWdcCWqNcyISXuDdOYzRW5mwmjWuT6WNtLJoGQ84uqS4EmA==",
|
||||
"dependencies": {
|
||||
"command-exists": "^1.2.9"
|
||||
}
|
||||
|
@ -24081,9 +24081,9 @@
|
|||
"integrity": "sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A=="
|
||||
},
|
||||
"node-cloudflared-tunnel": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/node-cloudflared-tunnel/-/node-cloudflared-tunnel-1.0.7.tgz",
|
||||
"integrity": "sha512-2xKygxFNZZPktF73dvJTNPjFkK4ThOPMpsZf885Iqq5Eie/vxk5mFH8a8dLlDWZYYpGDc699qToJTOlrTqd3Eg==",
|
||||
"version": "1.0.9",
|
||||
"resolved": "https://registry.npmjs.org/node-cloudflared-tunnel/-/node-cloudflared-tunnel-1.0.9.tgz",
|
||||
"integrity": "sha512-d0mhIM5P2ldE2yHChehC6EvnpFCkifWRzWrW81gVWdcCWqNcyISXuDdOYzRW5mwmjWuT6WNtLJoGQ84uqS4EmA==",
|
||||
"requires": {
|
||||
"command-exists": "^1.2.9"
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@
|
|||
"jsonwebtoken": "~8.5.1",
|
||||
"jwt-decode": "^3.1.2",
|
||||
"limiter": "^2.1.0",
|
||||
"node-cloudflared-tunnel": "~1.0.7",
|
||||
"node-cloudflared-tunnel": "~1.0.9",
|
||||
"nodemailer": "~6.6.5",
|
||||
"notp": "~2.0.3",
|
||||
"password-hash": "~1.2.2",
|
||||
|
|
|
@ -91,6 +91,7 @@ const port = parseInt(process.env.UPTIME_KUMA_PORT || process.env.PORT || args.p
|
|||
const sslKey = process.env.UPTIME_KUMA_SSL_KEY || process.env.SSL_KEY || args["ssl-key"] || undefined;
|
||||
const sslCert = process.env.UPTIME_KUMA_SSL_CERT || process.env.SSL_CERT || args["ssl-cert"] || undefined;
|
||||
const disableFrameSameOrigin = !!process.env.UPTIME_KUMA_DISABLE_FRAME_SAMEORIGIN || args["disable-frame-sameorigin"] || false;
|
||||
const cloudflaredToken = args["cloudflared-token"] || process.env.UPTIME_KUMA_CLOUDFLARED_TOKEN || undefined;
|
||||
|
||||
// 2FA / notp verification defaults
|
||||
const twofa_verification_opts = {
|
||||
|
@ -1407,7 +1408,7 @@ exports.entryPage = "dashboard";
|
|||
initBackgroundJobs(args);
|
||||
|
||||
// Start cloudflared at the end if configured
|
||||
await cloudflaredAutoStart();
|
||||
await cloudflaredAutoStart(cloudflaredToken);
|
||||
|
||||
})();
|
||||
|
||||
|
|
|
@ -37,19 +37,6 @@ module.exports.cloudflaredSocketHandler = (socket) => {
|
|||
try {
|
||||
checkLogin(socket);
|
||||
if (token && typeof token === "string") {
|
||||
token = token.trim();
|
||||
|
||||
// try to strip out "cloudflared.exe service install"
|
||||
let array = token.split(" ");
|
||||
if (array.length > 1) {
|
||||
for (let i = 0; i < array.length - 1; i++) {
|
||||
if (array[i] === "install") {
|
||||
token = array[i + 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await setSetting("cloudflaredTunnelToken", token);
|
||||
cloudflared.token = token;
|
||||
} else {
|
||||
cloudflared.token = null;
|
||||
|
@ -80,8 +67,14 @@ module.exports.cloudflaredSocketHandler = (socket) => {
|
|||
|
||||
};
|
||||
|
||||
module.exports.autoStart = async () => {
|
||||
let token = await setting("cloudflaredTunnelToken");
|
||||
module.exports.autoStart = async (token) => {
|
||||
if (!token) {
|
||||
token = await setting("cloudflaredTunnelToken");
|
||||
} else {
|
||||
// Override the current token via args or env var
|
||||
await setSetting("cloudflaredTunnelToken", token);
|
||||
console.log("Use cloudflared token from args or env var");
|
||||
}
|
||||
|
||||
if (token) {
|
||||
console.log("Start cloudflared");
|
||||
|
|
Loading…
Reference in a new issue