diff --git a/extra/reset-password.js b/extra/reset-password.js index b87d90f16..e66173af1 100644 --- a/extra/reset-password.js +++ b/extra/reset-password.js @@ -3,6 +3,7 @@ console.log("== Uptime Kuma Reset Password Tool =="); const Database = require("../server/database"); const { R } = require("redbean-node"); const readline = require("readline"); +const { passwordStrength } = require("check-password-strength"); const { initJWTSecret } = require("../server/util-server"); const User = require("../server/model/user"); const { io } = require("socket.io-client"); @@ -42,8 +43,15 @@ const main = async () => { console.log("Using password from argument"); console.warn("\x1b[31m%s\x1b[0m", "Warning: the password might be stored, in plain text, in your shell's history"); password = confirmPassword = args["new-password"] + ""; + if (passwordStrength(password).value === "Too weak") { + throw new Error("Password is too weak, please use a stronger password."); + } } else { password = await question("New Password: "); + if (passwordStrength(password).value === "Too weak") { + console.log("Password is too weak, please try again."); + continue; + } confirmPassword = await question("Confirm New Password: "); } diff --git a/package-lock.json b/package-lock.json index 7ab51157b..c5269c088 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,7 @@ "command-exists": "~1.2.9", "compare-versions": "~3.6.0", "compression": "~1.7.4", + "country-flag-emoji-polyfill": "^0.1.8", "croner": "~8.1.0", "dayjs": "~1.11.5", "dev-null": "^0.1.1", @@ -7204,6 +7205,12 @@ } } }, + "node_modules/country-flag-emoji-polyfill": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/country-flag-emoji-polyfill/-/country-flag-emoji-polyfill-0.1.8.tgz", + "integrity": "sha512-Mbah52sADS3gshUYhK5142gtUuJpHYOXlXtLFI3Ly4RqgkmPMvhX9kMZSTqDM8P7UqtSW99eHKFphhQSGXA3Cg==", + "license": "MIT" + }, "node_modules/cpu-features": { "version": "0.0.10", "resolved": "https://registry.npmjs.org/cpu-features/-/cpu-features-0.0.10.tgz", diff --git a/package.json b/package.json index 4284d5b5e..4a5aefd0d 100644 --- a/package.json +++ b/package.json @@ -82,6 +82,7 @@ "command-exists": "~1.2.9", "compare-versions": "~3.6.0", "compression": "~1.7.4", + "country-flag-emoji-polyfill": "^0.1.8", "croner": "~8.1.0", "dayjs": "~1.11.5", "dev-null": "^0.1.1", diff --git a/server/model/monitor.js b/server/model/monitor.js index 5999d93e7..a07f2595a 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -380,39 +380,6 @@ class Monitor extends BeanModel { if (await Monitor.isUnderMaintenance(this.id)) { bean.msg = "Monitor under maintenance"; bean.status = MAINTENANCE; - } else if (this.type === "group") { - const children = await Monitor.getChildren(this.id); - - if (children.length > 0) { - bean.status = UP; - bean.msg = "All children up and running"; - for (const child of children) { - if (!child.active) { - // Ignore inactive childs - continue; - } - const lastBeat = await Monitor.getPreviousHeartbeat(child.id); - - // Only change state if the monitor is in worse conditions then the ones before - // lastBeat.status could be null - if (!lastBeat) { - bean.status = PENDING; - } else if (bean.status === UP && (lastBeat.status === PENDING || lastBeat.status === DOWN)) { - bean.status = lastBeat.status; - } else if (bean.status === PENDING && lastBeat.status === DOWN) { - bean.status = lastBeat.status; - } - } - - if (bean.status !== UP) { - bean.msg = "Child inaccessible"; - } - } else { - // Set status pending if group is empty - bean.status = PENDING; - bean.msg = "Group empty"; - } - } else if (this.type === "http" || this.type === "keyword" || this.type === "json-query") { // Do not do any queries/high loading things before the "bean.ping" let startTime = dayjs().valueOf(); @@ -1625,7 +1592,7 @@ class Monitor extends BeanModel { /** * Gets all Children of the monitor * @param {number} monitorID ID of monitor to get - * @returns {Promise>} Children + * @returns {Promise[]>} Children */ static async getChildren(monitorID) { return await R.getAll(` diff --git a/server/monitor-types/group.js b/server/monitor-types/group.js new file mode 100644 index 000000000..28d0443d4 --- /dev/null +++ b/server/monitor-types/group.js @@ -0,0 +1,49 @@ +const { UP, PENDING, DOWN } = require("../../src/util"); +const { MonitorType } = require("./monitor-type"); +const Monitor = require("../model/monitor"); + +class GroupMonitorType extends MonitorType { + name = "group"; + + /** + * @inheritdoc + */ + async check(monitor, heartbeat, _server) { + const children = await Monitor.getChildren(monitor.id); + + if (children.length > 0) { + heartbeat.status = UP; + heartbeat.msg = "All children up and running"; + for (const child of children) { + if (!child.active) { + // Ignore inactive childs + continue; + } + const lastBeat = await Monitor.getPreviousHeartbeat(child.id); + + // Only change state if the monitor is in worse conditions then the ones before + // lastBeat.status could be null + if (!lastBeat) { + heartbeat.status = PENDING; + } else if (heartbeat.status === UP && (lastBeat.status === PENDING || lastBeat.status === DOWN)) { + heartbeat.status = lastBeat.status; + } else if (heartbeat.status === PENDING && lastBeat.status === DOWN) { + heartbeat.status = lastBeat.status; + } + } + + if (heartbeat.status !== UP) { + heartbeat.msg = "Child inaccessible"; + } + } else { + // Set status pending if group is empty + heartbeat.status = PENDING; + heartbeat.msg = "Group empty"; + } + } +} + +module.exports = { + GroupMonitorType, +}; + diff --git a/server/notification-providers/sms-planet.js b/server/notification-providers/sms-planet.js new file mode 100644 index 000000000..97e9e715e --- /dev/null +++ b/server/notification-providers/sms-planet.js @@ -0,0 +1,40 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); + +class SMSPlanet extends NotificationProvider { + name = "SMSPlanet"; + + /** + * @inheritdoc + */ + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + const okMsg = "Sent Successfully."; + const url = "https://api2.smsplanet.pl/sms"; + + try { + let config = { + headers: { + "Authorization": "Bearer " + notification.smsplanetApiToken, + "content-type": "multipart/form-data" + } + }; + + let data = { + "from": notification.smsplanetSenderName, + "to": notification.smsplanetPhoneNumbers, + "msg": msg.replace(/🔴/, "❌") + }; + + let response = await axios.post(url, data, config); + if (!response.data?.messageId) { + throw new Error(response.data?.errorMsg ?? "SMSPlanet server did not respond with the expected result"); + } + + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = SMSPlanet; diff --git a/server/notification.js b/server/notification.js index ed1071968..8682e6f5c 100644 --- a/server/notification.js +++ b/server/notification.js @@ -73,6 +73,7 @@ const Onesender = require("./notification-providers/onesender"); const Wpush = require("./notification-providers/wpush"); const SendGrid = require("./notification-providers/send-grid"); const YZJ = require("./notification-providers/yzj"); +const SMSPlanet = require("./notification-providers/sms-planet"); class Notification { @@ -162,7 +163,8 @@ class Notification { new Cellsynt(), new Wpush(), new SendGrid(), - new YZJ() + new YZJ(), + new SMSPlanet(), ]; for (let item of list) { if (! item.name) { diff --git a/server/routers/status-page-router.js b/server/routers/status-page-router.js index 893f57564..6e57451f1 100644 --- a/server/routers/status-page-router.js +++ b/server/routers/status-page-router.js @@ -89,7 +89,7 @@ router.get("/api/status-page/heartbeat/:slug", cache("1 minutes"), async (reques SELECT * FROM heartbeat WHERE monitor_id = ? ORDER BY time DESC - LIMIT 50 + LIMIT 100 `, [ monitorID, ]); diff --git a/server/uptime-kuma-server.js b/server/uptime-kuma-server.js index 062f098d7..cdaa83dfc 100644 --- a/server/uptime-kuma-server.js +++ b/server/uptime-kuma-server.js @@ -113,6 +113,7 @@ class UptimeKumaServer { UptimeKumaServer.monitorTypeList["tailscale-ping"] = new TailscalePing(); UptimeKumaServer.monitorTypeList["dns"] = new DnsMonitorType(); UptimeKumaServer.monitorTypeList["mqtt"] = new MqttMonitorType(); + UptimeKumaServer.monitorTypeList["group"] = new GroupMonitorType(); UptimeKumaServer.monitorTypeList["snmp"] = new SNMPMonitorType(); UptimeKumaServer.monitorTypeList["mongodb"] = new MongodbMonitorType(); UptimeKumaServer.monitorTypeList["rabbitmq"] = new RabbitMqMonitorType(); @@ -551,6 +552,7 @@ const { RealBrowserMonitorType } = require("./monitor-types/real-browser-monitor const { TailscalePing } = require("./monitor-types/tailscale-ping"); const { DnsMonitorType } = require("./monitor-types/dns"); const { MqttMonitorType } = require("./monitor-types/mqtt"); +const { GroupMonitorType } = require("./monitor-types/group"); const { SNMPMonitorType } = require("./monitor-types/snmp"); const { MongodbMonitorType } = require("./monitor-types/mongodb"); const { RabbitMqMonitorType } = require("./monitor-types/rabbitmq"); diff --git a/src/App.vue b/src/App.vue index f102360c1..a7bb69b42 100644 --- a/src/App.vue +++ b/src/App.vue @@ -4,9 +4,11 @@ diff --git a/src/assets/app.scss b/src/assets/app.scss index 6ddc99dec..fd43a7bee 100644 --- a/src/assets/app.scss +++ b/src/assets/app.scss @@ -3,7 +3,7 @@ @import "node_modules/bootstrap/scss/bootstrap"; #app { - font-family: BlinkMacSystemFont, segoe ui, Roboto, helvetica neue, Arial, noto sans, sans-serif, apple color emoji, segoe ui emoji, segoe ui symbol, noto color emoji; + font-family: "Twemoji Country Flags", BlinkMacSystemFont, segoe ui, Roboto, helvetica neue, Arial, noto sans, sans-serif, apple color emoji, segoe ui emoji, segoe ui symbol, noto color emoji; } h1 { diff --git a/src/components/MonitorListItem.vue b/src/components/MonitorListItem.vue index 74ba4835c..ce38086b9 100644 --- a/src/components/MonitorListItem.vue +++ b/src/components/MonitorListItem.vue @@ -14,7 +14,7 @@
-
+
@@ -22,11 +22,11 @@ {{ monitor.name }}
-
+
-
+
diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index fa1bbefb2..3ea3e23d4 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -186,7 +186,8 @@ export default { "PushPlus": "PushPlus (推送加)", "smsc": "SMSC", "WPush": "WPush(wpush.cn)", - "YZJ": "YZJ (云之家自定义机器人)" + "YZJ": "YZJ (云之家自定义机器人)", + "SMSPlanet": "SMSPlanet.pl" }; // Sort by notification name diff --git a/src/components/PublicGroupList.vue b/src/components/PublicGroupList.vue index bacddbf13..38aca2957 100644 --- a/src/components/PublicGroupList.vue +++ b/src/components/PublicGroupList.vue @@ -33,7 +33,7 @@ diff --git a/src/lang/en.json b/src/lang/en.json index cb704b0fe..b53fa1350 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -1067,5 +1067,12 @@ "YZJ Robot Token": "YZJ Robot token", "Plain Text": "Plain Text", "Message Template": "Message Template", - "Template Format": "Template Format" + "Template Format": "Template Format", + "Font Twemoji by Twitter licensed under": "Font Twemoji by Twitter licensed under", + "smsplanetApiToken": "Token for the SMSPlanet API", + "smsplanetApiDocs": "Detailed information on obtaining API tokens can be found in {the_smsplanet_documentation}.", + "the smsplanet documentation": "the smsplanet documentation", + "Phone numbers": "Phone numbers", + "Sender name": "Sender name", + "smsplanetNeedToApproveName": "Needs to be approved in the client panel" }