mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-09-11 22:06:59 +08:00
Compare commits
73 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
5bb329fa0e | ||
|
09dedc07fb | ||
|
6cfae01a0d | ||
|
32dc76a085 | ||
|
c6d6061a9f | ||
|
243726b03c | ||
|
936665aac3 | ||
|
1185b259c2 | ||
|
a81f949f98 | ||
|
59f10d542b | ||
|
2778929f74 | ||
|
f71d35e53e | ||
|
1490443618 | ||
|
add5c128ce | ||
|
e797abd108 | ||
|
7a9e2f5de6 | ||
|
7b5d2a71ff | ||
|
893278bd3d | ||
|
0e30ea830d | ||
|
c67a2070b8 | ||
|
9863a10321 | ||
|
ee7f8680c1 | ||
|
c1301804d4 | ||
|
b385e81608 | ||
|
f37f55e06c | ||
|
87d7a780e3 | ||
|
0fc372f558 | ||
|
67a13e1259 | ||
|
2b8f55194f | ||
|
288cab6dd7 | ||
|
b4e45c7ce8 | ||
|
7635ab54a0 | ||
|
458cdf9f9b | ||
|
f1e2ee74ea | ||
|
8d847abf35 | ||
|
8151ac0e25 | ||
|
4185ec20b0 | ||
|
4245ea86e7 | ||
|
f861a48dfc | ||
|
fa1214ae5e | ||
|
621419e434 | ||
|
482049c72b | ||
|
2815cc73cf | ||
|
e1147c06aa | ||
|
abc8f2b131 | ||
|
777ef6bc7b | ||
|
b244e8fcbb | ||
|
031947319a | ||
|
74a908a069 | ||
|
9c56c9b346 | ||
|
37666bf35f | ||
|
90badfabee | ||
|
e3396251a8 | ||
|
9c9a086788 | ||
|
9fb95fe95e | ||
|
1e75d81bcf | ||
|
cb3a104dc0 | ||
|
57a18958d6 | ||
|
1708b67949 | ||
|
73239d441d | ||
|
4ceeb304f1 | ||
|
711380bbbe | ||
|
9536c6aa6a | ||
|
4255496b11 | ||
|
f28dccf4e1 | ||
|
b689733d59 | ||
|
afaa7bb2f0 | ||
|
121d1a11af | ||
|
8e61158758 | ||
|
bf58838b89 | ||
|
33ce0ef02c | ||
|
c1aaad0d85 | ||
|
954e05b72f |
@@ -78,7 +78,7 @@ module.exports = {
|
|||||||
"checkLoops": false,
|
"checkLoops": false,
|
||||||
}],
|
}],
|
||||||
"space-before-blocks": "warn",
|
"space-before-blocks": "warn",
|
||||||
//'no-console': 'warn',
|
//"no-console": "warn",
|
||||||
"no-extra-boolean-cast": "off",
|
"no-extra-boolean-cast": "off",
|
||||||
"no-multiple-empty-lines": [ "warn", {
|
"no-multiple-empty-lines": [ "warn", {
|
||||||
"max": 1,
|
"max": 1,
|
||||||
@@ -90,7 +90,8 @@ module.exports = {
|
|||||||
"no-unneeded-ternary": "error",
|
"no-unneeded-ternary": "error",
|
||||||
"array-bracket-newline": [ "error", "consistent" ],
|
"array-bracket-newline": [ "error", "consistent" ],
|
||||||
"eol-last": [ "error", "always" ],
|
"eol-last": [ "error", "always" ],
|
||||||
//'prefer-template': 'error',
|
//"prefer-template": "error",
|
||||||
|
"template-curly-spacing": [ "warn", "never" ],
|
||||||
"comma-dangle": [ "warn", "only-multiline" ],
|
"comma-dangle": [ "warn", "only-multiline" ],
|
||||||
"no-empty": [ "error", {
|
"no-empty": [ "error", {
|
||||||
"allowEmptyCatch": true
|
"allowEmptyCatch": true
|
||||||
|
48
.github/workflows/auto-test.yml
vendored
48
.github/workflows/auto-test.yml
vendored
@@ -22,19 +22,18 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, ubuntu-latest, windows-latest, ARM64]
|
os: [macos-latest, ubuntu-latest, windows-latest, ARM64]
|
||||||
node: [ 14, 20 ]
|
node: [ 16, 20.5 ]
|
||||||
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- run: git config --global core.autocrlf false # Mainly for Windows
|
- run: git config --global core.autocrlf false # Mainly for Windows
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Use Node.js ${{ matrix.node }}
|
- name: Use Node.js ${{ matrix.node }}
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node }}
|
node-version: ${{ matrix.node }}
|
||||||
- run: npm install npm@9 -g
|
- run: npm ci
|
||||||
- run: npm install
|
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
- run: npm test
|
- run: npm test
|
||||||
env:
|
env:
|
||||||
@@ -50,18 +49,17 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ ARMv7 ]
|
os: [ ARMv7 ]
|
||||||
node: [ 14, 20 ]
|
node: [ 16, 20.5 ]
|
||||||
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- run: git config --global core.autocrlf false # Mainly for Windows
|
- run: git config --global core.autocrlf false # Mainly for Windows
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Use Node.js ${{ matrix.node }}
|
- name: Use Node.js ${{ matrix.node }}
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node }}
|
node-version: ${{ matrix.node }}
|
||||||
- run: npm install npm@9 -g
|
|
||||||
- run: npm ci --production
|
- run: npm ci --production
|
||||||
|
|
||||||
check-linters:
|
check-linters:
|
||||||
@@ -69,27 +67,27 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- run: git config --global core.autocrlf false # Mainly for Windows
|
- run: git config --global core.autocrlf false # Mainly for Windows
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Use Node.js 14
|
- name: Use Node.js 20
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 14
|
node-version: 20.5
|
||||||
- run: npm install
|
- run: npm ci
|
||||||
- run: npm run lint
|
- run: npm run lint:prod
|
||||||
|
|
||||||
e2e-tests:
|
e2e-tests:
|
||||||
needs: [ check-linters ]
|
needs: [ check-linters ]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- run: git config --global core.autocrlf false # Mainly for Windows
|
- run: git config --global core.autocrlf false # Mainly for Windows
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Use Node.js 14
|
- name: Use Node.js 16
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 14
|
node-version: 16
|
||||||
- run: npm install
|
- run: npm ci
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
- run: npm run cy:test
|
- run: npm run cy:test
|
||||||
|
|
||||||
@@ -98,12 +96,12 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- run: git config --global core.autocrlf false # Mainly for Windows
|
- run: git config --global core.autocrlf false # Mainly for Windows
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Use Node.js 14
|
- name: Use Node.js 16
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 14
|
node-version: 16
|
||||||
- run: npm install
|
- run: npm ci
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
- run: npm run cy:run:unit
|
- run: npm run cy:run:unit
|
||||||
|
4
.github/workflows/close-incorrect-issue.yml
vendored
4
.github/workflows/close-incorrect-issue.yml
vendored
@@ -14,10 +14,10 @@ jobs:
|
|||||||
node-version: [16]
|
node-version: [16]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
|
6
.github/workflows/json-yaml-validate.yml
vendored
6
.github/workflows/json-yaml-validate.yml
vendored
@@ -6,7 +6,7 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
- 2.0.X
|
- 1.23.X
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
@@ -17,11 +17,11 @@ jobs:
|
|||||||
json-yaml-validate:
|
json-yaml-validate:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: json-yaml-validate
|
- name: json-yaml-validate
|
||||||
id: json-yaml-validate
|
id: json-yaml-validate
|
||||||
uses: GrantBirki/json-yaml-validate@v1.3.0
|
uses: GrantBirki/json-yaml-validate@v2.4.0
|
||||||
with:
|
with:
|
||||||
comment: "true" # enable comment mode
|
comment: "true" # enable comment mode
|
||||||
exclude_file: ".github/config/exclude.txt" # gitignore style file for exclusions
|
exclude_file: ".github/config/exclude.txt" # gitignore style file for exclusions
|
||||||
|
2
.github/workflows/stale-bot.yml
vendored
2
.github/workflows/stale-bot.yml
vendored
@@ -9,7 +9,7 @@ jobs:
|
|||||||
stale:
|
stale:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/stale@v7
|
- uses: actions/stale@v8
|
||||||
with:
|
with:
|
||||||
stale-issue-message: 'We are clearing up our old issues and your ticket has been open for 3 months with no activity. Remove stale label or comment or this will be closed in 2 days.'
|
stale-issue-message: 'We are clearing up our old issues and your ticket has been open for 3 months with no activity. Remove stale label or comment or this will be closed in 2 days.'
|
||||||
close-issue-message: 'This issue was closed because it has been stalled for 2 days with no activity.'
|
close-issue-message: 'This issue was closed because it has been stalled for 2 days with no activity.'
|
||||||
|
@@ -3,7 +3,6 @@ import vue from "@vitejs/plugin-vue";
|
|||||||
import { defineConfig } from "vite";
|
import { defineConfig } from "vite";
|
||||||
import visualizer from "rollup-plugin-visualizer";
|
import visualizer from "rollup-plugin-visualizer";
|
||||||
import viteCompression from "vite-plugin-compression";
|
import viteCompression from "vite-plugin-compression";
|
||||||
import commonjs from "vite-plugin-commonjs";
|
|
||||||
|
|
||||||
const postCssScss = require("postcss-scss");
|
const postCssScss = require("postcss-scss");
|
||||||
const postcssRTLCSS = require("postcss-rtlcss");
|
const postcssRTLCSS = require("postcss-rtlcss");
|
||||||
@@ -22,7 +21,6 @@ export default defineConfig({
|
|||||||
"CODESPACE_NAME": JSON.stringify(process.env.CODESPACE_NAME),
|
"CODESPACE_NAME": JSON.stringify(process.env.CODESPACE_NAME),
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
commonjs(),
|
|
||||||
vue(),
|
vue(),
|
||||||
legacy({
|
legacy({
|
||||||
targets: [ "since 2015" ],
|
targets: [ "since 2015" ],
|
||||||
|
18
db/patch-monitor-tls-info-add-fk.sql
Normal file
18
db/patch-monitor-tls-info-add-fk.sql
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
PRAGMA writable_schema = TRUE;
|
||||||
|
|
||||||
|
UPDATE
|
||||||
|
SQLITE_MASTER
|
||||||
|
SET
|
||||||
|
sql = replace(sql,
|
||||||
|
'monitor_id INTEGER NOT NULL',
|
||||||
|
'monitor_id INTEGER NOT NULL REFERENCES [monitor] ([id]) ON DELETE CASCADE ON UPDATE CASCADE'
|
||||||
|
)
|
||||||
|
WHERE
|
||||||
|
name = 'monitor_tls_info'
|
||||||
|
AND type = 'table';
|
||||||
|
|
||||||
|
PRAGMA writable_schema = RESET;
|
||||||
|
|
||||||
|
COMMIT;
|
@@ -27,7 +27,7 @@ RUN apt-get update && \
|
|||||||
ca-certificates \
|
ca-certificates \
|
||||||
sudo \
|
sudo \
|
||||||
nscd && \
|
nscd && \
|
||||||
pip3 --no-cache-dir install apprise==1.4.5 && \
|
pip3 --no-cache-dir install apprise==1.6.0 && \
|
||||||
rm -rf /var/lib/apt/lists/* && \
|
rm -rf /var/lib/apt/lists/* && \
|
||||||
apt --yes autoremove
|
apt --yes autoremove
|
||||||
|
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
* ⚠️ Deprecated: Changed to healthcheck.go, it will be deleted in the future.
|
* ⚠️ Deprecated: Changed to healthcheck.go, it will be deleted in the future.
|
||||||
* This script should be run after a period of time (180s), because the server may need some time to prepare.
|
* This script should be run after a period of time (180s), because the server may need some time to prepare.
|
||||||
*/
|
*/
|
||||||
const { FBSD } = require("../server/util-server");
|
const FBSD = /^freebsd/.test(process.platform);
|
||||||
|
|
||||||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
||||||
|
|
||||||
|
44
extra/reformat-changelog.js
Normal file
44
extra/reformat-changelog.js
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
// Generate on GitHub
|
||||||
|
const input = `
|
||||||
|
* Add Korean translation by @Alanimdeo in https://github.com/louislam/dockge/pull/86
|
||||||
|
`;
|
||||||
|
|
||||||
|
const template = `
|
||||||
|
### 🆕 New Features
|
||||||
|
|
||||||
|
### 💇♀️ Improvements
|
||||||
|
|
||||||
|
### 🐞 Bug Fixes
|
||||||
|
|
||||||
|
### ⬆️ Security Fixes
|
||||||
|
|
||||||
|
### 🦎 Translation Contributions
|
||||||
|
|
||||||
|
### Others
|
||||||
|
- Other small changes, code refactoring and comment/doc updates in this repo:
|
||||||
|
`;
|
||||||
|
|
||||||
|
const lines = input.split("\n").filter((line) => line.trim() !== "");
|
||||||
|
|
||||||
|
for (const line of lines) {
|
||||||
|
// Split the last " by "
|
||||||
|
const usernamePullRequesURL = line.split(" by ").pop();
|
||||||
|
|
||||||
|
if (!usernamePullRequesURL) {
|
||||||
|
console.log("Unable to parse", line);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const [ username, pullRequestURL ] = usernamePullRequesURL.split(" in ");
|
||||||
|
const pullRequestID = "#" + pullRequestURL.split("/").pop();
|
||||||
|
let message = line.split(" by ").shift();
|
||||||
|
|
||||||
|
if (!message) {
|
||||||
|
console.log("Unable to parse", line);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
message = message.split("* ").pop();
|
||||||
|
console.log("-", pullRequestID, message, `(Thanks ${username})`);
|
||||||
|
}
|
||||||
|
console.log(template);
|
@@ -5,6 +5,8 @@ const { R } = require("redbean-node");
|
|||||||
const readline = require("readline");
|
const readline = require("readline");
|
||||||
const { initJWTSecret } = require("../server/util-server");
|
const { initJWTSecret } = require("../server/util-server");
|
||||||
const User = require("../server/model/user");
|
const User = require("../server/model/user");
|
||||||
|
const { io } = require("socket.io-client");
|
||||||
|
const { localWebSocketURL } = require("../server/config");
|
||||||
const args = require("args-parser")(process.argv);
|
const args = require("args-parser")(process.argv);
|
||||||
const rl = readline.createInterface({
|
const rl = readline.createInterface({
|
||||||
input: process.stdin,
|
input: process.stdin,
|
||||||
@@ -36,12 +38,16 @@ const main = async () => {
|
|||||||
// Reset all sessions by reset jwt secret
|
// Reset all sessions by reset jwt secret
|
||||||
await initJWTSecret();
|
await initJWTSecret();
|
||||||
|
|
||||||
|
// Disconnect all other socket clients of the user
|
||||||
|
await disconnectAllSocketClients(user.username, password);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
console.log("Passwords do not match, please try again.");
|
console.log("Passwords do not match, please try again.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log("Password reset successfully.");
|
console.log("Password reset successfully.");
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Error: " + e.message);
|
console.error("Error: " + e.message);
|
||||||
@@ -66,6 +72,44 @@ function question(question) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function disconnectAllSocketClients(username, password) {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
console.log("Connecting to " + localWebSocketURL + " to disconnect all other socket clients");
|
||||||
|
|
||||||
|
// Disconnect all socket connections
|
||||||
|
const socket = io(localWebSocketURL, {
|
||||||
|
reconnection: false,
|
||||||
|
timeout: 5000,
|
||||||
|
});
|
||||||
|
socket.on("connect", () => {
|
||||||
|
socket.emit("login", {
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
}, (res) => {
|
||||||
|
if (res.ok) {
|
||||||
|
console.log("Logged in.");
|
||||||
|
socket.emit("disconnectOtherSocketClients");
|
||||||
|
} else {
|
||||||
|
console.warn("Login failed.");
|
||||||
|
console.warn("Please restart the server to disconnect all sessions.");
|
||||||
|
}
|
||||||
|
socket.close();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on("connect_error", function () {
|
||||||
|
// The localWebSocketURL is not guaranteed to be working for some complicated Uptime Kuma setup
|
||||||
|
// Ask the user to restart the server manually
|
||||||
|
console.warn("Failed to connect to " + localWebSocketURL);
|
||||||
|
console.warn("Please restart the server to disconnect all sessions manually.");
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
socket.on("disconnect", () => {
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (!process.env.TEST_BACKEND) {
|
if (!process.env.TEST_BACKEND) {
|
||||||
main();
|
main();
|
||||||
}
|
}
|
||||||
|
11437
package-lock.json
generated
11437
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
42
package.json
42
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "uptime-kuma",
|
"name": "uptime-kuma",
|
||||||
"version": "1.23.5",
|
"version": "1.23.16",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -13,16 +13,18 @@
|
|||||||
"install-legacy": "npm install",
|
"install-legacy": "npm install",
|
||||||
"update-legacy": "npm update",
|
"update-legacy": "npm update",
|
||||||
"lint:js": "eslint --ext \".js,.vue\" --ignore-path .gitignore .",
|
"lint:js": "eslint --ext \".js,.vue\" --ignore-path .gitignore .",
|
||||||
|
"lint:js-prod": "npm run lint:js -- --max-warnings 0",
|
||||||
"lint-fix:js": "eslint --ext \".js,.vue\" --fix --ignore-path .gitignore .",
|
"lint-fix:js": "eslint --ext \".js,.vue\" --fix --ignore-path .gitignore .",
|
||||||
"lint:style": "stylelint \"**/*.{vue,css,scss}\" --ignore-path .gitignore",
|
"lint:style": "stylelint \"**/*.{vue,css,scss}\" --ignore-path .gitignore",
|
||||||
"lint-fix:style": "stylelint \"**/*.{vue,css,scss}\" --fix --ignore-path .gitignore",
|
"lint-fix:style": "stylelint \"**/*.{vue,css,scss}\" --fix --ignore-path .gitignore",
|
||||||
"lint": "npm run lint:js && npm run lint:style",
|
"lint": "npm run lint:js && npm run lint:style",
|
||||||
|
"lint:prod": "npm run lint:js-prod && npm run lint:style",
|
||||||
"dev": "concurrently -k -r \"wait-on tcp:3000 && npm run start-server-dev \" \"npm run start-frontend-dev\"",
|
"dev": "concurrently -k -r \"wait-on tcp:3000 && npm run start-server-dev \" \"npm run start-frontend-dev\"",
|
||||||
"start-frontend-dev": "cross-env NODE_ENV=development vite --host --config ./config/vite.config.js",
|
"start-frontend-dev": "cross-env NODE_ENV=development vite --host --config ./config/vite.config.js",
|
||||||
"start-frontend-devcontainer": "cross-env NODE_ENV=development DEVCONTAINER=1 vite --host --config ./config/vite.config.js",
|
"start-frontend-devcontainer": "cross-env NODE_ENV=development DEVCONTAINER=1 vite --host --config ./config/vite.config.js",
|
||||||
"start": "npm run start-server",
|
"start": "npm run start-server",
|
||||||
"start-server": "node server/server.js",
|
"start-server": "node server/server.js",
|
||||||
"start-server-dev": "cross-env NODE_ENV=development node server/server.js",
|
"start-server-dev": "cross-env NODE_ENV=development node server/server.js --data-dir=./data/v1/",
|
||||||
"build": "vite build --config ./config/vite.config.js",
|
"build": "vite build --config ./config/vite.config.js",
|
||||||
"test": "node test/prepare-test-server.js && npm run jest-backend",
|
"test": "node test/prepare-test-server.js && npm run jest-backend",
|
||||||
"test-with-build": "npm run build && npm test",
|
"test-with-build": "npm run build && npm test",
|
||||||
@@ -40,7 +42,7 @@
|
|||||||
"build-docker-nightly-amd64": "docker buildx build -f docker/dockerfile --platform linux/amd64 -t louislam/uptime-kuma:nightly-amd64 --target nightly . --push --progress plain",
|
"build-docker-nightly-amd64": "docker buildx build -f docker/dockerfile --platform linux/amd64 -t louislam/uptime-kuma:nightly-amd64 --target nightly . --push --progress plain",
|
||||||
"build-docker-pr-test": "docker buildx build -f docker/dockerfile --platform linux/amd64,linux/arm64 -t louislam/uptime-kuma:pr-test --target pr-test . --push",
|
"build-docker-pr-test": "docker buildx build -f docker/dockerfile --platform linux/amd64,linux/arm64 -t louislam/uptime-kuma:pr-test --target pr-test . --push",
|
||||||
"upload-artifacts": "docker buildx build -f docker/dockerfile --platform linux/amd64 -t louislam/uptime-kuma:upload-artifact --build-arg VERSION --build-arg GITHUB_TOKEN --target upload-artifact . --progress plain",
|
"upload-artifacts": "docker buildx build -f docker/dockerfile --platform linux/amd64 -t louislam/uptime-kuma:upload-artifact --build-arg VERSION --build-arg GITHUB_TOKEN --target upload-artifact . --progress plain",
|
||||||
"setup": "git checkout 1.23.5 && npm ci --production && npm run download-dist",
|
"setup": "git checkout 1.23.16 && npm ci --production && npm run download-dist",
|
||||||
"download-dist": "node extra/download-dist.js",
|
"download-dist": "node extra/download-dist.js",
|
||||||
"mark-as-nightly": "node extra/mark-as-nightly.js",
|
"mark-as-nightly": "node extra/mark-as-nightly.js",
|
||||||
"reset-password": "node extra/reset-password.js",
|
"reset-password": "node extra/reset-password.js",
|
||||||
@@ -72,21 +74,22 @@
|
|||||||
"cypress-open": "concurrently -k -r \"node test/prepare-test-server.js && node server/server.js --port=3002 --data-dir=./data/test/\" \"cypress open --config-file ./config/cypress.config.js\"",
|
"cypress-open": "concurrently -k -r \"node test/prepare-test-server.js && node server/server.js --port=3002 --data-dir=./data/test/\" \"cypress open --config-file ./config/cypress.config.js\"",
|
||||||
"build-healthcheck-armv7": "cross-env GOOS=linux GOARCH=arm GOARM=7 go build -x -o ./extra/healthcheck-armv7 ./extra/healthcheck.go",
|
"build-healthcheck-armv7": "cross-env GOOS=linux GOARCH=arm GOARM=7 go build -x -o ./extra/healthcheck-armv7 ./extra/healthcheck.go",
|
||||||
"deploy-demo-server": "node extra/deploy-demo-server.js",
|
"deploy-demo-server": "node extra/deploy-demo-server.js",
|
||||||
"sort-contributors": "node extra/sort-contributors.js"
|
"sort-contributors": "node extra/sort-contributors.js",
|
||||||
|
"start-server-node14-win": "private\\node14\\node.exe server/server.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@grpc/grpc-js": "~1.7.3",
|
"@grpc/grpc-js": "~1.8.22",
|
||||||
"@louislam/ping": "~0.4.4-mod.1",
|
"@louislam/ping": "~0.4.4-mod.1",
|
||||||
"@louislam/sqlite3": "15.1.6",
|
"@louislam/sqlite3": "15.1.6",
|
||||||
"args-parser": "~1.3.0",
|
"args-parser": "~1.3.0",
|
||||||
"axios": "~0.27.0",
|
"axios": "~0.28.1",
|
||||||
"axios-ntlm": "1.3.0",
|
"axios-ntlm": "1.3.0",
|
||||||
"badge-maker": "~3.3.1",
|
"badge-maker": "~3.3.1",
|
||||||
"bcryptjs": "~2.4.3",
|
"bcryptjs": "~2.4.3",
|
||||||
"cacheable-lookup": "~6.0.4",
|
"cacheable-lookup": "~6.0.4",
|
||||||
"chardet": "~1.4.0",
|
"chardet": "~1.4.0",
|
||||||
"check-password-strength": "^2.0.5",
|
"check-password-strength": "^2.0.5",
|
||||||
"cheerio": "~1.0.0-rc.12",
|
"cheerio": "1.0.0-rc.12",
|
||||||
"chroma-js": "~2.4.2",
|
"chroma-js": "~2.4.2",
|
||||||
"command-exists": "~1.2.9",
|
"command-exists": "~1.2.9",
|
||||||
"compare-versions": "~3.6.0",
|
"compare-versions": "~3.6.0",
|
||||||
@@ -94,11 +97,12 @@
|
|||||||
"croner": "~6.0.5",
|
"croner": "~6.0.5",
|
||||||
"dayjs": "~1.11.5",
|
"dayjs": "~1.11.5",
|
||||||
"dotenv": "~16.0.3",
|
"dotenv": "~16.0.3",
|
||||||
"express": "~4.17.3",
|
"express": "~4.21.0",
|
||||||
"express-basic-auth": "~1.2.1",
|
"express-basic-auth": "~1.2.1",
|
||||||
"express-static-gzip": "~2.1.7",
|
"express-static-gzip": "~2.1.7",
|
||||||
"form-data": "~4.0.0",
|
"form-data": "~4.0.0",
|
||||||
"gamedig": "~4.1.0",
|
"gamedig": "^4.2.0",
|
||||||
|
"html-escaper": "^3.0.3",
|
||||||
"http-graceful-shutdown": "~3.1.7",
|
"http-graceful-shutdown": "~3.1.7",
|
||||||
"http-proxy-agent": "~5.0.0",
|
"http-proxy-agent": "~5.0.0",
|
||||||
"https-proxy-agent": "~5.0.1",
|
"https-proxy-agent": "~5.0.1",
|
||||||
@@ -114,11 +118,11 @@
|
|||||||
"mongodb": "~4.17.1",
|
"mongodb": "~4.17.1",
|
||||||
"mqtt": "~4.3.7",
|
"mqtt": "~4.3.7",
|
||||||
"mssql": "~8.1.4",
|
"mssql": "~8.1.4",
|
||||||
"mysql2": "~3.6.2",
|
"mysql2": "~3.9.6",
|
||||||
"nanoid": "~3.3.4",
|
"nanoid": "~3.3.4",
|
||||||
"node-cloudflared-tunnel": "~1.0.9",
|
"node-cloudflared-tunnel": "~1.0.9",
|
||||||
"node-radius-client": "~1.0.0",
|
"node-radius-client": "~1.0.0",
|
||||||
"nodemailer": "~6.6.5",
|
"nodemailer": "~6.9.13",
|
||||||
"nostr-tools": "^1.13.1",
|
"nostr-tools": "^1.13.1",
|
||||||
"notp": "~2.0.3",
|
"notp": "~2.0.3",
|
||||||
"openid-client": "^5.4.2",
|
"openid-client": "^5.4.2",
|
||||||
@@ -128,21 +132,22 @@
|
|||||||
"playwright-core": "~1.35.1",
|
"playwright-core": "~1.35.1",
|
||||||
"prom-client": "~13.2.0",
|
"prom-client": "~13.2.0",
|
||||||
"prometheus-api-metrics": "~3.2.1",
|
"prometheus-api-metrics": "~3.2.1",
|
||||||
|
"promisify-child-process": "~4.1.2",
|
||||||
"protobufjs": "~7.2.4",
|
"protobufjs": "~7.2.4",
|
||||||
"qs": "~6.10.4",
|
"qs": "~6.10.4",
|
||||||
"redbean-node": "~0.3.0",
|
"redbean-node": "~0.3.0",
|
||||||
"redis": "~4.5.1",
|
"redis": "~4.5.1",
|
||||||
"semver": "~7.5.4",
|
"semver": "~7.5.4",
|
||||||
"socket.io": "~4.6.1",
|
"socket.io": "~4.8.0",
|
||||||
"socket.io-client": "~4.6.1",
|
"socket.io-client": "~4.8.0",
|
||||||
"socks-proxy-agent": "6.1.1",
|
"socks-proxy-agent": "6.1.1",
|
||||||
"tar": "~6.1.11",
|
"tar": "~6.2.1",
|
||||||
"tcp-ping": "~0.1.1",
|
"tcp-ping": "~0.1.1",
|
||||||
"thirty-two": "~1.0.2",
|
"thirty-two": "~1.0.2",
|
||||||
"ws": "^8.13.0"
|
"ws": "^8.13.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@actions/github": "~5.0.1",
|
"@actions/github": "~5.1.1",
|
||||||
"@babel/eslint-parser": "^7.22.7",
|
"@babel/eslint-parser": "^7.22.7",
|
||||||
"@babel/preset-env": "^7.15.8",
|
"@babel/preset-env": "^7.15.8",
|
||||||
"@fortawesome/fontawesome-svg-core": "~1.2.36",
|
"@fortawesome/fontawesome-svg-core": "~1.2.36",
|
||||||
@@ -166,7 +171,7 @@
|
|||||||
"cypress": "^13.2.0",
|
"cypress": "^13.2.0",
|
||||||
"delay": "^5.0.0",
|
"delay": "^5.0.0",
|
||||||
"dns2": "~2.0.1",
|
"dns2": "~2.0.1",
|
||||||
"dompurify": "~2.4.3",
|
"dompurify": "~3.1.7",
|
||||||
"eslint": "~8.14.0",
|
"eslint": "~8.14.0",
|
||||||
"eslint-plugin-vue": "~8.7.1",
|
"eslint-plugin-vue": "~8.7.1",
|
||||||
"favico.js": "~0.3.10",
|
"favico.js": "~0.3.10",
|
||||||
@@ -186,8 +191,7 @@
|
|||||||
"timezones-list": "~3.0.1",
|
"timezones-list": "~3.0.1",
|
||||||
"typescript": "~4.4.4",
|
"typescript": "~4.4.4",
|
||||||
"v-pagination-3": "~0.1.7",
|
"v-pagination-3": "~0.1.7",
|
||||||
"vite": "~4.4.1",
|
"vite": "~5.2.8",
|
||||||
"vite-plugin-commonjs": "^0.8.0",
|
|
||||||
"vite-plugin-compression": "^0.5.1",
|
"vite-plugin-compression": "^0.5.1",
|
||||||
"vue": "~3.3.4",
|
"vue": "~3.3.4",
|
||||||
"vue-chartjs": "~5.2.0",
|
"vue-chartjs": "~5.2.0",
|
||||||
@@ -201,7 +205,7 @@
|
|||||||
"vue-router": "~4.0.14",
|
"vue-router": "~4.0.14",
|
||||||
"vue-toastification": "~2.0.0-rc.5",
|
"vue-toastification": "~2.0.0-rc.5",
|
||||||
"vuedraggable": "~4.1.0",
|
"vuedraggable": "~4.1.0",
|
||||||
"wait-on": "^6.0.1",
|
"wait-on": "^7.2.0",
|
||||||
"whatwg-url": "~12.0.1"
|
"whatwg-url": "~12.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,9 @@
|
|||||||
<svg width="640" height="640" viewBox="0 0 640 640" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg width="640" height="640" viewBox="0 0 640 640" xml:space="preserve" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path d="M490.4 235.64C544.09 358.38 544.09 435.34 490.4 466.5C409.85 513.24 199.96 527.49 139.54 455.64C99.2601 407.74 99.2601 334.4 139.54 235.64C180.5 168.18 238.71 134.45 314.17 134.45C389.64 134.45 448.38 168.18 490.4 235.64Z" fill="url(#paint0_linear_381_799)"/>
|
<g transform="matrix(1 0 0 1 320 320)">
|
||||||
<path d="M490.4 235.64C544.09 358.38 544.09 435.34 490.4 466.5C409.85 513.24 199.96 527.49 139.54 455.64C99.2601 407.74 99.2601 334.4 139.54 235.64C180.5 168.18 238.71 134.45 314.17 134.45C389.64 134.45 448.38 168.18 490.4 235.64Z" stroke="#F2F2F2" stroke-opacity="0.51" stroke-width="200"/>
|
<linearGradient id="S3" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1 0 0 1 -319.99875 -320.0001577393)" x1="259.78" y1="261.15" x2="463.85" y2="456.49">
|
||||||
<defs>
|
|
||||||
<linearGradient id="paint0_linear_381_799" x1="259.78" y1="261.15" x2="463.85" y2="456.49" gradientUnits="userSpaceOnUse">
|
|
||||||
<stop stop-color="#5CDD8B"/>
|
<stop stop-color="#5CDD8B"/>
|
||||||
<stop offset="1" stop-color="#86E6A9"/>
|
<stop offset="1" stop-color="#86E6A9"/>
|
||||||
</linearGradient>
|
</linearGradient>
|
||||||
</defs>
|
<path style="stroke: rgb(242,242,242); stroke-opacity: 0.51; stroke-width: 200; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: url(#S3); fill-rule: nonzero; opacity: 1;" transform=" translate(0, 0)" d="M 170.40125 -84.36016 C 224.09125 38.37984 224.09125 115.33984 170.40125 146.49984 C 89.85125000000001 193.23984000000002 -120.03875 207.48984000000002 -180.45875 135.63984 C -220.73875 87.73983999999999 -220.73875 14.399839999999998 -180.45875 -84.36016000000001 C -139.49875 -151.82016 -81.28875000000001 -185.55016 -5.828750000000014 -185.55016 C 69.64124999999999 -185.55016 128.38125 -151.82016000000002 170.40124999999998 -84.36016000000001 z" stroke-linecap="round" />
|
||||||
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 893 B After Width: | Height: | Size: 1.1 KiB |
@@ -1,29 +1,42 @@
|
|||||||
|
const isFreeBSD = /^freebsd/.test(process.platform);
|
||||||
|
|
||||||
// Interop with browser
|
// Interop with browser
|
||||||
const args = (typeof process !== "undefined") ? require("args-parser")(process.argv) : {};
|
const args = (typeof process !== "undefined") ? require("args-parser")(process.argv) : {};
|
||||||
const demoMode = args["demo"] || false;
|
|
||||||
|
|
||||||
const badgeConstants = {
|
// If host is omitted, the server will accept connections on the unspecified IPv6 address (::) when IPv6 is available and the unspecified IPv4 address (0.0.0.0) otherwise.
|
||||||
naColor: "#999",
|
// Dual-stack support for (::)
|
||||||
defaultUpColor: "#66c20a",
|
// Also read HOST if not FreeBSD, as HOST is a system environment variable in FreeBSD
|
||||||
defaultWarnColor: "#eed202",
|
let hostEnv = isFreeBSD ? null : process.env.HOST;
|
||||||
defaultDownColor: "#c2290a",
|
const hostname = args.host || process.env.UPTIME_KUMA_HOST || hostEnv;
|
||||||
defaultPendingColor: "#f8a306",
|
|
||||||
defaultMaintenanceColor: "#1747f5",
|
const port = [ args.port, process.env.UPTIME_KUMA_PORT, process.env.PORT, 3001 ]
|
||||||
defaultPingColor: "blue", // as defined by badge-maker / shields.io
|
.map(portValue => parseInt(portValue))
|
||||||
defaultStyle: "flat",
|
.find(portValue => !isNaN(portValue));
|
||||||
defaultPingValueSuffix: "ms",
|
|
||||||
defaultPingLabelSuffix: "h",
|
const sslKey = args["ssl-key"] || process.env.UPTIME_KUMA_SSL_KEY || process.env.SSL_KEY || undefined;
|
||||||
defaultUptimeValueSuffix: "%",
|
const sslCert = args["ssl-cert"] || process.env.UPTIME_KUMA_SSL_CERT || process.env.SSL_CERT || undefined;
|
||||||
defaultUptimeLabelSuffix: "h",
|
const sslKeyPassphrase = args["ssl-key-passphrase"] || process.env.UPTIME_KUMA_SSL_KEY_PASSPHRASE || process.env.SSL_KEY_PASSPHRASE || undefined;
|
||||||
defaultCertExpValueSuffix: " days",
|
|
||||||
defaultCertExpLabelSuffix: "h",
|
const isSSL = sslKey && sslCert;
|
||||||
// Values Come From Default Notification Times
|
|
||||||
defaultCertExpireWarnDays: "14",
|
function getLocalWebSocketURL() {
|
||||||
defaultCertExpireDownDays: "7"
|
const protocol = isSSL ? "wss" : "ws";
|
||||||
};
|
const host = hostname || "localhost";
|
||||||
|
return `${protocol}://${host}:${port}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const localWebSocketURL = getLocalWebSocketURL();
|
||||||
|
|
||||||
|
const demoMode = args["demo"] || false;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
args,
|
args,
|
||||||
|
hostname,
|
||||||
|
port,
|
||||||
|
sslKey,
|
||||||
|
sslCert,
|
||||||
|
sslKeyPassphrase,
|
||||||
|
isSSL,
|
||||||
|
localWebSocketURL,
|
||||||
demoMode,
|
demoMode,
|
||||||
badgeConstants,
|
|
||||||
};
|
};
|
||||||
|
@@ -84,6 +84,7 @@ class Database {
|
|||||||
"patch-notification-config.sql": true,
|
"patch-notification-config.sql": true,
|
||||||
"patch-fix-kafka-producer-booleans.sql": true,
|
"patch-fix-kafka-producer-booleans.sql": true,
|
||||||
"patch-timeout.sql": true,
|
"patch-timeout.sql": true,
|
||||||
|
"patch-monitor-tls-info-add-fk.sql": true,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
const jsesc = require("jsesc");
|
const jsesc = require("jsesc");
|
||||||
|
const { escape } = require("html-escaper");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a string that represents the javascript that is required to insert the Google Analytics scripts
|
* Returns a string that represents the javascript that is required to insert the Google Analytics scripts
|
||||||
@@ -7,15 +8,18 @@ const jsesc = require("jsesc");
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
function getGoogleAnalyticsScript(tagId) {
|
function getGoogleAnalyticsScript(tagId) {
|
||||||
let escapedTagId = jsesc(tagId, { isScriptContext: true });
|
let escapedTagIdJS = jsesc(tagId, { isScriptContext: true });
|
||||||
|
|
||||||
if (escapedTagId) {
|
if (escapedTagIdJS) {
|
||||||
escapedTagId = escapedTagId.trim();
|
escapedTagIdJS = escapedTagIdJS.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Escape the tag ID for use in an HTML attribute.
|
||||||
|
let escapedTagIdHTMLAttribute = escape(tagId);
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<script async src="https://www.googletagmanager.com/gtag/js?id=${escapedTagId}"></script>
|
<script async src="https://www.googletagmanager.com/gtag/js?id=${escapedTagIdHTMLAttribute}"></script>
|
||||||
<script>window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date());gtag('config', '${escapedTagId}'); </script>
|
<script>window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date());gtag('config', '${escapedTagIdJS}'); </script>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,7 +3,7 @@ const dayjs = require("dayjs");
|
|||||||
const axios = require("axios");
|
const axios = require("axios");
|
||||||
const { Prometheus } = require("../prometheus");
|
const { Prometheus } = require("../prometheus");
|
||||||
const { log, UP, DOWN, PENDING, MAINTENANCE, flipStatus, TimeLogger, MAX_INTERVAL_SECOND, MIN_INTERVAL_SECOND,
|
const { log, UP, DOWN, PENDING, MAINTENANCE, flipStatus, TimeLogger, MAX_INTERVAL_SECOND, MIN_INTERVAL_SECOND,
|
||||||
SQL_DATETIME_FORMAT, isDev, sleep, getRandomInt
|
SQL_DATETIME_FORMAT
|
||||||
} = require("../../src/util");
|
} = require("../../src/util");
|
||||||
const { tcping, ping, dnsResolve, checkCertificate, checkStatusCode, getTotalClientInRoom, setting, mssqlQuery, postgresQuery, mysqlQuery, mqttAsync, setSetting, httpNtlm, radius, grpcQuery,
|
const { tcping, ping, dnsResolve, checkCertificate, checkStatusCode, getTotalClientInRoom, setting, mssqlQuery, postgresQuery, mysqlQuery, mqttAsync, setSetting, httpNtlm, radius, grpcQuery,
|
||||||
redisPingAsync, mongodbPing, kafkaProducerAsync, getOidcTokenClientCredentials, rootCertificatesFingerprints, axiosAbortSignal
|
redisPingAsync, mongodbPing, kafkaProducerAsync, getOidcTokenClientCredentials, rootCertificatesFingerprints, axiosAbortSignal
|
||||||
@@ -22,6 +22,7 @@ const { UptimeCacheList } = require("../uptime-cache-list");
|
|||||||
const Gamedig = require("gamedig");
|
const Gamedig = require("gamedig");
|
||||||
const jsonata = require("jsonata");
|
const jsonata = require("jsonata");
|
||||||
const jwt = require("jsonwebtoken");
|
const jwt = require("jsonwebtoken");
|
||||||
|
const crypto = require("crypto");
|
||||||
|
|
||||||
const rootCertificates = rootCertificatesFingerprints();
|
const rootCertificates = rootCertificatesFingerprints();
|
||||||
|
|
||||||
@@ -229,10 +230,12 @@ class Monitor extends BeanModel {
|
|||||||
/**
|
/**
|
||||||
* Encode user and password to Base64 encoding
|
* Encode user and password to Base64 encoding
|
||||||
* for HTTP "basic" auth, as per RFC-7617
|
* for HTTP "basic" auth, as per RFC-7617
|
||||||
|
* @param {string|null} user - The username (nullable if not changed by a user)
|
||||||
|
* @param {string|null} pass - The password (nullable if not changed by a user)
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
encodeBase64(user, pass) {
|
encodeBase64(user, pass) {
|
||||||
return Buffer.from(user + ":" + pass).toString("base64");
|
return Buffer.from(`${user || ""}:${pass || ""}`).toString("base64");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -328,16 +331,6 @@ class Monitor extends BeanModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Evil
|
|
||||||
if (isDev) {
|
|
||||||
if (process.env.EVIL_RANDOM_MONITOR_SLEEP === "SURE") {
|
|
||||||
if (getRandomInt(0, 100) === 0) {
|
|
||||||
log.debug("evil", `[${this.name}] Evil mode: Random sleep: ` + beatInterval * 10000);
|
|
||||||
await sleep(beatInterval * 10000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Expose here for prometheus update
|
// Expose here for prometheus update
|
||||||
// undefined if not https
|
// undefined if not https
|
||||||
let tlsInfo = undefined;
|
let tlsInfo = undefined;
|
||||||
@@ -482,7 +475,7 @@ class Monitor extends BeanModel {
|
|||||||
validateStatus: (status) => {
|
validateStatus: (status) => {
|
||||||
return checkStatusCode(status, this.getAcceptedStatuscodes());
|
return checkStatusCode(status, this.getAcceptedStatuscodes());
|
||||||
},
|
},
|
||||||
signal: axiosAbortSignal(this.timeout * 1000),
|
signal: axiosAbortSignal((this.timeout + 10) * 1000),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (bodyValue) {
|
if (bodyValue) {
|
||||||
@@ -519,6 +512,18 @@ class Monitor extends BeanModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let tlsInfo = {};
|
||||||
|
// Store tlsInfo when secureConnect event is emitted
|
||||||
|
// The keylog event listener is a workaround to access the tlsSocket
|
||||||
|
options.httpsAgent.once("keylog", async (line, tlsSocket) => {
|
||||||
|
tlsSocket.once("secureConnect", async () => {
|
||||||
|
tlsInfo = checkCertificate(tlsSocket);
|
||||||
|
tlsInfo.valid = tlsSocket.authorized || false;
|
||||||
|
|
||||||
|
await this.handleTlsInfo(tlsInfo);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
log.debug("monitor", `[${this.name}] Axios Options: ${JSON.stringify(options)}`);
|
log.debug("monitor", `[${this.name}] Axios Options: ${JSON.stringify(options)}`);
|
||||||
log.debug("monitor", `[${this.name}] Axios Request`);
|
log.debug("monitor", `[${this.name}] Axios Request`);
|
||||||
|
|
||||||
@@ -528,31 +533,19 @@ class Monitor extends BeanModel {
|
|||||||
bean.msg = `${res.status} - ${res.statusText}`;
|
bean.msg = `${res.status} - ${res.statusText}`;
|
||||||
bean.ping = dayjs().valueOf() - startTime;
|
bean.ping = dayjs().valueOf() - startTime;
|
||||||
|
|
||||||
// Check certificate if https is used
|
// fallback for if kelog event is not emitted, but we may still have tlsInfo,
|
||||||
let certInfoStartTime = dayjs().valueOf();
|
// e.g. if the connection is made through a proxy
|
||||||
if (this.getUrl()?.protocol === "https:") {
|
if (this.getUrl()?.protocol === "https:" && tlsInfo.valid === undefined) {
|
||||||
log.debug("monitor", `[${this.name}] Check cert`);
|
const tlsSocket = res.request.res.socket;
|
||||||
try {
|
|
||||||
let tlsInfoObject = checkCertificate(res);
|
|
||||||
tlsInfo = await this.updateTlsInfo(tlsInfoObject);
|
|
||||||
|
|
||||||
if (!this.getIgnoreTls() && this.isEnabledExpiryNotification()) {
|
if (tlsSocket) {
|
||||||
log.debug("monitor", `[${this.name}] call checkCertExpiryNotifications`);
|
tlsInfo = checkCertificate(tlsSocket);
|
||||||
await this.checkCertExpiryNotifications(tlsInfoObject);
|
tlsInfo.valid = tlsSocket.authorized || false;
|
||||||
}
|
|
||||||
|
|
||||||
} catch (e) {
|
await this.handleTlsInfo(tlsInfo);
|
||||||
if (e.message !== "No TLS certificate in response") {
|
|
||||||
log.error("monitor", "Caught error");
|
|
||||||
log.error("monitor", e.message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.env.TIMELOGGER === "1") {
|
|
||||||
log.debug("monitor", "Cert Info Query Time: " + (dayjs().valueOf() - certInfoStartTime) + "ms");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.env.UPTIME_KUMA_LOG_RESPONSE_BODY_MONITOR_ID === this.id) {
|
if (process.env.UPTIME_KUMA_LOG_RESPONSE_BODY_MONITOR_ID === this.id) {
|
||||||
log.info("monitor", res.data);
|
log.info("monitor", res.data);
|
||||||
}
|
}
|
||||||
@@ -585,8 +578,12 @@ class Monitor extends BeanModel {
|
|||||||
let data = res.data;
|
let data = res.data;
|
||||||
|
|
||||||
// convert data to object
|
// convert data to object
|
||||||
if (typeof data === "string") {
|
if (typeof data === "string" && res.headers["content-type"] !== "application/json") {
|
||||||
data = JSON.parse(data);
|
try {
|
||||||
|
data = JSON.parse(data);
|
||||||
|
} catch (_) {
|
||||||
|
// Failed to parse as JSON, just process it as a string
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let expression = jsonata(this.jsonPath);
|
let expression = jsonata(this.jsonPath);
|
||||||
@@ -937,7 +934,11 @@ class Monitor extends BeanModel {
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
||||||
bean.msg = error.message;
|
if (error?.name === "CanceledError") {
|
||||||
|
bean.msg = `timeout by AbortSignal (${this.timeout}s)`;
|
||||||
|
} else {
|
||||||
|
bean.msg = error.message;
|
||||||
|
}
|
||||||
|
|
||||||
// If UP come in here, it must be upside down mode
|
// If UP come in here, it must be upside down mode
|
||||||
// Just reset the retries
|
// Just reset the retries
|
||||||
@@ -1019,7 +1020,6 @@ class Monitor extends BeanModel {
|
|||||||
if (! this.isStop) {
|
if (! this.isStop) {
|
||||||
log.debug("monitor", `[${this.name}] SetTimeout for next check.`);
|
log.debug("monitor", `[${this.name}] SetTimeout for next check.`);
|
||||||
this.heartbeatInterval = setTimeout(safeBeat, beatInterval * 1000);
|
this.heartbeatInterval = setTimeout(safeBeat, beatInterval * 1000);
|
||||||
this.lastScheduleBeatTime = dayjs();
|
|
||||||
} else {
|
} else {
|
||||||
log.info("monitor", `[${this.name}] isStop = true, no next check.`);
|
log.info("monitor", `[${this.name}] isStop = true, no next check.`);
|
||||||
}
|
}
|
||||||
@@ -1029,9 +1029,7 @@ class Monitor extends BeanModel {
|
|||||||
/** Get a heartbeat and handle errors */
|
/** Get a heartbeat and handle errors */
|
||||||
const safeBeat = async () => {
|
const safeBeat = async () => {
|
||||||
try {
|
try {
|
||||||
this.lastStartBeatTime = dayjs();
|
|
||||||
await beat();
|
await beat();
|
||||||
this.lastEndBeatTime = dayjs();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.trace(e);
|
console.trace(e);
|
||||||
UptimeKumaServer.errorLog(e, false);
|
UptimeKumaServer.errorLog(e, false);
|
||||||
@@ -1040,9 +1038,6 @@ class Monitor extends BeanModel {
|
|||||||
if (! this.isStop) {
|
if (! this.isStop) {
|
||||||
log.info("monitor", "Try to restart the monitor");
|
log.info("monitor", "Try to restart the monitor");
|
||||||
this.heartbeatInterval = setTimeout(safeBeat, this.interval * 1000);
|
this.heartbeatInterval = setTimeout(safeBeat, this.interval * 1000);
|
||||||
this.lastScheduleBeatTime = dayjs();
|
|
||||||
} else {
|
|
||||||
log.info("monitor", "isStop = true, no next check.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1687,6 +1682,21 @@ class Monitor extends BeanModel {
|
|||||||
const parentActive = await Monitor.isParentActive(parent.id);
|
const parentActive = await Monitor.isParentActive(parent.id);
|
||||||
return parent.active && parentActive;
|
return parent.active && parentActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store TLS certificate information and check for expiry
|
||||||
|
* @param {Object} tlsInfo Information about the TLS connection
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
async handleTlsInfo(tlsInfo) {
|
||||||
|
await this.updateTlsInfo(tlsInfo);
|
||||||
|
this.prometheus?.update(null, tlsInfo);
|
||||||
|
|
||||||
|
if (!this.getIgnoreTls() && this.isEnabledExpiryNotification()) {
|
||||||
|
log.debug("monitor", `[${this.name}] call checkCertExpiryNotifications`);
|
||||||
|
await this.checkCertExpiryNotifications(tlsInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Monitor;
|
module.exports = Monitor;
|
||||||
|
@@ -9,6 +9,10 @@ const Database = require("../database");
|
|||||||
const jwt = require("jsonwebtoken");
|
const jwt = require("jsonwebtoken");
|
||||||
const config = require("../config");
|
const config = require("../config");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cached instance of a browser
|
||||||
|
* @type {import ("playwright-core").Browser}
|
||||||
|
*/
|
||||||
let browser = null;
|
let browser = null;
|
||||||
|
|
||||||
let allowedList = [];
|
let allowedList = [];
|
||||||
@@ -40,6 +44,7 @@ if (process.platform === "win32") {
|
|||||||
"/usr/bin/chromium",
|
"/usr/bin/chromium",
|
||||||
"/usr/bin/chromium-browser",
|
"/usr/bin/chromium-browser",
|
||||||
"/usr/bin/google-chrome",
|
"/usr/bin/google-chrome",
|
||||||
|
"/snap/bin/chromium", // Ubuntu
|
||||||
];
|
];
|
||||||
} else if (process.platform === "darwin") {
|
} else if (process.platform === "darwin") {
|
||||||
// TODO: Generated by GitHub Copilot, but not sure if it's correct
|
// TODO: Generated by GitHub Copilot, but not sure if it's correct
|
||||||
@@ -61,8 +66,15 @@ async function isAllowedChromeExecutable(executablePath) {
|
|||||||
return allowedList.includes(executablePath);
|
return allowedList.includes(executablePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current instance of the browser. If there isn't one, create
|
||||||
|
* it.
|
||||||
|
* @returns {Promise<import ("playwright-core").Browser>} The browser
|
||||||
|
*/
|
||||||
async function getBrowser() {
|
async function getBrowser() {
|
||||||
if (!browser) {
|
if (browser && browser.isConnected()) {
|
||||||
|
return browser;
|
||||||
|
} else {
|
||||||
let executablePath = await Settings.get("chromeExecutable");
|
let executablePath = await Settings.get("chromeExecutable");
|
||||||
|
|
||||||
executablePath = await prepareChromeExecutable(executablePath);
|
executablePath = await prepareChromeExecutable(executablePath);
|
||||||
@@ -71,8 +83,9 @@ async function getBrowser() {
|
|||||||
//headless: false,
|
//headless: false,
|
||||||
executablePath,
|
executablePath,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return browser;
|
||||||
}
|
}
|
||||||
return browser;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function prepareChromeExecutable(executablePath) {
|
async function prepareChromeExecutable(executablePath) {
|
||||||
@@ -180,6 +193,14 @@ class RealBrowserMonitorType extends MonitorType {
|
|||||||
const context = await browser.newContext();
|
const context = await browser.newContext();
|
||||||
const page = await context.newPage();
|
const page = await context.newPage();
|
||||||
|
|
||||||
|
// Prevent Local File Inclusion
|
||||||
|
// Accept only http:// and https://
|
||||||
|
// https://github.com/louislam/uptime-kuma/security/advisories/GHSA-2qgm-m29m-cj2h
|
||||||
|
let url = new URL(monitor.url);
|
||||||
|
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
||||||
|
throw new Error("Invalid url protocol, only http and https are allowed.");
|
||||||
|
}
|
||||||
|
|
||||||
const res = await page.goto(monitor.url, {
|
const res = await page.goto(monitor.url, {
|
||||||
waitUntil: "networkidle",
|
waitUntil: "networkidle",
|
||||||
timeout: monitor.interval * 1000 * 0.8,
|
timeout: monitor.interval * 1000 * 0.8,
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
const { MonitorType } = require("./monitor-type");
|
const { MonitorType } = require("./monitor-type");
|
||||||
const { UP, log } = require("../../src/util");
|
const { UP } = require("../../src/util");
|
||||||
const exec = require("child_process").exec;
|
const childProcessAsync = require("promisify-child-process");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A TailscalePing class extends the MonitorType.
|
* A TailscalePing class extends the MonitorType.
|
||||||
@@ -23,7 +23,6 @@ class TailscalePing extends MonitorType {
|
|||||||
let tailscaleOutput = await this.runTailscalePing(monitor.hostname, monitor.interval);
|
let tailscaleOutput = await this.runTailscalePing(monitor.hostname, monitor.interval);
|
||||||
this.parseTailscaleOutput(tailscaleOutput, heartbeat);
|
this.parseTailscaleOutput(tailscaleOutput, heartbeat);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
log.debug("Tailscale", err);
|
|
||||||
// trigger log function somewhere to display a notification or alert to the user (but how?)
|
// trigger log function somewhere to display a notification or alert to the user (but how?)
|
||||||
throw new Error(`Error checking Tailscale ping: ${err}`);
|
throw new Error(`Error checking Tailscale ping: ${err}`);
|
||||||
}
|
}
|
||||||
@@ -33,30 +32,24 @@ class TailscalePing extends MonitorType {
|
|||||||
* Runs the Tailscale ping command to the given URL.
|
* Runs the Tailscale ping command to the given URL.
|
||||||
*
|
*
|
||||||
* @param {string} hostname - The hostname to ping.
|
* @param {string} hostname - The hostname to ping.
|
||||||
|
* @param {number} interval
|
||||||
* @returns {Promise<string>} - A Promise that resolves to the output of the Tailscale ping command
|
* @returns {Promise<string>} - A Promise that resolves to the output of the Tailscale ping command
|
||||||
* @throws Will throw an error if the command execution encounters any error.
|
* @throws Will throw an error if the command execution encounters any error.
|
||||||
*/
|
*/
|
||||||
async runTailscalePing(hostname, interval) {
|
async runTailscalePing(hostname, interval) {
|
||||||
let cmd = `tailscale ping ${hostname}`;
|
let timeout = interval * 1000 * 0.8;
|
||||||
|
let res = await childProcessAsync.spawn("tailscale", [ "ping", "--c", "1", hostname ], {
|
||||||
log.debug("Tailscale", cmd);
|
timeout: timeout,
|
||||||
|
encoding: "utf8",
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
let timeout = interval * 1000 * 0.8;
|
|
||||||
exec(cmd, { timeout: timeout }, (error, stdout, stderr) => {
|
|
||||||
// we may need to handle more cases if tailscale reports an error that isn't necessarily an error (such as not-logged in or DERP health-related issues)
|
|
||||||
if (error) {
|
|
||||||
reject(`Execution error: ${error.message}`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (stderr) {
|
|
||||||
reject(`Error in output: ${stderr}`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
resolve(stdout);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
if (res.stderr && res.stderr.toString()) {
|
||||||
|
throw new Error(`Error in output: ${res.stderr.toString()}`);
|
||||||
|
}
|
||||||
|
if (res.stdout && res.stdout.toString()) {
|
||||||
|
return res.stdout.toString();
|
||||||
|
} else {
|
||||||
|
throw new Error("No output from Tailscale ping");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -74,7 +67,7 @@ class TailscalePing extends MonitorType {
|
|||||||
heartbeat.status = UP;
|
heartbeat.status = UP;
|
||||||
let time = line.split(" in ")[1].split(" ")[0];
|
let time = line.split(" in ")[1].split(" ")[0];
|
||||||
heartbeat.ping = parseInt(time);
|
heartbeat.ping = parseInt(time);
|
||||||
heartbeat.msg = line;
|
heartbeat.msg = "OK";
|
||||||
break;
|
break;
|
||||||
} else if (line.includes("timed out")) {
|
} else if (line.includes("timed out")) {
|
||||||
throw new Error(`Ping timed out: "${line}"`);
|
throw new Error(`Ping timed out: "${line}"`);
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
const NotificationProvider = require("./notification-provider");
|
const NotificationProvider = require("./notification-provider");
|
||||||
const childProcess = require("child_process");
|
const childProcessAsync = require("promisify-child-process");
|
||||||
|
|
||||||
class Apprise extends NotificationProvider {
|
class Apprise extends NotificationProvider {
|
||||||
|
|
||||||
@@ -11,7 +11,9 @@ class Apprise extends NotificationProvider {
|
|||||||
args.push("-t");
|
args.push("-t");
|
||||||
args.push(notification.title);
|
args.push(notification.title);
|
||||||
}
|
}
|
||||||
const s = childProcess.spawnSync("apprise", args);
|
const s = await childProcessAsync.spawn("apprise", args, {
|
||||||
|
encoding: "utf8",
|
||||||
|
});
|
||||||
|
|
||||||
const output = (s.stdout) ? s.stdout.toString() : "ERROR: maybe apprise not found";
|
const output = (s.stdout) ? s.stdout.toString() : "ERROR: maybe apprise not found";
|
||||||
|
|
||||||
|
@@ -18,7 +18,7 @@ class DingDing extends NotificationProvider {
|
|||||||
text: `## [${this.statusToString(heartbeatJSON["status"])}] ${monitorJSON["name"]} \n> ${heartbeatJSON["msg"]}\n> Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`,
|
text: `## [${this.statusToString(heartbeatJSON["status"])}] ${monitorJSON["name"]} \n> ${heartbeatJSON["msg"]}\n> Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (this.sendToDingDing(notification, params)) {
|
if (await this.sendToDingDing(notification, params)) {
|
||||||
return okMsg;
|
return okMsg;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -28,7 +28,7 @@ class DingDing extends NotificationProvider {
|
|||||||
content: msg
|
content: msg
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (this.sendToDingDing(notification, params)) {
|
if (await this.sendToDingDing(notification, params)) {
|
||||||
return okMsg;
|
return okMsg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ class DingDing extends NotificationProvider {
|
|||||||
if (result.data.errmsg === "ok") {
|
if (result.data.errmsg === "ok") {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
throw new Error(result.data.errmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -79,23 +79,25 @@ class Prometheus {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (heartbeat) {
|
||||||
monitorStatus.set(this.monitorLabelValues, heartbeat.status);
|
try {
|
||||||
} catch (e) {
|
monitorStatus.set(this.monitorLabelValues, heartbeat.status);
|
||||||
log.error("prometheus", "Caught error");
|
} catch (e) {
|
||||||
log.error("prometheus", e);
|
log.error("prometheus", "Caught error");
|
||||||
}
|
log.error("prometheus", e);
|
||||||
|
}
|
||||||
try {
|
|
||||||
if (typeof heartbeat.ping === "number") {
|
try {
|
||||||
monitorResponseTime.set(this.monitorLabelValues, heartbeat.ping);
|
if (typeof heartbeat.ping === "number") {
|
||||||
} else {
|
monitorResponseTime.set(this.monitorLabelValues, heartbeat.ping);
|
||||||
// Is it good?
|
} else {
|
||||||
monitorResponseTime.set(this.monitorLabelValues, -1);
|
// Is it good?
|
||||||
|
monitorResponseTime.set(this.monitorLabelValues, -1);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
log.error("prometheus", "Caught error");
|
||||||
|
log.error("prometheus", e);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
|
||||||
log.error("prometheus", "Caught error");
|
|
||||||
log.error("prometheus", e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -11,12 +11,11 @@ const { R } = require("redbean-node");
|
|||||||
const apicache = require("../modules/apicache");
|
const apicache = require("../modules/apicache");
|
||||||
const Monitor = require("../model/monitor");
|
const Monitor = require("../model/monitor");
|
||||||
const dayjs = require("dayjs");
|
const dayjs = require("dayjs");
|
||||||
const { UP, MAINTENANCE, DOWN, PENDING, flipStatus, log } = require("../../src/util");
|
const { UP, MAINTENANCE, DOWN, PENDING, flipStatus, log, badgeConstants } = require("../../src/util");
|
||||||
const StatusPage = require("../model/status_page");
|
const StatusPage = require("../model/status_page");
|
||||||
const { UptimeKumaServer } = require("../uptime-kuma-server");
|
const { UptimeKumaServer } = require("../uptime-kuma-server");
|
||||||
const { UptimeCacheList } = require("../uptime-cache-list");
|
const { UptimeCacheList } = require("../uptime-cache-list");
|
||||||
const { makeBadge } = require("badge-maker");
|
const { makeBadge } = require("badge-maker");
|
||||||
const { badgeConstants } = require("../config");
|
|
||||||
const { Prometheus } = require("../prometheus");
|
const { Prometheus } = require("../prometheus");
|
||||||
|
|
||||||
let router = express.Router();
|
let router = express.Router();
|
||||||
|
@@ -5,7 +5,7 @@ const StatusPage = require("../model/status_page");
|
|||||||
const { allowDevAllOrigin, sendHttpError } = require("../util-server");
|
const { allowDevAllOrigin, sendHttpError } = require("../util-server");
|
||||||
const { R } = require("redbean-node");
|
const { R } = require("redbean-node");
|
||||||
const Monitor = require("../model/monitor");
|
const Monitor = require("../model/monitor");
|
||||||
const { badgeConstants } = require("../config");
|
const { badgeConstants } = require("../../src/util");
|
||||||
const { makeBadge } = require("badge-maker");
|
const { makeBadge } = require("badge-maker");
|
||||||
|
|
||||||
let router = express.Router();
|
let router = express.Router();
|
||||||
|
@@ -48,9 +48,17 @@ if (! process.env.NODE_ENV) {
|
|||||||
process.env.NODE_ENV = "production";
|
process.env.NODE_ENV = "production";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!process.env.UPTIME_KUMA_WS_ORIGIN_CHECK) {
|
||||||
|
process.env.UPTIME_KUMA_WS_ORIGIN_CHECK = "cors-like";
|
||||||
|
}
|
||||||
|
|
||||||
log.info("server", "Node Env: " + process.env.NODE_ENV);
|
log.info("server", "Node Env: " + process.env.NODE_ENV);
|
||||||
log.info("server", "Inside Container: " + (process.env.UPTIME_KUMA_IS_CONTAINER === "1"));
|
log.info("server", "Inside Container: " + (process.env.UPTIME_KUMA_IS_CONTAINER === "1"));
|
||||||
|
|
||||||
|
if (process.env.UPTIME_KUMA_WS_ORIGIN_CHECK === "bypass") {
|
||||||
|
log.warn("server", "WebSocket Origin Check: " + process.env.UPTIME_KUMA_WS_ORIGIN_CHECK);
|
||||||
|
}
|
||||||
|
|
||||||
log.info("server", "Importing Node libraries");
|
log.info("server", "Importing Node libraries");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
|
|
||||||
@@ -76,7 +84,7 @@ const notp = require("notp");
|
|||||||
const base32 = require("thirty-two");
|
const base32 = require("thirty-two");
|
||||||
|
|
||||||
const { UptimeKumaServer } = require("./uptime-kuma-server");
|
const { UptimeKumaServer } = require("./uptime-kuma-server");
|
||||||
const server = UptimeKumaServer.getInstance(args);
|
const server = UptimeKumaServer.getInstance();
|
||||||
const io = module.exports.io = server.io;
|
const io = module.exports.io = server.io;
|
||||||
const app = server.app;
|
const app = server.app;
|
||||||
|
|
||||||
@@ -86,7 +94,7 @@ const Monitor = require("./model/monitor");
|
|||||||
const User = require("./model/user");
|
const User = require("./model/user");
|
||||||
|
|
||||||
log.debug("server", "Importing Settings");
|
log.debug("server", "Importing Settings");
|
||||||
const { getSettings, setSettings, setting, initJWTSecret, checkLogin, startUnitTest, FBSD, doubleCheckPassword, startE2eTests, shake256, SHAKE256_LENGTH
|
const { getSettings, setSettings, setting, initJWTSecret, checkLogin, startUnitTest, doubleCheckPassword, startE2eTests, shake256, SHAKE256_LENGTH
|
||||||
} = require("./util-server");
|
} = require("./util-server");
|
||||||
|
|
||||||
log.debug("server", "Importing Notification");
|
log.debug("server", "Importing Notification");
|
||||||
@@ -110,19 +118,13 @@ const passwordHash = require("./password-hash");
|
|||||||
const checkVersion = require("./check-version");
|
const checkVersion = require("./check-version");
|
||||||
log.info("server", "Version: " + checkVersion.version);
|
log.info("server", "Version: " + checkVersion.version);
|
||||||
|
|
||||||
// If host is omitted, the server will accept connections on the unspecified IPv6 address (::) when IPv6 is available and the unspecified IPv4 address (0.0.0.0) otherwise.
|
const hostname = config.hostname;
|
||||||
// Dual-stack support for (::)
|
|
||||||
// Also read HOST if not FreeBSD, as HOST is a system environment variable in FreeBSD
|
|
||||||
let hostEnv = FBSD ? null : process.env.HOST;
|
|
||||||
let hostname = args.host || process.env.UPTIME_KUMA_HOST || hostEnv;
|
|
||||||
|
|
||||||
if (hostname) {
|
if (hostname) {
|
||||||
log.info("server", "Custom hostname: " + hostname);
|
log.info("server", "Custom hostname: " + hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
const port = [ args.port, process.env.UPTIME_KUMA_PORT, process.env.PORT, 3001 ]
|
const port = config.port;
|
||||||
.map(portValue => parseInt(portValue))
|
|
||||||
.find(portValue => !isNaN(portValue));
|
|
||||||
|
|
||||||
const disableFrameSameOrigin = !!process.env.UPTIME_KUMA_DISABLE_FRAME_SAMEORIGIN || args["disable-frame-sameorigin"] || false;
|
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;
|
const cloudflaredToken = args["cloudflared-token"] || process.env.UPTIME_KUMA_CLOUDFLARED_TOKEN || undefined;
|
||||||
@@ -1152,6 +1154,8 @@ let needSetup = false;
|
|||||||
let user = await doubleCheckPassword(socket, password.currentPassword);
|
let user = await doubleCheckPassword(socket, password.currentPassword);
|
||||||
await user.resetPassword(password.newPassword);
|
await user.resetPassword(password.newPassword);
|
||||||
|
|
||||||
|
server.disconnectAllSocketClients(user.id, socket.id);
|
||||||
|
|
||||||
callback({
|
callback({
|
||||||
ok: true,
|
ok: true,
|
||||||
msg: "Password has been updated successfully.",
|
msg: "Password has been updated successfully.",
|
||||||
@@ -1201,6 +1205,12 @@ let needSetup = false;
|
|||||||
await doubleCheckPassword(socket, currentPassword);
|
await doubleCheckPassword(socket, currentPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Log out all clients if enabling auth
|
||||||
|
// GHSA-23q2-5gf8-gjpp
|
||||||
|
if (currentDisabledAuth && !data.disableAuth) {
|
||||||
|
server.disconnectAllSocketClients(socket.userID, socket.id);
|
||||||
|
}
|
||||||
|
|
||||||
const previousChromeExecutable = await Settings.get("chromeExecutable");
|
const previousChromeExecutable = await Settings.get("chromeExecutable");
|
||||||
const previousNSCDStatus = await Settings.get("nscd");
|
const previousNSCDStatus = await Settings.get("nscd");
|
||||||
|
|
||||||
@@ -1223,9 +1233,9 @@ let needSetup = false;
|
|||||||
// Update nscd status
|
// Update nscd status
|
||||||
if (previousNSCDStatus !== data.nscd) {
|
if (previousNSCDStatus !== data.nscd) {
|
||||||
if (data.nscd) {
|
if (data.nscd) {
|
||||||
server.startNSCDServices();
|
await server.startNSCDServices();
|
||||||
} else {
|
} else {
|
||||||
server.stopNSCDServices();
|
await server.stopNSCDServices();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -42,24 +42,50 @@ module.exports.generalSocketHandler = (socket, server) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
socket.on("getGameList", async (callback) => {
|
socket.on("getGameList", async (callback) => {
|
||||||
callback({
|
try {
|
||||||
ok: true,
|
checkLogin(socket);
|
||||||
gameList: getGameList(),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
socket.on("testChrome", (executable, callback) => {
|
|
||||||
// Just noticed that await call could block the whole socket.io server!!! Use pure promise instead.
|
|
||||||
testChrome(executable).then((version) => {
|
|
||||||
callback({
|
callback({
|
||||||
ok: true,
|
ok: true,
|
||||||
msg: "Found Chromium/Chrome. Version: " + version,
|
gameList: getGameList(),
|
||||||
});
|
});
|
||||||
}).catch((e) => {
|
} catch (e) {
|
||||||
callback({
|
callback({
|
||||||
ok: false,
|
ok: false,
|
||||||
msg: e.message,
|
msg: e.message,
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on("testChrome", (executable, callback) => {
|
||||||
|
try {
|
||||||
|
checkLogin(socket);
|
||||||
|
// Just noticed that await call could block the whole socket.io server!!! Use pure promise instead.
|
||||||
|
testChrome(executable).then((version) => {
|
||||||
|
callback({
|
||||||
|
ok: true,
|
||||||
|
msg: "Found Chromium/Chrome. Version: " + version,
|
||||||
|
});
|
||||||
|
}).catch((e) => {
|
||||||
|
callback({
|
||||||
|
ok: false,
|
||||||
|
msg: e.message,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
callback({
|
||||||
|
ok: false,
|
||||||
|
msg: e.message,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Disconnect all other socket clients of the user
|
||||||
|
socket.on("disconnectOtherSocketClients", async () => {
|
||||||
|
try {
|
||||||
|
checkLogin(socket);
|
||||||
|
server.disconnectAllSocketClients(socket.userID, socket.id);
|
||||||
|
} catch (e) {
|
||||||
|
log.warn("disconnectAllSocketClients", e.message);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@@ -147,7 +147,7 @@ module.exports.statusPageSocketHandler = (socket) => {
|
|||||||
config.logo = `/upload/${filename}?t=` + Date.now();
|
config.logo = `/upload/${filename}?t=` + Date.now();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
config.icon = imgDataUrl;
|
config.logo = imgDataUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
statusPage.slug = config.slug;
|
statusPage.slug = config.slug;
|
||||||
|
@@ -4,15 +4,15 @@ const fs = require("fs");
|
|||||||
const http = require("http");
|
const http = require("http");
|
||||||
const { Server } = require("socket.io");
|
const { Server } = require("socket.io");
|
||||||
const { R } = require("redbean-node");
|
const { R } = require("redbean-node");
|
||||||
const { log } = require("../src/util");
|
const { log, isDev } = require("../src/util");
|
||||||
const Database = require("./database");
|
const Database = require("./database");
|
||||||
const util = require("util");
|
const util = require("util");
|
||||||
const { CacheableDnsHttpAgent } = require("./cacheable-dns-http-agent");
|
const { CacheableDnsHttpAgent } = require("./cacheable-dns-http-agent");
|
||||||
const { Settings } = require("./settings");
|
const { Settings } = require("./settings");
|
||||||
const dayjs = require("dayjs");
|
const dayjs = require("dayjs");
|
||||||
const childProcess = require("child_process");
|
const childProcessAsync = require("promisify-child-process");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const axios = require("axios");
|
const { isSSL, sslKey, sslCert, sslKeyPassphrase } = require("./config");
|
||||||
// DO NOT IMPORT HERE IF THE MODULES USED `UptimeKumaServer.getInstance()`, put at the bottom of this file instead.
|
// DO NOT IMPORT HERE IF THE MODULES USED `UptimeKumaServer.getInstance()`, put at the bottom of this file instead.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,27 +63,17 @@ class UptimeKumaServer {
|
|||||||
*/
|
*/
|
||||||
jwtSecret = null;
|
jwtSecret = null;
|
||||||
|
|
||||||
checkMonitorsInterval = null;
|
static getInstance() {
|
||||||
|
|
||||||
static getInstance(args) {
|
|
||||||
if (UptimeKumaServer.instance == null) {
|
if (UptimeKumaServer.instance == null) {
|
||||||
UptimeKumaServer.instance = new UptimeKumaServer(args);
|
UptimeKumaServer.instance = new UptimeKumaServer();
|
||||||
}
|
}
|
||||||
return UptimeKumaServer.instance;
|
return UptimeKumaServer.instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(args) {
|
constructor() {
|
||||||
// SSL
|
|
||||||
const sslKey = args["ssl-key"] || process.env.UPTIME_KUMA_SSL_KEY || process.env.SSL_KEY || undefined;
|
|
||||||
const sslCert = args["ssl-cert"] || process.env.UPTIME_KUMA_SSL_CERT || process.env.SSL_CERT || undefined;
|
|
||||||
const sslKeyPassphrase = args["ssl-key-passphrase"] || process.env.UPTIME_KUMA_SSL_KEY_PASSPHRASE || process.env.SSL_KEY_PASSPHRASE || undefined;
|
|
||||||
|
|
||||||
// Set default axios timeout to 5 minutes instead of infinity
|
|
||||||
axios.defaults.timeout = 300 * 1000;
|
|
||||||
|
|
||||||
log.info("server", "Creating express and socket.io instance");
|
log.info("server", "Creating express and socket.io instance");
|
||||||
this.app = express();
|
this.app = express();
|
||||||
if (sslKey && sslCert) {
|
if (isSSL) {
|
||||||
log.info("server", "Server Type: HTTPS");
|
log.info("server", "Server Type: HTTPS");
|
||||||
this.httpServer = https.createServer({
|
this.httpServer = https.createServer({
|
||||||
key: fs.readFileSync(sslKey),
|
key: fs.readFileSync(sslKey),
|
||||||
@@ -109,7 +99,66 @@ class UptimeKumaServer {
|
|||||||
UptimeKumaServer.monitorTypeList["real-browser"] = new RealBrowserMonitorType();
|
UptimeKumaServer.monitorTypeList["real-browser"] = new RealBrowserMonitorType();
|
||||||
UptimeKumaServer.monitorTypeList["tailscale-ping"] = new TailscalePing();
|
UptimeKumaServer.monitorTypeList["tailscale-ping"] = new TailscalePing();
|
||||||
|
|
||||||
this.io = new Server(this.httpServer);
|
// Allow all CORS origins (polling) in development
|
||||||
|
let cors = undefined;
|
||||||
|
if (isDev) {
|
||||||
|
cors = {
|
||||||
|
origin: "*",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
this.io = new Server(this.httpServer, {
|
||||||
|
cors,
|
||||||
|
allowRequest: async (req, callback) => {
|
||||||
|
let transport;
|
||||||
|
// It should be always true, but just in case, because this property is not documented
|
||||||
|
if (req._query) {
|
||||||
|
transport = req._query.transport;
|
||||||
|
} else {
|
||||||
|
log.error("socket", "Ops!!! Cannot get transport type, assume that it is polling");
|
||||||
|
transport = "polling";
|
||||||
|
}
|
||||||
|
|
||||||
|
const clientIP = await this.getClientIPwithProxy(req.connection.remoteAddress, req.headers);
|
||||||
|
log.info("socket", `New ${transport} connection, IP = ${clientIP}`);
|
||||||
|
|
||||||
|
// The following check is only for websocket connections, polling connections are already protected by CORS
|
||||||
|
if (transport === "polling") {
|
||||||
|
callback(null, true);
|
||||||
|
} else if (transport === "websocket") {
|
||||||
|
const bypass = process.env.UPTIME_KUMA_WS_ORIGIN_CHECK === "bypass";
|
||||||
|
if (bypass) {
|
||||||
|
log.info("auth", "WebSocket origin check is bypassed");
|
||||||
|
callback(null, true);
|
||||||
|
} else if (!req.headers.origin) {
|
||||||
|
log.info("auth", "WebSocket with no origin is allowed");
|
||||||
|
callback(null, true);
|
||||||
|
} else {
|
||||||
|
let host = req.headers.host;
|
||||||
|
let origin = req.headers.origin;
|
||||||
|
|
||||||
|
try {
|
||||||
|
let originURL = new URL(origin);
|
||||||
|
let xForwardedFor;
|
||||||
|
if (await Settings.get("trustProxy")) {
|
||||||
|
xForwardedFor = req.headers["x-forwarded-for"];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (host !== originURL.host && xForwardedFor !== originURL.host) {
|
||||||
|
callback(null, false);
|
||||||
|
log.error("auth", `Origin (${origin}) does not match host (${host}), IP: ${clientIP}`);
|
||||||
|
} else {
|
||||||
|
callback(null, true);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// Invalid origin url, probably not from browser
|
||||||
|
callback(null, false);
|
||||||
|
log.error("auth", `Invalid origin url (${origin}), IP: ${clientIP}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Initialise app after the database has been set up */
|
/** Initialise app after the database has been set up */
|
||||||
@@ -244,20 +293,28 @@ class UptimeKumaServer {
|
|||||||
/**
|
/**
|
||||||
* Get the IP of the client connected to the socket
|
* Get the IP of the client connected to the socket
|
||||||
* @param {Socket} socket
|
* @param {Socket} socket
|
||||||
* @returns {string}
|
* @returns {Promise<string>}
|
||||||
*/
|
*/
|
||||||
async getClientIP(socket) {
|
getClientIP(socket) {
|
||||||
let clientIP = socket.client.conn.remoteAddress;
|
return this.getClientIPwithProxy(socket.client.conn.remoteAddress, socket.client.conn.request.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {string} clientIP
|
||||||
|
* @param {IncomingHttpHeaders} headers
|
||||||
|
* @returns {Promise<string>}
|
||||||
|
*/
|
||||||
|
async getClientIPwithProxy(clientIP, headers) {
|
||||||
if (clientIP === undefined) {
|
if (clientIP === undefined) {
|
||||||
clientIP = "";
|
clientIP = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await Settings.get("trustProxy")) {
|
if (await Settings.get("trustProxy")) {
|
||||||
const forwardedFor = socket.client.conn.request.headers["x-forwarded-for"];
|
const forwardedFor = headers["x-forwarded-for"];
|
||||||
|
|
||||||
return (typeof forwardedFor === "string" ? forwardedFor.split(",")[0].trim() : null)
|
return (typeof forwardedFor === "string" ? forwardedFor.split(",")[0].trim() : null)
|
||||||
|| socket.client.conn.request.headers["x-real-ip"]
|
|| headers["x-real-ip"]
|
||||||
|| clientIP.replace(/^::ffff:/, "");
|
|| clientIP.replace(/^::ffff:/, "");
|
||||||
} else {
|
} else {
|
||||||
return clientIP.replace(/^::ffff:/, "");
|
return clientIP.replace(/^::ffff:/, "");
|
||||||
@@ -350,12 +407,8 @@ class UptimeKumaServer {
|
|||||||
let enable = await Settings.get("nscd");
|
let enable = await Settings.get("nscd");
|
||||||
|
|
||||||
if (enable || enable === null) {
|
if (enable || enable === null) {
|
||||||
this.startNSCDServices();
|
await this.startNSCDServices();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.checkMonitorsInterval = setInterval(() => {
|
|
||||||
this.checkMonitors();
|
|
||||||
}, 60 * 1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -366,21 +419,19 @@ class UptimeKumaServer {
|
|||||||
let enable = await Settings.get("nscd");
|
let enable = await Settings.get("nscd");
|
||||||
|
|
||||||
if (enable || enable === null) {
|
if (enable || enable === null) {
|
||||||
this.stopNSCDServices();
|
await this.stopNSCDServices();
|
||||||
}
|
}
|
||||||
|
|
||||||
clearInterval(this.checkMonitorsInterval);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start all system services (e.g. nscd)
|
* Start all system services (e.g. nscd)
|
||||||
* For now, only used in Docker
|
* For now, only used in Docker
|
||||||
*/
|
*/
|
||||||
startNSCDServices() {
|
async startNSCDServices() {
|
||||||
if (process.env.UPTIME_KUMA_IS_CONTAINER) {
|
if (process.env.UPTIME_KUMA_IS_CONTAINER) {
|
||||||
try {
|
try {
|
||||||
log.info("services", "Starting nscd");
|
log.info("services", "Starting nscd");
|
||||||
childProcess.execSync("sudo service nscd start", { stdio: "pipe" });
|
await childProcessAsync.exec("sudo service nscd start");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.info("services", "Failed to start nscd");
|
log.info("services", "Failed to start nscd");
|
||||||
}
|
}
|
||||||
@@ -390,11 +441,11 @@ class UptimeKumaServer {
|
|||||||
/**
|
/**
|
||||||
* Stop all system services
|
* Stop all system services
|
||||||
*/
|
*/
|
||||||
stopNSCDServices() {
|
async stopNSCDServices() {
|
||||||
if (process.env.UPTIME_KUMA_IS_CONTAINER) {
|
if (process.env.UPTIME_KUMA_IS_CONTAINER) {
|
||||||
try {
|
try {
|
||||||
log.info("services", "Stopping nscd");
|
log.info("services", "Stopping nscd");
|
||||||
childProcess.execSync("sudo service nscd stop");
|
await childProcessAsync.exec("sudo service nscd stop");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.info("services", "Failed to stop nscd");
|
log.info("services", "Failed to stop nscd");
|
||||||
}
|
}
|
||||||
@@ -402,80 +453,22 @@ class UptimeKumaServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start the specified monitor
|
* Force connected sockets of a user to refresh and disconnect.
|
||||||
* @param {number} monitorID ID of monitor to start
|
* Used for resetting password.
|
||||||
* @returns {Promise<void>}
|
* @param {string} userID
|
||||||
|
* @param {string?} currentSocketID
|
||||||
*/
|
*/
|
||||||
async startMonitor(monitorID) {
|
disconnectAllSocketClients(userID, currentSocketID = undefined) {
|
||||||
log.info("manage", `Resume Monitor: ${monitorID} by server`);
|
for (const socket of this.io.sockets.sockets.values()) {
|
||||||
|
if (socket.userID === userID && socket.id !== currentSocketID) {
|
||||||
|
try {
|
||||||
|
socket.emit("refresh");
|
||||||
|
socket.disconnect();
|
||||||
|
} catch (e) {
|
||||||
|
|
||||||
await R.exec("UPDATE monitor SET active = 1 WHERE id = ?", [
|
|
||||||
monitorID,
|
|
||||||
]);
|
|
||||||
|
|
||||||
let monitor = await R.findOne("monitor", " id = ? ", [
|
|
||||||
monitorID,
|
|
||||||
]);
|
|
||||||
|
|
||||||
if (monitor.id in this.monitorList) {
|
|
||||||
this.monitorList[monitor.id].stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.monitorList[monitor.id] = monitor;
|
|
||||||
monitor.start(this.io);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Restart a given monitor
|
|
||||||
* @param {number} monitorID ID of monitor to start
|
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
|
||||||
async restartMonitor(monitorID) {
|
|
||||||
return await this.startMonitor(monitorID);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if monitors are running properly
|
|
||||||
*/
|
|
||||||
async checkMonitors() {
|
|
||||||
log.debug("monitor_checker", "Checking monitors");
|
|
||||||
|
|
||||||
for (let monitorID in this.monitorList) {
|
|
||||||
let monitor = this.monitorList[monitorID];
|
|
||||||
|
|
||||||
// Not for push monitor
|
|
||||||
if (monitor.type === "push") {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!monitor.active) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check the lastStartBeatTime, if it is too long, then restart
|
|
||||||
if (monitor.lastScheduleBeatTime ) {
|
|
||||||
let diff = dayjs().diff(monitor.lastStartBeatTime, "second");
|
|
||||||
|
|
||||||
if (diff > monitor.interval * 1.5) {
|
|
||||||
log.error("monitor_checker", `Monitor Interval: ${monitor.interval} Monitor ` + monitorID + " lastStartBeatTime diff: " + diff);
|
|
||||||
log.error("monitor_checker", "Unexpected error: Monitor " + monitorID + " is struck for unknown reason");
|
|
||||||
log.error("monitor_checker", "Last start beat time: " + R.isoDateTime(monitor.lastStartBeatTime));
|
|
||||||
log.error("monitor_checker", "Last end beat time: " + R.isoDateTime(monitor.lastEndBeatTime));
|
|
||||||
log.error("monitor_checker", "Last ScheduleBeatTime: " + R.isoDateTime(monitor.lastScheduleBeatTime));
|
|
||||||
|
|
||||||
// Restart
|
|
||||||
log.error("monitor_checker", `Restarting monitor ${monitorID} automatically now`);
|
|
||||||
this.restartMonitor(monitorID);
|
|
||||||
} else {
|
|
||||||
//log.debug("monitor_checker", "Monitor " + monitorID + " is running normally");
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
//log.debug("monitor_checker", "Monitor " + monitorID + " is not started yet, skipp");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug("monitor_checker", "Checking monitors end");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
const tcpp = require("tcp-ping");
|
const tcpp = require("tcp-ping");
|
||||||
const ping = require("@louislam/ping");
|
const ping = require("@louislam/ping");
|
||||||
const { R } = require("redbean-node");
|
const { R } = require("redbean-node");
|
||||||
const { log, genSecret } = require("../src/util");
|
const { log, genSecret, badgeConstants } = require("../src/util");
|
||||||
const passwordHash = require("./password-hash");
|
const passwordHash = require("./password-hash");
|
||||||
const { Resolver } = require("dns");
|
const { Resolver } = require("dns");
|
||||||
const childProcess = require("child_process");
|
const childProcess = require("child_process");
|
||||||
@@ -9,7 +9,6 @@ const iconv = require("iconv-lite");
|
|||||||
const chardet = require("chardet");
|
const chardet = require("chardet");
|
||||||
const mqtt = require("mqtt");
|
const mqtt = require("mqtt");
|
||||||
const chroma = require("chroma-js");
|
const chroma = require("chroma-js");
|
||||||
const { badgeConstants } = require("./config");
|
|
||||||
const mssql = require("mssql");
|
const mssql = require("mssql");
|
||||||
const { Client } = require("pg");
|
const { Client } = require("pg");
|
||||||
const postgresConParse = require("pg-connection-string").parse;
|
const postgresConParse = require("pg-connection-string").parse;
|
||||||
@@ -458,6 +457,7 @@ exports.postgresQuery = function (connectionString, query) {
|
|||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
reject(e);
|
reject(e);
|
||||||
|
client.end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -716,20 +716,27 @@ const parseCertificateInfo = function (info) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if certificate is valid
|
* Check if certificate is valid
|
||||||
* @param {Object} res Response object from axios
|
* @param {tls.TLSSocket} socket TLSSocket, which may or may not be connected
|
||||||
* @returns {Object} Object containing certificate information
|
* @returns {Object} Object containing certificate information
|
||||||
*/
|
*/
|
||||||
exports.checkCertificate = function (res) {
|
exports.checkCertificate = function (socket) {
|
||||||
if (!res.request.res.socket) {
|
let certInfoStartTime = dayjs().valueOf();
|
||||||
throw new Error("No socket found");
|
|
||||||
|
// Return null if there is no socket
|
||||||
|
if (socket === undefined || socket == null) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const info = res.request.res.socket.getPeerCertificate(true);
|
const info = socket.getPeerCertificate(true);
|
||||||
const valid = res.request.res.socket.authorized || false;
|
const valid = socket.authorized || false;
|
||||||
|
|
||||||
log.debug("cert", "Parsing Certificate Info");
|
log.debug("cert", "Parsing Certificate Info");
|
||||||
const parsedInfo = parseCertificateInfo(info);
|
const parsedInfo = parseCertificateInfo(info);
|
||||||
|
|
||||||
|
if (process.env.TIMELOGGER === "1") {
|
||||||
|
log.debug("monitor", "Cert Info Query Time: " + (dayjs().valueOf() - certInfoStartTime) + "ms");
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
valid: valid,
|
valid: valid,
|
||||||
certInfo: parsedInfo
|
certInfo: parsedInfo
|
||||||
@@ -1141,7 +1148,6 @@ module.exports.axiosAbortSignal = (timeoutMs) => {
|
|||||||
// v16-: AbortSignal.timeout is not supported
|
// v16-: AbortSignal.timeout is not supported
|
||||||
try {
|
try {
|
||||||
const abortController = new AbortController();
|
const abortController = new AbortController();
|
||||||
|
|
||||||
setTimeout(() => abortController.abort(), timeoutMs);
|
setTimeout(() => abortController.abort(), timeoutMs);
|
||||||
|
|
||||||
return abortController.signal;
|
return abortController.signal;
|
||||||
|
@@ -8,9 +8,9 @@
|
|||||||
:placeholder="placeholder"
|
:placeholder="placeholder"
|
||||||
:disabled="!enabled"
|
:disabled="!enabled"
|
||||||
>
|
>
|
||||||
<a class="btn btn-outline-primary" @click="action()">
|
<button type="button" class="btn btn-outline-primary" :aria-label="actionAriaLabel" @click="action()">
|
||||||
<font-awesome-icon :icon="icon" />
|
<font-awesome-icon :icon="icon" />
|
||||||
</a>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -66,6 +66,13 @@ export default {
|
|||||||
action: {
|
action: {
|
||||||
type: Function,
|
type: Function,
|
||||||
default: () => {},
|
default: () => {},
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* The aria-label of the action button
|
||||||
|
*/
|
||||||
|
actionAriaLabel: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
emits: [ "update:modelValue" ],
|
emits: [ "update:modelValue" ],
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="input-group mb-3">
|
<div class="input-group mb-3">
|
||||||
<select ref="select" v-model="model" class="form-select" :disabled="disabled" :required="required">
|
<select :id="id" ref="select" v-model="model" class="form-select" :disabled="disabled" :required="required">
|
||||||
<option v-for="option in options" :key="option" :value="option.value" :disabled="option.disabled">{{ option.label }}</option>
|
<option v-for="option in options" :key="option" :value="option.value" :disabled="option.disabled">{{ option.label }}</option>
|
||||||
</select>
|
</select>
|
||||||
<a class="btn btn-outline-primary" :class="{ disabled: actionDisabled }" @click="action()">
|
<button type="button" class="btn btn-outline-primary" :class="{ disabled: actionDisabled }" :aria-label="actionAriaLabel" @click="action()">
|
||||||
<font-awesome-icon :icon="icon" />
|
<font-awesome-icon :icon="icon" aria-hidden="true" />
|
||||||
</a>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -20,6 +20,13 @@ export default {
|
|||||||
type: Array,
|
type: Array,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* The id of the form which will be targeted by a <label for=..
|
||||||
|
*/
|
||||||
|
id: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* The value of the select field.
|
* The value of the select field.
|
||||||
*/
|
*/
|
||||||
@@ -51,6 +58,13 @@ export default {
|
|||||||
type: Function,
|
type: Function,
|
||||||
default: () => {},
|
default: () => {},
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* The aria-label of the action button
|
||||||
|
*/
|
||||||
|
actionAriaLabel: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Whether the action button is disabled.
|
* Whether the action button is disabled.
|
||||||
* @example true
|
* @example true
|
||||||
|
@@ -135,7 +135,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Modal } from "bootstrap";
|
import { Modal } from "bootstrap";
|
||||||
import CopyableInput from "./CopyableInput.vue";
|
import CopyableInput from "./CopyableInput.vue";
|
||||||
import { default as serverConfig } from "../../server/config.js";
|
import { badgeConstants } from "../util.ts";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@@ -230,7 +230,7 @@ export default {
|
|||||||
"labelColor",
|
"labelColor",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
badgeConstants: serverConfig.badgeConstants,
|
badgeConstants,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@@ -29,10 +29,10 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
startDateTime() {
|
startDateTime() {
|
||||||
return dayjs(this.maintenance.timeslotList[0].startDate).tz(this.maintenance.timezone).format(SQL_DATETIME_FORMAT_WITHOUT_SECOND);
|
return dayjs(this.maintenance.timeslotList[0].startDate).tz(this.maintenance.timezone, true).format(SQL_DATETIME_FORMAT_WITHOUT_SECOND);
|
||||||
},
|
},
|
||||||
endDateTime() {
|
endDateTime() {
|
||||||
return dayjs(this.maintenance.timeslotList[0].endDate).tz(this.maintenance.timezone).format(SQL_DATETIME_FORMAT_WITHOUT_SECOND);
|
return dayjs(this.maintenance.timeslotList[0].endDate).tz(this.maintenance.timezone, true).format(SQL_DATETIME_FORMAT_WITHOUT_SECOND);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@@ -16,7 +16,10 @@
|
|||||||
</a>
|
</a>
|
||||||
<form>
|
<form>
|
||||||
<input
|
<input
|
||||||
v-model="searchText" class="form-control search-input" :placeholder="$t('Search...')"
|
v-model="searchText"
|
||||||
|
class="form-control search-input"
|
||||||
|
:placeholder="$t('Search...')"
|
||||||
|
:aria-label="$t('Search monitored sites')"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
|
@@ -13,6 +13,15 @@
|
|||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="ntfy-priority" class="form-label">{{ $t("Priority") }}</label>
|
<label for="ntfy-priority" class="form-label">{{ $t("Priority") }}</label>
|
||||||
<input id="ntfy-priority" v-model="$parent.notification.ntfyPriority" type="number" class="form-control" required min="1" max="5" step="1">
|
<input id="ntfy-priority" v-model="$parent.notification.ntfyPriority" type="number" class="form-control" required min="1" max="5" step="1">
|
||||||
|
<div class="form-text">
|
||||||
|
<p v-if="$parent.notification.ntfyPriority >= 5">
|
||||||
|
{{ $t("ntfyPriorityHelptextAllEvents") }}
|
||||||
|
</p>
|
||||||
|
<i18n-t v-else tag="p" keypath="ntfyPriorityHelptextAllExceptDown">
|
||||||
|
<code>DOWN</code>
|
||||||
|
<code>{{ $parent.notification.ntfyPriority + 1 }}</code>
|
||||||
|
</i18n-t>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="authentication-method" class="form-label">{{ $t("ntfyAuthenticationMethod") }}</label>
|
<label for="authentication-method" class="form-label">{{ $t("ntfyAuthenticationMethod") }}</label>
|
||||||
|
@@ -5,6 +5,14 @@
|
|||||||
<input id="hostname" v-model="$parent.notification.smtpHost" type="text" class="form-control" required>
|
<input id="hostname" v-model="$parent.notification.smtpHost" type="text" class="form-control" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<i18n-t tag="div" keypath="Either enter the hostname of the server you want to connect to or localhost if you intend to use a locally configured mail transfer agent" class="form-text">
|
||||||
|
<template #localhost>
|
||||||
|
<code>localhost</code>
|
||||||
|
</template>
|
||||||
|
<template #local_mta>
|
||||||
|
<a href="https://wikipedia.org/wiki/Mail_Transfer_Agent" target="_blank">{{ $t("locally configured mail transfer agent") }}</a>
|
||||||
|
</template>
|
||||||
|
</i18n-t>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="port" class="form-label">{{ $t("Port") }}</label>
|
<label for="port" class="form-label">{{ $t("Port") }}</label>
|
||||||
<input id="port" v-model="$parent.notification.smtpPort" type="number" class="form-control" required min="0" max="65535" step="1">
|
<input id="port" v-model="$parent.notification.smtpPort" type="number" class="form-control" required min="0" max="65535" step="1">
|
||||||
|
@@ -1,53 +1,63 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div class="add-btn">
|
<div
|
||||||
<button class="btn btn-primary me-2" type="button" @click="$refs.apiKeyDialog.show()">
|
v-if="settings.disableAuth"
|
||||||
<font-awesome-icon icon="plus" /> {{ $t("Add API Key") }}
|
class="mt-5 d-flex align-items-center justify-content-center my-3"
|
||||||
</button>
|
>
|
||||||
|
{{ $t("apiKeysDisabledMsg") }}
|
||||||
</div>
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<div class="add-btn">
|
||||||
|
<button class="btn btn-primary me-2" type="button" @click="$refs.apiKeyDialog.show()">
|
||||||
|
<font-awesome-icon icon="plus" /> {{ $t("Add API Key") }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<span v-if="Object.keys(keyList).length === 0" class="d-flex align-items-center justify-content-center my-3">
|
<span
|
||||||
{{ $t("No API Keys") }}
|
v-if="Object.keys(keyList).length === 0"
|
||||||
</span>
|
class="d-flex align-items-center justify-content-center my-3"
|
||||||
|
>
|
||||||
|
{{ $t("No API Keys") }}
|
||||||
|
</span>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
v-for="(item, index) in keyList"
|
v-for="(item, index) in keyList"
|
||||||
:key="index"
|
:key="index"
|
||||||
class="item"
|
class="item"
|
||||||
:class="item.status"
|
:class="item.status"
|
||||||
>
|
>
|
||||||
<div class="left-part">
|
<div class="left-part">
|
||||||
<div
|
<div class="circle"></div>
|
||||||
class="circle"
|
<div class="info">
|
||||||
></div>
|
<div class="title">{{ item.name }}</div>
|
||||||
<div class="info">
|
<div class="status">
|
||||||
<div class="title">{{ item.name }}</div>
|
{{ $t("apiKey-" + item.status) }}
|
||||||
<div class="status">
|
</div>
|
||||||
{{ $t("apiKey-" + item.status) }}
|
<div class="date">
|
||||||
</div>
|
{{ $t("Created") }}: {{ item.createdDate }}
|
||||||
<div class="date">
|
</div>
|
||||||
{{ $t("Created") }}: {{ item.createdDate }}
|
<div class="date">
|
||||||
</div>
|
{{ $t("Expires") }}:
|
||||||
<div class="date">
|
{{ item.expires || $t("Never") }}
|
||||||
{{ $t("Expires") }}: {{ item.expires || $t("Never") }}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<div class="btn-group" role="group">
|
<div class="btn-group" role="group">
|
||||||
<button v-if="item.active" class="btn btn-normal" @click="disableDialog(item.id)">
|
<button v-if="item.active" class="btn btn-normal" @click="disableDialog(item.id)">
|
||||||
<font-awesome-icon icon="pause" /> {{ $t("Disable") }}
|
<font-awesome-icon icon="pause" /> {{ $t("Disable") }}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button v-if="!item.active" class="btn btn-primary" @click="enableKey(item.id)">
|
<button v-if="!item.active" class="btn btn-primary" @click="enableKey(item.id)">
|
||||||
<font-awesome-icon icon="play" /> {{ $t("Enable") }}
|
<font-awesome-icon icon="play" /> {{ $t("Enable") }}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button class="btn btn-danger" @click="deleteDialog(item.id)">
|
<button class="btn btn-danger" @click="deleteDialog(item.id)">
|
||||||
<font-awesome-icon icon="trash" /> {{ $t("Delete") }}
|
<font-awesome-icon icon="trash" /> {{ $t("Delete") }}
|
||||||
</button>
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -90,6 +100,9 @@ export default {
|
|||||||
let result = Object.values(this.$root.apiKeyList);
|
let result = Object.values(this.$root.apiKeyList);
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
settings() {
|
||||||
|
return this.$parent.$parent.$parent.settings;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
@@ -127,9 +140,11 @@ export default {
|
|||||||
* Pause maintenance
|
* Pause maintenance
|
||||||
*/
|
*/
|
||||||
disableKey() {
|
disableKey() {
|
||||||
this.$root.getSocket().emit("disableAPIKey", this.selectedKeyID, (res) => {
|
this.$root
|
||||||
this.$root.toastRes(res);
|
.getSocket()
|
||||||
});
|
.emit("disableAPIKey", this.selectedKeyID, (res) => {
|
||||||
|
this.$root.toastRes(res);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -145,113 +160,113 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@import "../../assets/vars.scss";
|
@import "../../assets/vars.scss";
|
||||||
|
|
||||||
.mobile {
|
|
||||||
.item {
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: flex-start;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.add-btn {
|
|
||||||
padding-top: 20px;
|
|
||||||
padding-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
.mobile {
|
||||||
.item {
|
.item {
|
||||||
display: flex;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: flex-start;
|
||||||
gap: 10px;
|
margin-bottom: 20px;
|
||||||
text-decoration: none;
|
}
|
||||||
border-radius: 10px;
|
}
|
||||||
transition: all ease-in-out 0.15s;
|
|
||||||
justify-content: space-between;
|
|
||||||
padding: 10px;
|
|
||||||
min-height: 90px;
|
|
||||||
margin-bottom: 5px;
|
|
||||||
|
|
||||||
&:hover {
|
.add-btn {
|
||||||
background-color: $highlight-white;
|
padding-top: 20px;
|
||||||
|
padding-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
text-decoration: none;
|
||||||
|
border-radius: 10px;
|
||||||
|
transition: all ease-in-out 0.15s;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 10px;
|
||||||
|
min-height: 90px;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: $highlight-white;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
.circle {
|
||||||
|
background-color: $primary;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&.active {
|
&.inactive {
|
||||||
.circle {
|
.circle {
|
||||||
background-color: $primary;
|
background-color: $danger;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&.inactive {
|
|
||||||
.circle {
|
|
||||||
background-color: $danger;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&.expired {
|
|
||||||
.left-part {
|
|
||||||
opacity: 0.3;
|
|
||||||
}
|
|
||||||
|
|
||||||
.circle {
|
|
||||||
background-color: $dark-font-color;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.expired {
|
||||||
.left-part {
|
.left-part {
|
||||||
display: flex;
|
opacity: 0.3;
|
||||||
gap: 12px;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
.circle {
|
|
||||||
width: 25px;
|
|
||||||
height: 25px;
|
|
||||||
border-radius: 50rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.info {
|
|
||||||
.title {
|
|
||||||
font-weight: bold;
|
|
||||||
font-size: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.status {
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.buttons {
|
.circle {
|
||||||
display: flex;
|
background-color: $dark-font-color;
|
||||||
gap: 8px;
|
}
|
||||||
flex-direction: row-reverse;
|
}
|
||||||
|
|
||||||
.btn-group {
|
.left-part {
|
||||||
width: 310px;
|
display: flex;
|
||||||
|
gap: 12px;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.circle {
|
||||||
|
width: 25px;
|
||||||
|
height: 25px;
|
||||||
|
border-radius: 50rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info {
|
||||||
|
.title {
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status {
|
||||||
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.date {
|
.buttons {
|
||||||
margin-top: 5px;
|
display: flex;
|
||||||
display: block;
|
gap: 8px;
|
||||||
font-size: 14px;
|
flex-direction: row-reverse;
|
||||||
background-color: rgba(255, 255, 255, 0.5);
|
|
||||||
border-radius: 20px;
|
|
||||||
padding: 0 10px;
|
|
||||||
width: fit-content;
|
|
||||||
|
|
||||||
.dark & {
|
.btn-group {
|
||||||
color: white;
|
width: 310px;
|
||||||
background-color: rgba(255, 255, 255, 0.1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.dark {
|
.date {
|
||||||
.item {
|
margin-top: 5px;
|
||||||
&:hover {
|
display: block;
|
||||||
background-color: $dark-bg2;
|
font-size: 14px;
|
||||||
}
|
background-color: rgba(255, 255, 255, 0.5);
|
||||||
|
border-radius: 20px;
|
||||||
|
padding: 0 10px;
|
||||||
|
width: fit-content;
|
||||||
|
|
||||||
|
.dark & {
|
||||||
|
color: white;
|
||||||
|
background-color: rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dark {
|
||||||
|
.item {
|
||||||
|
&:hover {
|
||||||
|
background-color: $dark-bg2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@@ -27,13 +27,13 @@
|
|||||||
<div class="mt-1 mb-3 ps-2 cert-exp-days col-12 col-xl-6">
|
<div class="mt-1 mb-3 ps-2 cert-exp-days col-12 col-xl-6">
|
||||||
<div v-for="day in settings.tlsExpiryNotifyDays" :key="day" class="d-flex align-items-center justify-content-between cert-exp-day-row py-2">
|
<div v-for="day in settings.tlsExpiryNotifyDays" :key="day" class="d-flex align-items-center justify-content-between cert-exp-day-row py-2">
|
||||||
<span>{{ day }} {{ $tc("day", day) }}</span>
|
<span>{{ day }} {{ $tc("day", day) }}</span>
|
||||||
<button type="button" class="btn-rm-expiry btn btn-outline-danger ms-2 py-1" @click="removeExpiryNotifDay(day)">
|
<button type="button" class="btn-rm-expiry btn btn-outline-danger ms-2 py-1" :aria-label="$t('Remove the expiry notification')" @click="removeExpiryNotifDay(day)">
|
||||||
<font-awesome-icon class="" icon="times" />
|
<font-awesome-icon icon="times" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 col-xl-6">
|
<div class="col-12 col-xl-6">
|
||||||
<ActionInput v-model="expiryNotifInput" :type="'number'" :placeholder="$t('day')" :icon="'plus'" :action="() => addExpiryNotifDay(expiryNotifInput)" />
|
<ActionInput v-model="expiryNotifInput" :type="'number'" :placeholder="$t('day')" :icon="'plus'" :action="() => addExpiryNotifDay(expiryNotifInput)" :action-aria-label="$t('Add a new expiry notification day')" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<button class="btn btn-primary" type="button" @click="saveSettings()">
|
<button class="btn btn-primary" type="button" @click="saveSettings()">
|
||||||
|
27
src/i18n.js
27
src/i18n.js
@@ -57,10 +57,29 @@ for (let lang in languageList) {
|
|||||||
|
|
||||||
const rtlLangs = [ "fa", "ar-SY", "ur" ];
|
const rtlLangs = [ "fa", "ar-SY", "ur" ];
|
||||||
|
|
||||||
export const currentLocale = () => localStorage.locale
|
/**
|
||||||
|| languageList[navigator.language] && navigator.language
|
* Find the best matching locale to display
|
||||||
|| languageList[navigator.language.substring(0, 2)] && navigator.language.substring(0, 2)
|
* If no locale can be matched, the default is "en"
|
||||||
|| "en";
|
* @returns {string} the locale that should be displayed
|
||||||
|
*/
|
||||||
|
export function currentLocale() {
|
||||||
|
for (const locale of [ localStorage.locale, navigator.language, ...navigator.languages ]) {
|
||||||
|
// localstorage might not have a value or there might not be a language in `navigator.language`
|
||||||
|
if (!locale) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (locale in messages) {
|
||||||
|
return locale;
|
||||||
|
}
|
||||||
|
// some locales are further specified such as "en-US".
|
||||||
|
// If we only have a generic locale for this, we can use it too
|
||||||
|
const genericLocale = locale.split("-")[0];
|
||||||
|
if (genericLocale in messages) {
|
||||||
|
return genericLocale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "en";
|
||||||
|
}
|
||||||
|
|
||||||
export const localeDirection = () => {
|
export const localeDirection = () => {
|
||||||
return rtlLangs.includes(currentLocale()) ? "rtl" : "ltr";
|
return rtlLangs.includes(currentLocale()) ? "rtl" : "ltr";
|
||||||
|
@@ -57,6 +57,8 @@
|
|||||||
"Friendly Name": "Friendly Name",
|
"Friendly Name": "Friendly Name",
|
||||||
"URL": "URL",
|
"URL": "URL",
|
||||||
"Hostname": "Hostname",
|
"Hostname": "Hostname",
|
||||||
|
"locally configured mail transfer agent": "locally configured mail transfer agent",
|
||||||
|
"Either enter the hostname of the server you want to connect to or localhost if you intend to use a locally configured mail transfer agent": "Either enter the hostname of the server you want to connect to or {localhost} if you intend to use a {local_mta}",
|
||||||
"Port": "Port",
|
"Port": "Port",
|
||||||
"Heartbeat Interval": "Heartbeat Interval",
|
"Heartbeat Interval": "Heartbeat Interval",
|
||||||
"Request Timeout": "Request Timeout",
|
"Request Timeout": "Request Timeout",
|
||||||
@@ -183,6 +185,7 @@
|
|||||||
"Pink": "Pink",
|
"Pink": "Pink",
|
||||||
"Custom": "Custom",
|
"Custom": "Custom",
|
||||||
"Search...": "Search…",
|
"Search...": "Search…",
|
||||||
|
"Search monitored sites": "Search monitored sites",
|
||||||
"Avg. Ping": "Avg. Ping",
|
"Avg. Ping": "Avg. Ping",
|
||||||
"Avg. Response": "Avg. Response",
|
"Avg. Response": "Avg. Response",
|
||||||
"Entry Page": "Entry Page",
|
"Entry Page": "Entry Page",
|
||||||
@@ -334,6 +337,8 @@
|
|||||||
"Fingerprint:": "Fingerprint:",
|
"Fingerprint:": "Fingerprint:",
|
||||||
"No status pages": "No status pages",
|
"No status pages": "No status pages",
|
||||||
"Domain Name Expiry Notification": "Domain Name Expiry Notification",
|
"Domain Name Expiry Notification": "Domain Name Expiry Notification",
|
||||||
|
"Add a new expiry notification day": "Add a new expiry notification day",
|
||||||
|
"Remove the expiry notification": "Remove the expiry notification day",
|
||||||
"Proxy": "Proxy",
|
"Proxy": "Proxy",
|
||||||
"Date Created": "Date Created",
|
"Date Created": "Date Created",
|
||||||
"Footer Text": "Footer Text",
|
"Footer Text": "Footer Text",
|
||||||
@@ -656,6 +661,10 @@
|
|||||||
"Notify Channel": "Notify Channel",
|
"Notify Channel": "Notify Channel",
|
||||||
"aboutNotifyChannel": "Notify channel will trigger a desktop or mobile notification for all members of the channel, whether their availability is set to active or away.",
|
"aboutNotifyChannel": "Notify channel will trigger a desktop or mobile notification for all members of the channel, whether their availability is set to active or away.",
|
||||||
"Uptime Kuma URL": "Uptime Kuma URL",
|
"Uptime Kuma URL": "Uptime Kuma URL",
|
||||||
|
"setup a new monitor group": "setup a new monitor group",
|
||||||
|
"openModalTo": "open modal to {0}",
|
||||||
|
"Add a domain": "Add a domain",
|
||||||
|
"Remove domain": "Remove domain '{0}'",
|
||||||
"Icon Emoji": "Icon Emoji",
|
"Icon Emoji": "Icon Emoji",
|
||||||
"signalImportant": "IMPORTANT: You cannot mix groups and numbers in recipients!",
|
"signalImportant": "IMPORTANT: You cannot mix groups and numbers in recipients!",
|
||||||
"aboutWebhooks": "More info about Webhooks on: {0}",
|
"aboutWebhooks": "More info about Webhooks on: {0}",
|
||||||
@@ -749,6 +758,8 @@
|
|||||||
"lunaseaDeviceID": "Device ID",
|
"lunaseaDeviceID": "Device ID",
|
||||||
"lunaseaUserID": "User ID",
|
"lunaseaUserID": "User ID",
|
||||||
"ntfyAuthenticationMethod": "Authentication Method",
|
"ntfyAuthenticationMethod": "Authentication Method",
|
||||||
|
"ntfyPriorityHelptextAllEvents": "All events are send with the maximum priority",
|
||||||
|
"ntfyPriorityHelptextAllExceptDown": "All events are send with this priority, except {0}-events, which have a priority of {1}",
|
||||||
"ntfyUsernameAndPassword": "Username and Password",
|
"ntfyUsernameAndPassword": "Username and Password",
|
||||||
"twilioAccountSID": "Account SID",
|
"twilioAccountSID": "Account SID",
|
||||||
"twilioApiKey": "Api Key (optional)",
|
"twilioApiKey": "Api Key (optional)",
|
||||||
@@ -809,5 +820,6 @@
|
|||||||
"showCertificateExpiry": "Show Certificate Expiry",
|
"showCertificateExpiry": "Show Certificate Expiry",
|
||||||
"noOrBadCertificate": "No/Bad Certificate",
|
"noOrBadCertificate": "No/Bad Certificate",
|
||||||
"gamedigGuessPort": "Gamedig: Guess Port",
|
"gamedigGuessPort": "Gamedig: Guess Port",
|
||||||
"gamedigGuessPortDescription": "The port used by Valve Server Query Protocol may be different from the client port. Try this if the monitor cannot connect to your server."
|
"gamedigGuessPortDescription": "The port used by Valve Server Query Protocol may be different from the client port. Try this if the monitor cannot connect to your server.",
|
||||||
|
"apiKeysDisabledMsg": "API keys are disabled because authentication is disabled."
|
||||||
}
|
}
|
||||||
|
@@ -91,21 +91,20 @@ export default {
|
|||||||
|
|
||||||
this.socket.initedSocketIO = true;
|
this.socket.initedSocketIO = true;
|
||||||
|
|
||||||
let protocol = (location.protocol === "https:") ? "wss://" : "ws://";
|
let protocol = location.protocol + "//";
|
||||||
|
|
||||||
let wsHost;
|
let url;
|
||||||
const env = process.env.NODE_ENV || "production";
|
const env = process.env.NODE_ENV || "production";
|
||||||
if (env === "development" && isDevContainer()) {
|
if (env === "development" && isDevContainer()) {
|
||||||
wsHost = protocol + getDevContainerServerHostname();
|
url = protocol + getDevContainerServerHostname();
|
||||||
} else if (env === "development" || localStorage.dev === "dev") {
|
} else if (env === "development" || localStorage.dev === "dev") {
|
||||||
wsHost = protocol + location.hostname + ":3001";
|
url = protocol + location.hostname + ":3001";
|
||||||
} else {
|
} else {
|
||||||
wsHost = protocol + location.host;
|
// Connect to the current url
|
||||||
|
url = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
socket = io(wsHost, {
|
socket = io(url);
|
||||||
transports: [ "websocket" ],
|
|
||||||
});
|
|
||||||
|
|
||||||
socket.on("info", (info) => {
|
socket.on("info", (info) => {
|
||||||
this.info = info;
|
this.info = info;
|
||||||
@@ -288,6 +287,10 @@ export default {
|
|||||||
socket.on("initServerTimezone", () => {
|
socket.on("initServerTimezone", () => {
|
||||||
socket.emit("initServerTimezone", dayjs.tz.guess());
|
socket.emit("initServerTimezone", dayjs.tz.guess());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket.on("refresh", () => {
|
||||||
|
location.reload();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -288,7 +288,9 @@
|
|||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="docker-host" class="form-label">{{ $t("Docker Host") }}</label>
|
<label for="docker-host" class="form-label">{{ $t("Docker Host") }}</label>
|
||||||
<ActionSelect
|
<ActionSelect
|
||||||
|
id="docker-host"
|
||||||
v-model="monitor.docker_host"
|
v-model="monitor.docker_host"
|
||||||
|
:action-aria-label="$t('openModalTo', $t('Setup Docker Host'))"
|
||||||
:options="dockerHostOptionsList"
|
:options="dockerHostOptionsList"
|
||||||
:disabled="$root.dockerHostList == null || $root.dockerHostList.length === 0"
|
:disabled="$root.dockerHostList == null || $root.dockerHostList.length === 0"
|
||||||
:icon="'plus'"
|
:icon="'plus'"
|
||||||
@@ -498,9 +500,11 @@
|
|||||||
|
|
||||||
<!-- Parent Monitor -->
|
<!-- Parent Monitor -->
|
||||||
<div class="my-3">
|
<div class="my-3">
|
||||||
<label for="parent" class="form-label">{{ $t("Monitor Group") }}</label>
|
<label for="monitorGroupSelector" class="form-label">{{ $t("Monitor Group") }}</label>
|
||||||
<ActionSelect
|
<ActionSelect
|
||||||
|
id="monitorGroupSelector"
|
||||||
v-model="monitor.parent"
|
v-model="monitor.parent"
|
||||||
|
:action-aria-label="$t('openModalTo', 'setup a new monitor group')"
|
||||||
:options="parentMonitorOptionsList"
|
:options="parentMonitorOptionsList"
|
||||||
:disabled="sortedGroupMonitorList.length === 0 && draftGroupName == null"
|
:disabled="sortedGroupMonitorList.length === 0 && draftGroupName == null"
|
||||||
:icon="'plus'"
|
:icon="'plus'"
|
||||||
@@ -844,9 +848,8 @@ import NotificationDialog from "../components/NotificationDialog.vue";
|
|||||||
import DockerHostDialog from "../components/DockerHostDialog.vue";
|
import DockerHostDialog from "../components/DockerHostDialog.vue";
|
||||||
import ProxyDialog from "../components/ProxyDialog.vue";
|
import ProxyDialog from "../components/ProxyDialog.vue";
|
||||||
import TagsManager from "../components/TagsManager.vue";
|
import TagsManager from "../components/TagsManager.vue";
|
||||||
import { genSecret, isDev, MAX_INTERVAL_SECOND, MIN_INTERVAL_SECOND } from "../util.ts";
|
import { genSecret, isDev, MAX_INTERVAL_SECOND, MIN_INTERVAL_SECOND, sleep } from "../util.ts";
|
||||||
import { hostNameRegexPattern } from "../util-frontend";
|
import { hostNameRegexPattern } from "../util-frontend";
|
||||||
import { sleep } from "../util";
|
|
||||||
import HiddenInput from "../components/HiddenInput.vue";
|
import HiddenInput from "../components/HiddenInput.vue";
|
||||||
|
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
@@ -860,7 +863,7 @@ const monitorDefaults = {
|
|||||||
interval: 60,
|
interval: 60,
|
||||||
retryInterval: 60,
|
retryInterval: 60,
|
||||||
resendInterval: 0,
|
resendInterval: 0,
|
||||||
maxretries: 1,
|
maxretries: 0,
|
||||||
timeout: 48,
|
timeout: 48,
|
||||||
notificationIDList: {},
|
notificationIDList: {},
|
||||||
ignoreTls: false,
|
ignoreTls: false,
|
||||||
|
@@ -69,13 +69,17 @@
|
|||||||
<div class="my-3">
|
<div class="my-3">
|
||||||
<label class="form-label">
|
<label class="form-label">
|
||||||
{{ $t("Domain Names") }}
|
{{ $t("Domain Names") }}
|
||||||
<font-awesome-icon icon="plus-circle" class="btn-add-domain action text-primary" @click="addDomainField" />
|
<button class="p-0 bg-transparent border-0" :aria-label="$t('Add a domain')" @click="addDomainField">
|
||||||
|
<font-awesome-icon icon="plus-circle" class="action text-primary" />
|
||||||
|
</button>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<ul class="list-group domain-name-list">
|
<ul class="list-group domain-name-list">
|
||||||
<li v-for="(domain, index) in config.domainNameList" :key="index" class="list-group-item">
|
<li v-for="(domain, index) in config.domainNameList" :key="index" class="list-group-item">
|
||||||
<input v-model="config.domainNameList[index]" type="text" class="no-bg domain-input" placeholder="example.com" />
|
<input v-model="config.domainNameList[index]" type="text" class="no-bg domain-input" placeholder="example.com" />
|
||||||
<font-awesome-icon icon="times" class="action remove ms-2 me-3 text-danger" @click="removeDomain(index)" />
|
<button class="p-0 bg-transparent border-0" :aria-label="$t('Remove domain', [ domain ])" @click="removeDomain(index)">
|
||||||
|
<font-awesome-icon icon="times" class="action remove ms-2 me-3 text-danger" />
|
||||||
|
</button>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
47
src/util.js
47
src/util.js
@@ -6,9 +6,12 @@
|
|||||||
//
|
//
|
||||||
// Backend uses the compiled file util.js
|
// Backend uses the compiled file util.js
|
||||||
// Frontend uses util.ts
|
// Frontend uses util.ts
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.localToUTC = exports.utcToLocal = exports.utcToISODateTime = exports.isoToUTCDateTime = exports.parseTimeFromTimeObject = exports.parseTimeObject = exports.getMaintenanceRelativeURL = exports.getMonitorRelativeURL = exports.genSecret = exports.getCryptoRandomInt = exports.getRandomInt = exports.getRandomArbitrary = exports.TimeLogger = exports.polyfill = exports.log = exports.debug = exports.ucfirst = exports.sleep = exports.flipStatus = exports.MIN_INTERVAL_SECOND = exports.MAX_INTERVAL_SECOND = exports.SQL_DATETIME_FORMAT_WITHOUT_SECOND = exports.SQL_DATETIME_FORMAT = exports.SQL_DATE_FORMAT = exports.STATUS_PAGE_MAINTENANCE = exports.STATUS_PAGE_PARTIAL_DOWN = exports.STATUS_PAGE_ALL_UP = exports.STATUS_PAGE_ALL_DOWN = exports.MAINTENANCE = exports.PENDING = exports.UP = exports.DOWN = exports.appName = exports.isDev = void 0;
|
exports.localToUTC = exports.utcToLocal = exports.utcToISODateTime = exports.isoToUTCDateTime = exports.parseTimeFromTimeObject = exports.parseTimeObject = exports.getMaintenanceRelativeURL = exports.getMonitorRelativeURL = exports.genSecret = exports.getCryptoRandomInt = exports.getRandomInt = exports.getRandomArbitrary = exports.TimeLogger = exports.polyfill = exports.log = exports.debug = exports.ucfirst = exports.sleep = exports.flipStatus = exports.badgeConstants = exports.MIN_INTERVAL_SECOND = exports.MAX_INTERVAL_SECOND = exports.SQL_DATETIME_FORMAT_WITHOUT_SECOND = exports.SQL_DATETIME_FORMAT = exports.SQL_DATE_FORMAT = exports.STATUS_PAGE_MAINTENANCE = exports.STATUS_PAGE_PARTIAL_DOWN = exports.STATUS_PAGE_ALL_UP = exports.STATUS_PAGE_ALL_DOWN = exports.MAINTENANCE = exports.PENDING = exports.UP = exports.DOWN = exports.appName = exports.isDev = void 0;
|
||||||
const dayjs = require("dayjs");
|
const dayjs_1 = __importDefault(require("dayjs"));
|
||||||
exports.isDev = process.env.NODE_ENV === "development";
|
exports.isDev = process.env.NODE_ENV === "development";
|
||||||
exports.appName = "Uptime Kuma";
|
exports.appName = "Uptime Kuma";
|
||||||
exports.DOWN = 0;
|
exports.DOWN = 0;
|
||||||
@@ -24,6 +27,25 @@ exports.SQL_DATETIME_FORMAT = "YYYY-MM-DD HH:mm:ss";
|
|||||||
exports.SQL_DATETIME_FORMAT_WITHOUT_SECOND = "YYYY-MM-DD HH:mm";
|
exports.SQL_DATETIME_FORMAT_WITHOUT_SECOND = "YYYY-MM-DD HH:mm";
|
||||||
exports.MAX_INTERVAL_SECOND = 2073600; // 24 days
|
exports.MAX_INTERVAL_SECOND = 2073600; // 24 days
|
||||||
exports.MIN_INTERVAL_SECOND = 20; // 20 seconds
|
exports.MIN_INTERVAL_SECOND = 20; // 20 seconds
|
||||||
|
exports.badgeConstants = {
|
||||||
|
naColor: "#999",
|
||||||
|
defaultUpColor: "#66c20a",
|
||||||
|
defaultWarnColor: "#eed202",
|
||||||
|
defaultDownColor: "#c2290a",
|
||||||
|
defaultPendingColor: "#f8a306",
|
||||||
|
defaultMaintenanceColor: "#1747f5",
|
||||||
|
defaultPingColor: "blue",
|
||||||
|
defaultStyle: "flat",
|
||||||
|
defaultPingValueSuffix: "ms",
|
||||||
|
defaultPingLabelSuffix: "h",
|
||||||
|
defaultUptimeValueSuffix: "%",
|
||||||
|
defaultUptimeLabelSuffix: "h",
|
||||||
|
defaultCertExpValueSuffix: " days",
|
||||||
|
defaultCertExpLabelSuffix: "h",
|
||||||
|
// Values Come From Default Notification Times
|
||||||
|
defaultCertExpireWarnDays: "14",
|
||||||
|
defaultCertExpireDownDays: "7"
|
||||||
|
};
|
||||||
/** Flip the status of s */
|
/** Flip the status of s */
|
||||||
function flipStatus(s) {
|
function flipStatus(s) {
|
||||||
if (s === exports.UP) {
|
if (s === exports.UP) {
|
||||||
@@ -101,17 +123,20 @@ class Logger {
|
|||||||
* @param level Log level. One of INFO, WARN, ERROR, DEBUG or can be customized.
|
* @param level Log level. One of INFO, WARN, ERROR, DEBUG or can be customized.
|
||||||
*/
|
*/
|
||||||
log(module, msg, level) {
|
log(module, msg, level) {
|
||||||
|
if (level === "DEBUG" && !exports.isDev) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (this.hideLog[level] && this.hideLog[level].includes(module.toLowerCase())) {
|
if (this.hideLog[level] && this.hideLog[level].includes(module.toLowerCase())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
module = module.toUpperCase();
|
module = module.toUpperCase();
|
||||||
level = level.toUpperCase();
|
level = level.toUpperCase();
|
||||||
let now;
|
let now;
|
||||||
if (dayjs.tz) {
|
if (dayjs_1.default.tz) {
|
||||||
now = dayjs.tz(new Date()).format();
|
now = dayjs_1.default.tz(new Date()).format();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
now = dayjs().format();
|
now = (0, dayjs_1.default)().format();
|
||||||
}
|
}
|
||||||
const formattedMessage = (typeof msg === "string") ? `${now} [${module}] ${level}: ${msg}` : msg;
|
const formattedMessage = (typeof msg === "string") ? `${now} [${module}] ${level}: ${msg}` : msg;
|
||||||
if (level === "INFO") {
|
if (level === "INFO") {
|
||||||
@@ -200,7 +225,7 @@ function polyfill() {
|
|||||||
exports.polyfill = polyfill;
|
exports.polyfill = polyfill;
|
||||||
class TimeLogger {
|
class TimeLogger {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.startTime = dayjs().valueOf();
|
this.startTime = (0, dayjs_1.default)().valueOf();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Output time since start of monitor
|
* Output time since start of monitor
|
||||||
@@ -208,7 +233,7 @@ class TimeLogger {
|
|||||||
*/
|
*/
|
||||||
print(name) {
|
print(name) {
|
||||||
if (exports.isDev && process.env.TIMELOGGER === "1") {
|
if (exports.isDev && process.env.TIMELOGGER === "1") {
|
||||||
console.log(name + ": " + (dayjs().valueOf() - this.startTime) + "ms");
|
console.log(name + ": " + ((0, dayjs_1.default)().valueOf() - this.startTime) + "ms");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -372,21 +397,21 @@ exports.parseTimeFromTimeObject = parseTimeFromTimeObject;
|
|||||||
* @returns ISO Date time
|
* @returns ISO Date time
|
||||||
*/
|
*/
|
||||||
function isoToUTCDateTime(input) {
|
function isoToUTCDateTime(input) {
|
||||||
return dayjs(input).utc().format(exports.SQL_DATETIME_FORMAT);
|
return (0, dayjs_1.default)(input).utc().format(exports.SQL_DATETIME_FORMAT);
|
||||||
}
|
}
|
||||||
exports.isoToUTCDateTime = isoToUTCDateTime;
|
exports.isoToUTCDateTime = isoToUTCDateTime;
|
||||||
/**
|
/**
|
||||||
* @param input
|
* @param input
|
||||||
*/
|
*/
|
||||||
function utcToISODateTime(input) {
|
function utcToISODateTime(input) {
|
||||||
return dayjs.utc(input).toISOString();
|
return dayjs_1.default.utc(input).toISOString();
|
||||||
}
|
}
|
||||||
exports.utcToISODateTime = utcToISODateTime;
|
exports.utcToISODateTime = utcToISODateTime;
|
||||||
/**
|
/**
|
||||||
* For SQL_DATETIME_FORMAT
|
* For SQL_DATETIME_FORMAT
|
||||||
*/
|
*/
|
||||||
function utcToLocal(input, format = exports.SQL_DATETIME_FORMAT) {
|
function utcToLocal(input, format = exports.SQL_DATETIME_FORMAT) {
|
||||||
return dayjs.utc(input).local().format(format);
|
return dayjs_1.default.utc(input).local().format(format);
|
||||||
}
|
}
|
||||||
exports.utcToLocal = utcToLocal;
|
exports.utcToLocal = utcToLocal;
|
||||||
/**
|
/**
|
||||||
@@ -396,6 +421,6 @@ exports.utcToLocal = utcToLocal;
|
|||||||
* @returns Date in requested format
|
* @returns Date in requested format
|
||||||
*/
|
*/
|
||||||
function localToUTC(input, format = exports.SQL_DATETIME_FORMAT) {
|
function localToUTC(input, format = exports.SQL_DATETIME_FORMAT) {
|
||||||
return dayjs(input).utc().format(format);
|
return (0, dayjs_1.default)(input).utc().format(format);
|
||||||
}
|
}
|
||||||
exports.localToUTC = localToUTC;
|
exports.localToUTC = localToUTC;
|
||||||
|
26
src/util.ts
26
src/util.ts
@@ -6,7 +6,7 @@
|
|||||||
// Backend uses the compiled file util.js
|
// Backend uses the compiled file util.js
|
||||||
// Frontend uses util.ts
|
// Frontend uses util.ts
|
||||||
|
|
||||||
import * as dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import * as timezone from "dayjs/plugin/timezone";
|
import * as timezone from "dayjs/plugin/timezone";
|
||||||
import * as utc from "dayjs/plugin/utc";
|
import * as utc from "dayjs/plugin/utc";
|
||||||
|
|
||||||
@@ -29,6 +29,26 @@ export const SQL_DATETIME_FORMAT_WITHOUT_SECOND = "YYYY-MM-DD HH:mm";
|
|||||||
export const MAX_INTERVAL_SECOND = 2073600; // 24 days
|
export const MAX_INTERVAL_SECOND = 2073600; // 24 days
|
||||||
export const MIN_INTERVAL_SECOND = 20; // 20 seconds
|
export const MIN_INTERVAL_SECOND = 20; // 20 seconds
|
||||||
|
|
||||||
|
export const badgeConstants = {
|
||||||
|
naColor: "#999",
|
||||||
|
defaultUpColor: "#66c20a",
|
||||||
|
defaultWarnColor: "#eed202",
|
||||||
|
defaultDownColor: "#c2290a",
|
||||||
|
defaultPendingColor: "#f8a306",
|
||||||
|
defaultMaintenanceColor: "#1747f5",
|
||||||
|
defaultPingColor: "blue", // as defined by badge-maker / shields.io
|
||||||
|
defaultStyle: "flat",
|
||||||
|
defaultPingValueSuffix: "ms",
|
||||||
|
defaultPingLabelSuffix: "h",
|
||||||
|
defaultUptimeValueSuffix: "%",
|
||||||
|
defaultUptimeLabelSuffix: "h",
|
||||||
|
defaultCertExpValueSuffix: " days",
|
||||||
|
defaultCertExpLabelSuffix: "h",
|
||||||
|
// Values Come From Default Notification Times
|
||||||
|
defaultCertExpireWarnDays: "14",
|
||||||
|
defaultCertExpireDownDays: "7"
|
||||||
|
};
|
||||||
|
|
||||||
/** Flip the status of s */
|
/** Flip the status of s */
|
||||||
export function flipStatus(s: number) {
|
export function flipStatus(s: number) {
|
||||||
if (s === UP) {
|
if (s === UP) {
|
||||||
@@ -115,6 +135,10 @@ class Logger {
|
|||||||
* @param level Log level. One of INFO, WARN, ERROR, DEBUG or can be customized.
|
* @param level Log level. One of INFO, WARN, ERROR, DEBUG or can be customized.
|
||||||
*/
|
*/
|
||||||
log(module: string, msg: any, level: string) {
|
log(module: string, msg: any, level: string) {
|
||||||
|
if (level === "DEBUG" && !isDev) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.hideLog[level] && this.hideLog[level].includes(module.toLowerCase())) {
|
if (this.hideLog[level] && this.hideLog[level].includes(module.toLowerCase())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -3,42 +3,62 @@ import { currentLocale } from "../../../src/i18n";
|
|||||||
describe("Test i18n.js", () => {
|
describe("Test i18n.js", () => {
|
||||||
|
|
||||||
it("currentLocale()", () => {
|
it("currentLocale()", () => {
|
||||||
const setLanguage = (language) => {
|
const setLanguages = (languages) => {
|
||||||
Object.defineProperty(window.navigator, 'language', {
|
Object.defineProperty(navigator, 'language', {
|
||||||
value: language,
|
value: languages[0],
|
||||||
writable: true
|
writable: true
|
||||||
|
});
|
||||||
|
Object.defineProperty(navigator, 'languages', {
|
||||||
|
value: languages,
|
||||||
|
writable: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
setLanguage('en-EN');
|
|
||||||
|
|
||||||
|
setLanguages(['en-EN']);
|
||||||
expect(currentLocale()).equal("en");
|
expect(currentLocale()).equal("en");
|
||||||
|
|
||||||
setLanguage('zh-HK');
|
setLanguages(['zh-HK']);
|
||||||
expect(currentLocale()).equal("zh-HK");
|
expect(currentLocale()).equal("zh-HK");
|
||||||
|
|
||||||
// Note that in Safari on iOS prior to 10.2, the country code returned is lowercase: "en-us", "fr-fr" etc.
|
// Note that in Safari on iOS prior to 10.2, the country code returned is lowercase: "en-us", "fr-fr" etc.
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/Navigator/language
|
// https://developer.mozilla.org/en-US/docs/Web/API/Navigator/language
|
||||||
setLanguage('zh-hk');
|
setLanguages(['zh-hk']);
|
||||||
expect(currentLocale()).equal("en");
|
expect(currentLocale()).equal("en");
|
||||||
|
|
||||||
setLanguage('en-US');
|
setLanguages(['en-US']);
|
||||||
expect(currentLocale()).equal("en");
|
expect(currentLocale()).equal("en");
|
||||||
|
|
||||||
setLanguage('ja-ZZ');
|
setLanguages(['ja-ZZ']);
|
||||||
expect(currentLocale()).equal("ja");
|
expect(currentLocale()).equal("ja");
|
||||||
|
|
||||||
setLanguage('zz-ZZ');
|
setLanguages(['zz-ZZ']);
|
||||||
expect(currentLocale()).equal("en");
|
expect(currentLocale()).equal("en");
|
||||||
|
|
||||||
setLanguage('zz-ZZ');
|
setLanguages(['zz-ZZ']);
|
||||||
expect(currentLocale()).equal("en");
|
expect(currentLocale()).equal("en");
|
||||||
|
|
||||||
setLanguage('en');
|
setLanguages(['en-US', 'en', 'pl', 'ja']);
|
||||||
localStorage.locale = "en";
|
|
||||||
expect(currentLocale()).equal("en");
|
expect(currentLocale()).equal("en");
|
||||||
|
|
||||||
localStorage.locale = "zh-HK";
|
setLanguages(['en-US', 'pl', 'ja']);
|
||||||
expect(currentLocale()).equal("zh-HK");
|
expect(currentLocale()).equal("en");
|
||||||
|
|
||||||
|
setLanguages(['abc', 'en-US', 'pl', 'ja']);
|
||||||
|
expect(currentLocale()).equal("en");
|
||||||
|
|
||||||
|
setLanguages(['fil-PH', 'pl']);
|
||||||
|
expect(currentLocale()).equal("pl");
|
||||||
|
|
||||||
|
setLanguages(['shi-Latn-MA', 'pl']);
|
||||||
|
expect(currentLocale()).equal("pl");
|
||||||
|
|
||||||
|
setLanguages(['pl']);
|
||||||
|
localStorage.locale = "ja-ZZ";
|
||||||
|
expect(currentLocale()).equal("ja");
|
||||||
|
|
||||||
|
setLanguages(['pl']);
|
||||||
|
localStorage.locale = "invalid-lang";
|
||||||
|
expect(currentLocale()).equal("pl");
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@@ -11,7 +11,8 @@
|
|||||||
"removeComments": false,
|
"removeComments": false,
|
||||||
"preserveConstEnums": true,
|
"preserveConstEnums": true,
|
||||||
"sourceMap": false,
|
"sourceMap": false,
|
||||||
"strict": true
|
"strict": true,
|
||||||
|
"esModuleInterop": true
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"./src/util.ts"
|
"./src/util.ts"
|
||||||
|
Reference in New Issue
Block a user