From 5e6d945095f0923c4fb748a8fbfe94312a7bc021 Mon Sep 17 00:00:00 2001 From: Jasper Miller-Waugh <contact@jmw.nz> Date: Wed, 27 Oct 2021 23:06:06 +1300 Subject: [PATCH 01/25] Most hacked in POC --- server/routers/api-router.js | 8 ++++++-- src/components/PublicGroupList.vue | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/server/routers/api-router.js b/server/routers/api-router.js index fbe8136e..be186ccc 100644 --- a/server/routers/api-router.js +++ b/server/routers/api-router.js @@ -141,9 +141,13 @@ router.get("/api/status-page/monitor-list", cache("5 minutes"), async (_request, await checkPublished(); const publicGroupList = []; let list = await R.find("group", " public = 1 ORDER BY weight "); - for (let groupBean of list) { - publicGroupList.push(await groupBean.toPublicJSON()); + let monitor_info = await groupBean.toPublicJSON() + monitor_info.monitorList = await Promise.all(monitor_info.monitorList.map( async (monitor)=>{ + let tags = await R.getAll("SELECT mt.monitor_id,mt.value, tag.name, tag.color FROM monitor_tag mt JOIN tag ON mt.tag_id = tag.id WHERE mt.monitor_id = ?", [monitor.id]); + return {...monitor,tags: tags} + })) + publicGroupList.push(monitor_info); } response.json(publicGroupList); diff --git a/src/components/PublicGroupList.vue b/src/components/PublicGroupList.vue index 23d19e6c..39fb342e 100644 --- a/src/components/PublicGroupList.vue +++ b/src/components/PublicGroupList.vue @@ -40,6 +40,7 @@ <Uptime :monitor="monitor.element" type="24" :pill="true" /> {{ monitor.element.name }} + <Tag v-for="tag in monitor.element.tags" :key="tag" :item="tag" :size="'sm'" /> </div> </div> <div :key="$root.userHeartbeatBar" class="col-3 col-md-4"> @@ -59,12 +60,14 @@ import Draggable from "vuedraggable"; import HeartbeatBar from "./HeartbeatBar.vue"; import Uptime from "./Uptime.vue"; +import Tag from "./Tag.vue"; export default { components: { Draggable, HeartbeatBar, Uptime, + Tag, }, props: { editMode: { From 9143b73f844ebd1214c2160a6e1319fa91191b6f Mon Sep 17 00:00:00 2001 From: Jasper Miller-Waugh <contact@jmw.nz> Date: Thu, 28 Oct 2021 14:53:27 +1300 Subject: [PATCH 02/25] Styling for tags --- src/assets/app.scss | 4 ++++ src/components/PublicGroupList.vue | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/assets/app.scss b/src/assets/app.scss index e1a5d052..ae1ff687 100644 --- a/src/assets/app.scss +++ b/src/assets/app.scss @@ -346,6 +346,10 @@ textarea.form-control { &.active { background-color: #cdf8f4; } + // Removes margin to line up tags list with uptime percentage + .tags, .tag-wrapper:first-child { + margin-left: 0 !important; + } } } diff --git a/src/components/PublicGroupList.vue b/src/components/PublicGroupList.vue index 39fb342e..97441d50 100644 --- a/src/components/PublicGroupList.vue +++ b/src/components/PublicGroupList.vue @@ -40,6 +40,9 @@ <Uptime :monitor="monitor.element" type="24" :pill="true" /> {{ monitor.element.name }} + + </div> + <div class="tags"> <Tag v-for="tag in monitor.element.tags" :key="tag" :item="tag" :size="'sm'" /> </div> </div> From 348c5ec995c34d7d17f1e44297e205f04858d787 Mon Sep 17 00:00:00 2001 From: Jasper Miller-Waugh <contact@jmw.nz> Date: Thu, 28 Oct 2021 15:07:19 +1300 Subject: [PATCH 03/25] Match lint settings --- server/routers/api-router.js | 7 ++++--- src/components/PublicGroupList.vue | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/routers/api-router.js b/server/routers/api-router.js index be186ccc..bf0cc54c 100644 --- a/server/routers/api-router.js +++ b/server/routers/api-router.js @@ -142,12 +142,13 @@ router.get("/api/status-page/monitor-list", cache("5 minutes"), async (_request, const publicGroupList = []; let list = await R.find("group", " public = 1 ORDER BY weight "); for (let groupBean of list) { - let monitor_info = await groupBean.toPublicJSON() - monitor_info.monitorList = await Promise.all(monitor_info.monitorList.map( async (monitor)=>{ + let monitorGroup = await groupBean.toPublicJSON() + monitorGroup.monitorList = await Promise.all(monitorGroup.monitorList.map( async (monitor)=>{ + // Includes tags as an array in response, allows for tags to be displayed on public status page let tags = await R.getAll("SELECT mt.monitor_id,mt.value, tag.name, tag.color FROM monitor_tag mt JOIN tag ON mt.tag_id = tag.id WHERE mt.monitor_id = ?", [monitor.id]); return {...monitor,tags: tags} })) - publicGroupList.push(monitor_info); + publicGroupList.push(monitorGroup); } response.json(publicGroupList); diff --git a/src/components/PublicGroupList.vue b/src/components/PublicGroupList.vue index 97441d50..f30edcef 100644 --- a/src/components/PublicGroupList.vue +++ b/src/components/PublicGroupList.vue @@ -40,7 +40,6 @@ <Uptime :monitor="monitor.element" type="24" :pill="true" /> {{ monitor.element.name }} - </div> <div class="tags"> <Tag v-for="tag in monitor.element.tags" :key="tag" :item="tag" :size="'sm'" /> From 24664cde2c204f5809c193643837b097cdce81af Mon Sep 17 00:00:00 2001 From: Jasper Miller-Waugh <contact@jmw.nz> Date: Thu, 28 Oct 2021 15:22:35 +1300 Subject: [PATCH 04/25] Smarter CSS to fix Mobile alignment --- src/assets/app.scss | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/assets/app.scss b/src/assets/app.scss index ae1ff687..db01e12d 100644 --- a/src/assets/app.scss +++ b/src/assets/app.scss @@ -346,9 +346,9 @@ textarea.form-control { &.active { background-color: #cdf8f4; } - // Removes margin to line up tags list with uptime percentage - .tags, .tag-wrapper:first-child { - margin-left: 0 !important; + .tags { + // Removes margin to line up tags list with uptime percentage + margin-left: -0.25rem; } } } From b32bfb3ff1578483dd3b8f10e3a05aa83a1fc3cf Mon Sep 17 00:00:00 2001 From: Jasper Miller-Waugh <contact@jmw.nz> Date: Fri, 29 Oct 2021 18:19:24 +1300 Subject: [PATCH 05/25] Added toggle for tag visibility --- server/routers/api-router.js | 18 +++++++++++++----- src/pages/StatusPage.vue | 31 +++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/server/routers/api-router.js b/server/routers/api-router.js index bf0cc54c..b58c4a00 100644 --- a/server/routers/api-router.js +++ b/server/routers/api-router.js @@ -101,6 +101,10 @@ router.get("/api/status-page/config", async (_request, response) => { config.statusPagePublished = true; } + if (! config.statusPageTags) { + config.statusPageTags = "hidden"; + } + if (! config.title) { config.title = "Uptime Kuma"; } @@ -143,11 +147,15 @@ router.get("/api/status-page/monitor-list", cache("5 minutes"), async (_request, let list = await R.find("group", " public = 1 ORDER BY weight "); for (let groupBean of list) { let monitorGroup = await groupBean.toPublicJSON() - monitorGroup.monitorList = await Promise.all(monitorGroup.monitorList.map( async (monitor)=>{ - // Includes tags as an array in response, allows for tags to be displayed on public status page - let tags = await R.getAll("SELECT mt.monitor_id,mt.value, tag.name, tag.color FROM monitor_tag mt JOIN tag ON mt.tag_id = tag.id WHERE mt.monitor_id = ?", [monitor.id]); - return {...monitor,tags: tags} - })) + console.log("\n\nsettings", await getSettings("statusPage")) + if ((await getSettings("statusPage")).statusPageTags=="visible") { + monitorGroup.monitorList = await Promise.all(monitorGroup.monitorList.map( async (monitor)=>{ + // Includes tags as an array in response, allows for tags to be displayed on public status page + let tags = await R.getAll("SELECT mt.monitor_id,mt.value, tag.name, tag.color FROM monitor_tag mt JOIN tag ON mt.tag_id = tag.id WHERE mt.monitor_id = ?", [monitor.id]); + return {...monitor,tags: tags} + })) + } + publicGroupList.push(monitorGroup); } diff --git a/src/pages/StatusPage.vue b/src/pages/StatusPage.vue index 87634f35..4ee810c7 100644 --- a/src/pages/StatusPage.vue +++ b/src/pages/StatusPage.vue @@ -77,6 +77,16 @@ <font-awesome-icon icon="save" /> {{ $t("Switch to Dark Theme") }} </button> + + <button v-if="tagsVisible == 'hidden'" class="btn btn-secondary me-2" @click="changeTagsVisibilty('visible')"> + <font-awesome-icon icon="eye" /> + {{ $t("Show Tags") }} + </button> + + <button v-if="tagsVisible == 'visible'" class="btn btn-secondary me-2" @click="changeTagsVisibilty('hidden')"> + <font-awesome-icon icon="eye-slash" /> + {{ $t("Hide Tags") }} + </button> </div> </div> @@ -292,6 +302,10 @@ export default { return this.config.statusPageTheme; }, + tagsVisible() { + return this.config.statusPageTags + }, + logoClass() { if (this.editMode) { return { @@ -472,6 +486,23 @@ export default { changeTheme(name) { this.config.statusPageTheme = name; }, + changeTagsVisibilty(newState) { + this.config.statusPageTags = newState; + + // On load, if the status page will not include tags if it's not enabled for security reasons + // Which means if we enable tags, it won't show in the UI until saved + // So we have this to enhance UX and load in the tags from the authenticated source instantly + this.$root.publicGroupList = this.$root.publicGroupList.map((group)=>{ + return {...group, + monitorList: group.monitorList.map((monitor)=> { + // We only include the tags if visible so we can reuse the logic to hide the tags on disable + return {...monitor, + tags: newState==="visible" ? this.$root.monitorList[monitor.id].tags : [] + } + }) + } + }); + }, /** * Crop Success From 74688e69aa6313c14a87bab53a5712f900bd0b20 Mon Sep 17 00:00:00 2001 From: Jasper Miller-Waugh <contact@jmw.nz> Date: Sat, 30 Oct 2021 00:58:46 +1300 Subject: [PATCH 06/25] Remove debug statement in server/routers/api-router.js Co-authored-by: Adam Stachowicz <saibamenppl@gmail.com> --- server/routers/api-router.js | 1 - 1 file changed, 1 deletion(-) diff --git a/server/routers/api-router.js b/server/routers/api-router.js index b58c4a00..a5d12450 100644 --- a/server/routers/api-router.js +++ b/server/routers/api-router.js @@ -147,7 +147,6 @@ router.get("/api/status-page/monitor-list", cache("5 minutes"), async (_request, let list = await R.find("group", " public = 1 ORDER BY weight "); for (let groupBean of list) { let monitorGroup = await groupBean.toPublicJSON() - console.log("\n\nsettings", await getSettings("statusPage")) if ((await getSettings("statusPage")).statusPageTags=="visible") { monitorGroup.monitorList = await Promise.all(monitorGroup.monitorList.map( async (monitor)=>{ // Includes tags as an array in response, allows for tags to be displayed on public status page From 8ec858fd1424c06ac1127f87b8dfca486a65e14b Mon Sep 17 00:00:00 2001 From: Minvinea <29579830+Minvinea@users.noreply.github.com> Date: Sun, 31 Oct 2021 21:18:36 +0100 Subject: [PATCH 07/25] Add missing translation Line 282 to 306 --- src/languages/fr-FR.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/languages/fr-FR.js b/src/languages/fr-FR.js index 062435d7..176a6150 100644 --- a/src/languages/fr-FR.js +++ b/src/languages/fr-FR.js @@ -279,4 +279,29 @@ export default { promosmsTypeSpeed: "SMS SPEED - La plus haute des priorités dans le système. Très rapide et fiable mais cher (environ le double du prix d'un SMS FULL).", promosmsPhoneNumber: "Numéro de téléphone (Poiur les déstinataires Polonais, vous pouvez enlever les codes interna.)", promosmsSMSSender: "SMS Expéditeur : Nom pré-enregistré ou l'un de base: InfoSMS, SMS Info, MaxSMS, INFO, SMS", + "Primary Base URL": "Primary Base URL", + emailCustomSubject: "Sujet personalisé", + clicksendsms: "ClickSend SMS", + checkPrice: "Vérification {0} tarifs:", + apiCredentials: "Crédentials de l'API", + octopushLegacyHint: "Vous utilisez l'ancienne version d'Octopush (2011-2020) ou la nouvelle version ?", + "Feishu WebHookUrl": "Feishu WebHookURL", + matrixHomeserverURL: "L'URL du serveur (avec http(s):// et le port de manière facultatif)", + "Internal Room Id": "ID de la salle interne", + matrixDesc1: "Vous pouvez trouvez l'ID de salle interne en regardant dans la section avancée des paramètres dans le client Matrix. C'est sensé ressembler à: !QMdRCpUIfLwsfjxye6:home.server.", + matrixDesc2: "Il est fortement recommandé de créer un nouvel utilisateur et de ne pas utiliser le jeton d'accès de votre propre utilisateur Matrix, car il vous donnera un accès complet à votre compte et à toutes les salles que vous avez rejointes. Au lieu de cela, créez un nouvel utilisateur et invitez-le uniquement dans la salle dans laquelle vous souhaitez recevoir la notification. Vous pouvez obtenir le jeton d'accès en exécutant {0}", + Method: "Méthode", + Body: "Le corps", + Headers: "En-têtes", + PushUrl: "Push URL", + HeadersInvalidFormat: "L'en-têtes de la requête n'est pas dans un format JSON valide: ", + BodyInvalidFormat: "Le corps de la requête n'est pas dans un format JSON valide: ", + "Monitor History": "Historique de la sonde", + clearDataOlderThan: "Garder l'historique des données de la sonde durant {0} jours.", + PasswordsDoNotMatch: "Les mots de passe ne correspondent pas.", + records: "Enregistrements", + "One record": "Un enregistrement", + steamApiKeyDescription: "Pour surveiller un serveur Steam, vous avez besoin d'une clé Steam Web-API. Vous pouvez enregistrer votre clé ici: ", + "Current User": "Utilisateur actuel", + recent: "Récent", }; From 4004926e643e63a2a8d6915cef6af6992225aa9f Mon Sep 17 00:00:00 2001 From: Jasper Miller-Waugh <contact@jmw.nz> Date: Mon, 1 Nov 2021 12:52:21 +1300 Subject: [PATCH 08/25] Small formatting changes from code-review Co-authored-by: deef <deef551@gmail.com> --- src/pages/StatusPage.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pages/StatusPage.vue b/src/pages/StatusPage.vue index 4ee810c7..06be1616 100644 --- a/src/pages/StatusPage.vue +++ b/src/pages/StatusPage.vue @@ -493,10 +493,12 @@ export default { // Which means if we enable tags, it won't show in the UI until saved // So we have this to enhance UX and load in the tags from the authenticated source instantly this.$root.publicGroupList = this.$root.publicGroupList.map((group)=>{ - return {...group, + return { + ...group, monitorList: group.monitorList.map((monitor)=> { // We only include the tags if visible so we can reuse the logic to hide the tags on disable - return {...monitor, + return { + ...monitor, tags: newState==="visible" ? this.$root.monitorList[monitor.id].tags : [] } }) From 12ef9f39c51fac03f5a18ba4182a9a81328c662f Mon Sep 17 00:00:00 2001 From: Jasper Miller-Waugh <contact@jmw.nz> Date: Mon, 1 Nov 2021 13:23:46 +1300 Subject: [PATCH 09/25] Merged buttons, cleaned up SS tag retrieval and made tagsVisible a bool. Also to note: due to the transition of tagsVisible this breaks compatibility with the previous commits, delete the tagsVisible setting in the database to fix. --- server/routers/api-router.js | 19 +++++++++++++------ src/pages/StatusPage.vue | 19 ++++++++++--------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/server/routers/api-router.js b/server/routers/api-router.js index a5d12450..30f6a828 100644 --- a/server/routers/api-router.js +++ b/server/routers/api-router.js @@ -102,7 +102,7 @@ router.get("/api/status-page/config", async (_request, response) => { } if (! config.statusPageTags) { - config.statusPageTags = "hidden"; + config.statusPageTags = false; } if (! config.title) { @@ -144,15 +144,22 @@ router.get("/api/status-page/monitor-list", cache("5 minutes"), async (_request, try { await checkPublished(); const publicGroupList = []; - let list = await R.find("group", " public = 1 ORDER BY weight "); + const tagsVisible = (await getSettings("statusPage")).statusPageTags; + const list = await R.find("group", " public = 1 ORDER BY weight "); for (let groupBean of list) { - let monitorGroup = await groupBean.toPublicJSON() - if ((await getSettings("statusPage")).statusPageTags=="visible") { + let monitorGroup = await groupBean.toPublicJSON(); + if (tagsVisible) { monitorGroup.monitorList = await Promise.all(monitorGroup.monitorList.map( async (monitor)=>{ // Includes tags as an array in response, allows for tags to be displayed on public status page - let tags = await R.getAll("SELECT mt.monitor_id,mt.value, tag.name, tag.color FROM monitor_tag mt JOIN tag ON mt.tag_id = tag.id WHERE mt.monitor_id = ?", [monitor.id]); + const tags = await R.getAll( + `SELECT monitor_tag.monitor_id, monitor_tag.value, tag.name, tag.color + FROM monitor_tag + JOIN tag + ON monitor_tag.tag_id = tag.id + WHERE monitor_tag.monitor_id = ?`, [monitor.id] + ); return {...monitor,tags: tags} - })) + })); } publicGroupList.push(monitorGroup); diff --git a/src/pages/StatusPage.vue b/src/pages/StatusPage.vue index 06be1616..1320f093 100644 --- a/src/pages/StatusPage.vue +++ b/src/pages/StatusPage.vue @@ -78,14 +78,15 @@ {{ $t("Switch to Dark Theme") }} </button> - <button v-if="tagsVisible == 'hidden'" class="btn btn-secondary me-2" @click="changeTagsVisibilty('visible')"> - <font-awesome-icon icon="eye" /> - {{ $t("Show Tags") }} - </button> - - <button v-if="tagsVisible == 'visible'" class="btn btn-secondary me-2" @click="changeTagsVisibilty('hidden')"> - <font-awesome-icon icon="eye-slash" /> - {{ $t("Hide Tags") }} + <button class="btn btn-secondary me-2" @click="changeTagsVisibilty(!tagsVisible)"> + <template v-if="tagsVisible"> + <font-awesome-icon icon="eye-slash" /> + {{ $t("Hide Tags") }} + </template> + <template v-else> + <font-awesome-icon icon="eye" /> + {{ $t("Show Tags") }} + </template> </button> </div> </div> @@ -499,7 +500,7 @@ export default { // We only include the tags if visible so we can reuse the logic to hide the tags on disable return { ...monitor, - tags: newState==="visible" ? this.$root.monitorList[monitor.id].tags : [] + tags: newState ? this.$root.monitorList[monitor.id].tags : [] } }) } From f3651a1219a12b28e66964fb4fcd90eb742d3cad Mon Sep 17 00:00:00 2001 From: Jagger <634750802@qq.com> Date: Mon, 1 Nov 2021 13:31:31 +0800 Subject: [PATCH 10/25] Add a status prefix for feishu notification --- server/notification-providers/feishu.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/notification-providers/feishu.js b/server/notification-providers/feishu.js index a3e34030..05fc9c18 100644 --- a/server/notification-providers/feishu.js +++ b/server/notification-providers/feishu.js @@ -27,7 +27,7 @@ class Feishu extends NotificationProvider { content: { post: { zh_cn: { - title: "UptimeKuma Alert: " + monitorJSON["name"], + title: "UptimeKuma Alert: [Down] " + monitorJSON["name"], content: [ [ { @@ -54,7 +54,7 @@ class Feishu extends NotificationProvider { content: { post: { zh_cn: { - title: "UptimeKuma Alert: " + monitorJSON["name"], + title: "UptimeKuma Alert: [Up] " + monitorJSON["name"], content: [ [ { From 191b81ee07ab919123427d6ef1998969350b5d8f Mon Sep 17 00:00:00 2001 From: Jasper Miller-Waugh <contact@jmw.nz> Date: Mon, 1 Nov 2021 22:14:41 +1300 Subject: [PATCH 11/25] Fix grammer in comment Co-authored-by: Nelson Chan <chakflying@hotmail.com> --- src/pages/StatusPage.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/StatusPage.vue b/src/pages/StatusPage.vue index 1320f093..70367cc9 100644 --- a/src/pages/StatusPage.vue +++ b/src/pages/StatusPage.vue @@ -490,7 +490,7 @@ export default { changeTagsVisibilty(newState) { this.config.statusPageTags = newState; - // On load, if the status page will not include tags if it's not enabled for security reasons + // On load, the status page will not include tags if it's not enabled for security reasons // Which means if we enable tags, it won't show in the UI until saved // So we have this to enhance UX and load in the tags from the authenticated source instantly this.$root.publicGroupList = this.$root.publicGroupList.map((group)=>{ From c094dc0c5bd36c691869fcdc907ab87d52bf8ea9 Mon Sep 17 00:00:00 2001 From: Louis Lam <louislam@users.noreply.github.com> Date: Tue, 2 Nov 2021 21:48:46 +0800 Subject: [PATCH 12/25] speed up redirect by using 302 redirect instead of vue redirect --- server/server.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server/server.js b/server/server.js index 0af003d1..d1fd7ff2 100644 --- a/server/server.js +++ b/server/server.js @@ -186,6 +186,15 @@ exports.entryPage = "dashboard"; // Normal Router here // *************************** + // Entry Page + app.get("/", async (_request, response) => { + if (exports.entryPage === "statusPage") { + response.redirect("/status"); + } else { + response.redirect("/dashboard"); + } + }); + // Robots.txt app.get("/robots.txt", async (_request, response) => { let txt = "User-agent: *\nDisallow:"; From e496c3b3be4a2d93332766d687294b41da9f4549 Mon Sep 17 00:00:00 2001 From: Louis Lam <louislam@users.noreply.github.com> Date: Tue, 2 Nov 2021 22:03:02 +0800 Subject: [PATCH 13/25] update healthcheck.js --- extra/healthcheck.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/healthcheck.js b/extra/healthcheck.js index 8044f654..c6e8a349 100644 --- a/extra/healthcheck.js +++ b/extra/healthcheck.js @@ -35,7 +35,7 @@ let options = { let request = client.request(options, (res) => { console.log(`Health Check OK [Res Code: ${res.statusCode}]`); - if (res.statusCode === 200) { + if (res.statusCode === 302) { process.exit(0); } else { process.exit(1); From e5d6410cafc1afbff3991f37a1ffb69ad45f51f4 Mon Sep 17 00:00:00 2001 From: Jasper Miller-Waugh <contact@jmw.nz> Date: Wed, 3 Nov 2021 11:46:53 +1300 Subject: [PATCH 14/25] Apply formatting suggestions from code review Co-authored-by: Adam Stachowicz <saibamenppl@gmail.com> --- server/routers/api-router.js | 4 ++-- src/pages/StatusPage.vue | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/routers/api-router.js b/server/routers/api-router.js index 30f6a828..79e82837 100644 --- a/server/routers/api-router.js +++ b/server/routers/api-router.js @@ -149,7 +149,7 @@ router.get("/api/status-page/monitor-list", cache("5 minutes"), async (_request, for (let groupBean of list) { let monitorGroup = await groupBean.toPublicJSON(); if (tagsVisible) { - monitorGroup.monitorList = await Promise.all(monitorGroup.monitorList.map( async (monitor)=>{ + monitorGroup.monitorList = await Promise.all(monitorGroup.monitorList.map(async (monitor) => { // Includes tags as an array in response, allows for tags to be displayed on public status page const tags = await R.getAll( `SELECT monitor_tag.monitor_id, monitor_tag.value, tag.name, tag.color @@ -158,7 +158,7 @@ router.get("/api/status-page/monitor-list", cache("5 minutes"), async (_request, ON monitor_tag.tag_id = tag.id WHERE monitor_tag.monitor_id = ?`, [monitor.id] ); - return {...monitor,tags: tags} + return {...monitor, tags: tags} })); } diff --git a/src/pages/StatusPage.vue b/src/pages/StatusPage.vue index 70367cc9..ce0f94b5 100644 --- a/src/pages/StatusPage.vue +++ b/src/pages/StatusPage.vue @@ -493,10 +493,10 @@ export default { // On load, the status page will not include tags if it's not enabled for security reasons // Which means if we enable tags, it won't show in the UI until saved // So we have this to enhance UX and load in the tags from the authenticated source instantly - this.$root.publicGroupList = this.$root.publicGroupList.map((group)=>{ + this.$root.publicGroupList = this.$root.publicGroupList.map((group) => { return { ...group, - monitorList: group.monitorList.map((monitor)=> { + monitorList: group.monitorList.map((monitor) => { // We only include the tags if visible so we can reuse the logic to hide the tags on disable return { ...monitor, From dee131c25d64d36ad0b7de7cbb46bb61a86c710f Mon Sep 17 00:00:00 2001 From: Louis Lam <louislam@users.noreply.github.com> Date: Wed, 3 Nov 2021 13:02:44 +0800 Subject: [PATCH 15/25] fix table hover color not working after updated bootstrap to 5.1.3 --- src/assets/app.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assets/app.scss b/src/assets/app.scss index e1a5d052..89639fd9 100644 --- a/src/assets/app.scss +++ b/src/assets/app.scss @@ -189,7 +189,7 @@ textarea.form-control { opacity: 1; } - .table-hover > tbody > tr:hover { + .table-hover > tbody > tr:hover > * { --bs-table-accent-bg: #070a10; color: $dark-font-color; } From 1ba203470183ee2f741898fa4971b408432d2f2d Mon Sep 17 00:00:00 2001 From: Louis Lam <louislam@users.noreply.github.com> Date: Wed, 3 Nov 2021 13:03:36 +0800 Subject: [PATCH 16/25] freeze bootstrap to 5.1.3 to prevent breaking changes --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 64be83ee..d34531b3 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "args-parser": "~1.3.0", "axios": "~0.21.4", "bcryptjs": "~2.4.3", - "bootstrap": "~5.1.3", + "bootstrap": "5.1.3", "bree": "~6.3.1", "chardet": "^1.3.0", "chart.js": "~3.6.0", From ee2c54cfd1f619541aba35f2e3c2fae60d3fb61f Mon Sep 17 00:00:00 2001 From: MrEddX <66828538+MrEddX@users.noreply.github.com> Date: Wed, 3 Nov 2021 11:49:22 +0200 Subject: [PATCH 17/25] Update bg-BG.js - Added New Fields - Fixed Existing Fields --- src/languages/bg-BG.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/languages/bg-BG.js b/src/languages/bg-BG.js index 0d5af783..f1d9b078 100644 --- a/src/languages/bg-BG.js +++ b/src/languages/bg-BG.js @@ -77,7 +77,7 @@ export default { "Accepted Status Codes": "Допустими статус кодове", Save: "Запази", Notifications: "Известявания", - "Not available, please setup.": "Не е налично. Моля, настройте.", + "Not available, please setup.": "Не са налични. Моля, настройте.", "Setup Notification": "Настройки за известявания", Light: "Светла", Dark: "Тъмна", @@ -141,7 +141,7 @@ export default { Overwrite: "Презапиши", Options: "Опции", "Keep both": "Запази двете", - "Verify Token": "Проверка на токен код", + "Verify Token": "Провери токен код", "Setup 2FA": "Настройка 2FA", "Enable 2FA": "Включи 2FA", "Disable 2FA": "Изключи 2FA", @@ -298,8 +298,13 @@ export default { HeadersInvalidFormat: "Заявените хедъри не са валидни JSON: ", BodyInvalidFormat: "Заявеното съобщение не е валиден JSON: ", "Monitor History": "История на мониторите", - clearDataOlderThan: "Ще се съхранява за {0} дни.", + clearDataOlderThan: "Ще се съхранява {0} дни.", records: "записа", "One record": "Един запис", steamApiKeyDescription: "За да мониторирате Steam Gameserver се нуждаете от Steam Web-API ключ. Може да регистрирате Вашия API ключ тук: ", + clicksendsms: "ClickSend SMS", + apiCredentials: "API удостоверяване", + PasswordsDoNotMatch: "Паролите не съвпадат.", + "Current User": "Текущ потребител", + recent: "Скорошни", }; From 57389fab2c3588b671cd54d63de95c14d7ec663f Mon Sep 17 00:00:00 2001 From: Nelson Chan <chakflying@hotmail.com> Date: Wed, 3 Nov 2021 19:13:11 +0800 Subject: [PATCH 18/25] Update PULL_REQUEST_TEMPLATE.md --- .github/PULL_REQUEST_TEMPLATE.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index fa0aa883..c286db02 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -24,3 +24,5 @@ Please delete options that are not relevant. - [ ] My code needed automated testing. I have added them (this is optional task) ## Screenshots (if any) + +Please do not use any external image service. Instead, just paste in the image here and it will be uploaded automatically. From bc5f61b3ec4d29ed7ac99f48eb655be7fd364976 Mon Sep 17 00:00:00 2001 From: Nelson Chan <chakflying@hotmail.com> Date: Thu, 4 Nov 2021 10:21:57 +0800 Subject: [PATCH 19/25] Chore: Add drag and drop Co-authored-by: Adam Stachowicz <saibamenppl@gmail.com> --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index c286db02..3be22931 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -25,4 +25,4 @@ Please delete options that are not relevant. ## Screenshots (if any) -Please do not use any external image service. Instead, just paste in the image here and it will be uploaded automatically. +Please do not use any external image service. Instead, just paste in or drag and drop the image here and it will be uploaded automatically. From 210566c7af9561e2b63571c0649f0352c9a054e1 Mon Sep 17 00:00:00 2001 From: Louis Lam <louislam@users.noreply.github.com> Date: Fri, 5 Nov 2021 11:34:50 +0800 Subject: [PATCH 20/25] remove prefix for issue title, so users need to input the title --- .github/ISSUE_TEMPLATE/ask-for-help.yaml | 2 +- .github/ISSUE_TEMPLATE/bug_report.yaml | 2 +- .github/ISSUE_TEMPLATE/feature_request.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/ask-for-help.yaml b/.github/ISSUE_TEMPLATE/ask-for-help.yaml index 76a78e5c..3442e8b7 100644 --- a/.github/ISSUE_TEMPLATE/ask-for-help.yaml +++ b/.github/ISSUE_TEMPLATE/ask-for-help.yaml @@ -1,6 +1,6 @@ name: "❓ Ask for help" description: "Submit any question related to Uptime Kuma" -title: "[Help] " +#title: "[Help] " labels: [help] body: - type: checkboxes diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index 055c3a62..2dca1556 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -1,6 +1,6 @@ name: "🐛 Bug Report" description: "Submit a bug report to help us improve" -title: "[Bug] " +#title: "[Bug] " labels: [bug] body: - type: checkboxes diff --git a/.github/ISSUE_TEMPLATE/feature_request.yaml b/.github/ISSUE_TEMPLATE/feature_request.yaml index 6464e276..f0a92ede 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yaml +++ b/.github/ISSUE_TEMPLATE/feature_request.yaml @@ -1,6 +1,6 @@ name: 🚀 Feature Request description: "Submit a proposal for a new feature" -title: "[Feature] " +#title: "[Feature] " labels: [enhancement] body: - type: checkboxes From 8f44b9f6181dfd80015012cceff227fb1e521c18 Mon Sep 17 00:00:00 2001 From: Andreas Brett <github@abrett.de> Date: Fri, 5 Nov 2021 09:54:10 +0100 Subject: [PATCH 21/25] 24h tooltip on status page --- src/components/Uptime.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Uptime.vue b/src/components/Uptime.vue index a4bf22f6..2717672c 100644 --- a/src/components/Uptime.vue +++ b/src/components/Uptime.vue @@ -1,5 +1,5 @@ <template> - <span :class="className">{{ uptime }}</span> + <span :class="className" :title="24 + $t('-hour')">{{ uptime }}</span> </template> <script> From bc69a331ee3f7be8ec637d47c5902fa5d496e458 Mon Sep 17 00:00:00 2001 From: Louis Lam <louislam@users.noreply.github.com> Date: Sun, 7 Nov 2021 13:50:22 +0800 Subject: [PATCH 22/25] eslint --- src/languages/fr-FR.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/languages/fr-FR.js b/src/languages/fr-FR.js index 176a6150..92083a38 100644 --- a/src/languages/fr-FR.js +++ b/src/languages/fr-FR.js @@ -280,17 +280,17 @@ export default { promosmsPhoneNumber: "Numéro de téléphone (Poiur les déstinataires Polonais, vous pouvez enlever les codes interna.)", promosmsSMSSender: "SMS Expéditeur : Nom pré-enregistré ou l'un de base: InfoSMS, SMS Info, MaxSMS, INFO, SMS", "Primary Base URL": "Primary Base URL", - emailCustomSubject: "Sujet personalisé", - clicksendsms: "ClickSend SMS", - checkPrice: "Vérification {0} tarifs:", - apiCredentials: "Crédentials de l'API", - octopushLegacyHint: "Vous utilisez l'ancienne version d'Octopush (2011-2020) ou la nouvelle version ?", + emailCustomSubject: "Sujet personalisé", + clicksendsms: "ClickSend SMS", + checkPrice: "Vérification {0} tarifs:", + apiCredentials: "Crédentials de l'API", + octopushLegacyHint: "Vous utilisez l'ancienne version d'Octopush (2011-2020) ou la nouvelle version ?", "Feishu WebHookUrl": "Feishu WebHookURL", matrixHomeserverURL: "L'URL du serveur (avec http(s):// et le port de manière facultatif)", "Internal Room Id": "ID de la salle interne", matrixDesc1: "Vous pouvez trouvez l'ID de salle interne en regardant dans la section avancée des paramètres dans le client Matrix. C'est sensé ressembler à: !QMdRCpUIfLwsfjxye6:home.server.", - matrixDesc2: "Il est fortement recommandé de créer un nouvel utilisateur et de ne pas utiliser le jeton d'accès de votre propre utilisateur Matrix, car il vous donnera un accès complet à votre compte et à toutes les salles que vous avez rejointes. Au lieu de cela, créez un nouvel utilisateur et invitez-le uniquement dans la salle dans laquelle vous souhaitez recevoir la notification. Vous pouvez obtenir le jeton d'accès en exécutant {0}", - Method: "Méthode", + matrixDesc2: "Il est fortement recommandé de créer un nouvel utilisateur et de ne pas utiliser le jeton d'accès de votre propre utilisateur Matrix, car il vous donnera un accès complet à votre compte et à toutes les salles que vous avez rejointes. Au lieu de cela, créez un nouvel utilisateur et invitez-le uniquement dans la salle dans laquelle vous souhaitez recevoir la notification. Vous pouvez obtenir le jeton d'accès en exécutant {0}", + Method: "Méthode", Body: "Le corps", Headers: "En-têtes", PushUrl: "Push URL", @@ -299,9 +299,9 @@ export default { "Monitor History": "Historique de la sonde", clearDataOlderThan: "Garder l'historique des données de la sonde durant {0} jours.", PasswordsDoNotMatch: "Les mots de passe ne correspondent pas.", - records: "Enregistrements", + records: "Enregistrements", "One record": "Un enregistrement", steamApiKeyDescription: "Pour surveiller un serveur Steam, vous avez besoin d'une clé Steam Web-API. Vous pouvez enregistrer votre clé ici: ", - "Current User": "Utilisateur actuel", + "Current User": "Utilisateur actuel", recent: "Récent", }; From c92153c97ed151c9759ebe63ef22d2821e5d115e Mon Sep 17 00:00:00 2001 From: Louis Lam <louislam@users.noreply.github.com> Date: Sun, 7 Nov 2021 21:00:47 +0800 Subject: [PATCH 23/25] add more debug msg --- server/model/monitor.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index fc329231..c6e09f53 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -141,6 +141,7 @@ class Monitor extends BeanModel { // Do not do any queries/high loading things before the "bean.ping" let startTime = dayjs().valueOf(); + debug(`[${this.name}] Prepare Options for axios`); const options = { url: this.url, method: (this.method || "get").toLowerCase(), @@ -160,6 +161,8 @@ class Monitor extends BeanModel { return checkStatusCode(status, this.getAcceptedStatuscodes()); }, }; + + debug(`[${this.name}] Axios Request`); let res = await axios.request(options); bean.msg = `${res.status} - ${res.statusText}`; bean.ping = dayjs().valueOf() - startTime; @@ -167,12 +170,13 @@ class Monitor extends BeanModel { // Check certificate if https is used let certInfoStartTime = dayjs().valueOf(); if (this.getUrl()?.protocol === "https:") { + debug(`[${this.name}] Check cert`); try { let tlsInfoObject = checkCertificate(res); tlsInfo = await this.updateTlsInfo(tlsInfoObject); if (!this.getIgnoreTls()) { - debug("call sendCertNotification"); + debug(`[${this.name}] call sendCertNotification`); await this.sendCertNotification(tlsInfoObject); } @@ -351,15 +355,19 @@ class Monitor extends BeanModel { let beatInterval = this.interval; + debug(`[${this.name}] Check isImportant`); let isImportant = Monitor.isImportantBeat(isFirstBeat, previousBeat?.status, bean.status); // Mark as important if status changed, ignore pending pings, // Don't notify if disrupted changes to up if (isImportant) { bean.important = true; + + debug(`[${this.name}] sendNotification`); await Monitor.sendNotification(isFirstBeat, this, bean); // Clear Status Page Cache + debug(`[${this.name}] Check isImportant`); apicache.clear(); } else { @@ -377,10 +385,14 @@ class Monitor extends BeanModel { console.warn(`Monitor #${this.id} '${this.name}': Failing: ${bean.msg} | Interval: ${beatInterval} seconds | Type: ${this.type}`); } + debug(`[${this.name}] Send to socket`); io.to(this.user_id).emit("heartbeat", bean.toJSON()); Monitor.sendStats(io, this.id, this.user_id); + debug(`[${this.name}] Store`); await R.store(bean); + + debug(`[${this.name}] prometheus.update`); prometheus.update(bean, tlsInfo); previousBeat = bean; @@ -394,7 +406,10 @@ class Monitor extends BeanModel { } } + debug(`[${this.name}] SetTimeout for next check.`); this.heartbeatInterval = setTimeout(safeBeat, beatInterval * 1000); + } else { + console.log(`[${this.name}] isStop = true, no next check.`); } }; From 41a6d1b701e40c8aa2d3eae97dd56f7480c1109d Mon Sep 17 00:00:00 2001 From: Louis Lam <louislam@users.noreply.github.com> Date: Mon, 8 Nov 2021 15:39:17 +0800 Subject: [PATCH 24/25] Fix parseCertificateInfo possibly in dead loop --- server/model/monitor.js | 2 +- server/util-server.js | 17 +++++- test/backend.spec.js | 122 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 139 insertions(+), 2 deletions(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index c6e09f53..980e0ac6 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -367,7 +367,7 @@ class Monitor extends BeanModel { await Monitor.sendNotification(isFirstBeat, this, bean); // Clear Status Page Cache - debug(`[${this.name}] Check isImportant`); + debug(`[${this.name}] apicache clear`); apicache.clear(); } else { diff --git a/server/util-server.js b/server/util-server.js index 5d65f46d..bfb4a9cb 100644 --- a/server/util-server.js +++ b/server/util-server.js @@ -201,8 +201,13 @@ const getDaysRemaining = (validFrom, validTo) => { // param: info - the chain obtained from getPeerCertificate() const parseCertificateInfo = function (info) { let link = info; + let i = 0; + + const existingList = {}; while (link) { + debug(`[${i}] ${link.fingerprint}`); + if (!link.valid_from || !link.valid_to) { break; } @@ -210,15 +215,24 @@ const parseCertificateInfo = function (info) { link.validFor = link.subjectaltname?.replace(/DNS:|IP Address:/g, "").split(", "); link.daysRemaining = getDaysRemaining(new Date(), link.validTo); + existingList[link.fingerprint] = true; + // Move up the chain until loop is encountered if (link.issuerCertificate == null) { break; - } else if (link.fingerprint == link.issuerCertificate.fingerprint) { + } else if (link.issuerCertificate.fingerprint in existingList) { + debug(`[Last] ${link.issuerCertificate.fingerprint}`); link.issuerCertificate = null; break; } else { link = link.issuerCertificate; } + + // Should be no use, but just in case. + if (i > 500) { + throw new Error("Dead loop occurred in parseCertificateInfo"); + } + i++; } return info; @@ -228,6 +242,7 @@ exports.checkCertificate = function (res) { const info = res.request.res.socket.getPeerCertificate(true); const valid = res.request.res.socket.authorized || false; + console.log("Parsing Certificate Info"); const parsedInfo = parseCertificateInfo(info); return { diff --git a/test/backend.spec.js b/test/backend.spec.js index bd73d202..bbfc6897 100644 --- a/test/backend.spec.js +++ b/test/backend.spec.js @@ -1,4 +1,125 @@ const { genSecret, sleep } = require("../src/util"); +const utilServerRewire = require("../server/util-server"); + +describe("Test parseCertificateInfo", () => { + it("should handle undefined", async () => { + const parseCertificateInfo = utilServerRewire.__get__("parseCertificateInfo"); + const info = parseCertificateInfo(undefined); + expect(info).toEqual(undefined); + }, 5000); + + it("should handle normal cert chain", async () => { + const parseCertificateInfo = utilServerRewire.__get__("parseCertificateInfo"); + + const chain1 = { + fingerprint: "CF:2C:F3:6A:FE:6B:10:EC:44:77:C8:95:BB:96:2E:06:1F:0E:15:DA", + valid_from: "Oct 22 12:00:00 2013 GMT", + valid_to: "Oct 22 12:00:00 2028 GMT", + subjectaltname: "DNS:www.example.org, DNS:example.com, DNS:example.edu, DNS:example.net, DNS:example.org, DNS:www.example.com, DNS:www.example.edu, DNS:www.example.net", + }; + + const chain2 = { + fingerprint: "A0:31:C4:67:82:E6:E6:C6:62:C2:C8:7C:76:DA:9A:A6:2C:CA:BD:8E", + valid_from: "Oct 22 12:00:00 2013 GMT", + valid_to: "Oct 22 12:00:00 2028 GMT", + subjectaltname: "DNS:www.example.org, DNS:example.com, DNS:example.edu, DNS:example.net, DNS:example.org, DNS:www.example.com, DNS:www.example.edu, DNS:www.example.net", + }; + + const chain3 = { + fingerprint: "5F:B7:EE:06:33:E2:59:DB:AD:0C:4C:9A:E6:D3:8F:1A:61:C7:DC:25", + valid_from: "Oct 22 12:00:00 2013 GMT", + valid_to: "Oct 22 12:00:00 2028 GMT", + subjectaltname: "DNS:www.example.org, DNS:example.com, DNS:example.edu, DNS:example.net, DNS:example.org, DNS:www.example.com, DNS:www.example.edu, DNS:www.example.net", + }; + + chain1.issuerCertificate = chain2; + chain2.issuerCertificate = chain3; + chain3.issuerCertificate = chain3; + + const info = parseCertificateInfo(chain1); + expect(chain1).toEqual(info); + }, 5000); + + it("should handle cert chain with strange circle", async () => { + const parseCertificateInfo = utilServerRewire.__get__("parseCertificateInfo"); + + const chain1 = { + fingerprint: "CF:2C:F3:6A:FE:6B:10:EC:44:77:C8:95:BB:96:2E:06:1F:0E:15:DA", + valid_from: "Oct 22 12:00:00 2013 GMT", + valid_to: "Oct 22 12:00:00 2028 GMT", + subjectaltname: "DNS:www.example.org, DNS:example.com, DNS:example.edu, DNS:example.net, DNS:example.org, DNS:www.example.com, DNS:www.example.edu, DNS:www.example.net", + }; + + const chain2 = { + fingerprint: "A0:31:C4:67:82:E6:E6:C6:62:C2:C8:7C:76:DA:9A:A6:2C:CA:BD:8E", + valid_from: "Oct 22 12:00:00 2013 GMT", + valid_to: "Oct 22 12:00:00 2028 GMT", + subjectaltname: "DNS:www.example.org, DNS:example.com, DNS:example.edu, DNS:example.net, DNS:example.org, DNS:www.example.com, DNS:www.example.edu, DNS:www.example.net", + }; + + const chain3 = { + fingerprint: "5F:B7:EE:06:33:E2:59:DB:AD:0C:4C:9A:E6:D3:8F:1A:61:C7:DC:25", + valid_from: "Oct 22 12:00:00 2013 GMT", + valid_to: "Oct 22 12:00:00 2028 GMT", + subjectaltname: "DNS:www.example.org, DNS:example.com, DNS:example.edu, DNS:example.net, DNS:example.org, DNS:www.example.com, DNS:www.example.edu, DNS:www.example.net", + }; + + const chain4 = { + fingerprint: "haha", + valid_from: "Oct 22 12:00:00 2013 GMT", + valid_to: "Oct 22 12:00:00 2028 GMT", + subjectaltname: "DNS:www.example.org, DNS:example.com, DNS:example.edu, DNS:example.net, DNS:example.org, DNS:www.example.com, DNS:www.example.edu, DNS:www.example.net", + }; + + chain1.issuerCertificate = chain2; + chain2.issuerCertificate = chain3; + chain3.issuerCertificate = chain4; + chain4.issuerCertificate = chain2; + + const info = parseCertificateInfo(chain1); + expect(chain1).toEqual(info); + }, 5000); + + it("should handle cert chain with last undefined (should be happen in real, but just in case)", async () => { + const parseCertificateInfo = utilServerRewire.__get__("parseCertificateInfo"); + + const chain1 = { + fingerprint: "CF:2C:F3:6A:FE:6B:10:EC:44:77:C8:95:BB:96:2E:06:1F:0E:15:DA", + valid_from: "Oct 22 12:00:00 2013 GMT", + valid_to: "Oct 22 12:00:00 2028 GMT", + subjectaltname: "DNS:www.example.org, DNS:example.com, DNS:example.edu, DNS:example.net, DNS:example.org, DNS:www.example.com, DNS:www.example.edu, DNS:www.example.net", + }; + + const chain2 = { + fingerprint: "A0:31:C4:67:82:E6:E6:C6:62:C2:C8:7C:76:DA:9A:A6:2C:CA:BD:8E", + valid_from: "Oct 22 12:00:00 2013 GMT", + valid_to: "Oct 22 12:00:00 2028 GMT", + subjectaltname: "DNS:www.example.org, DNS:example.com, DNS:example.edu, DNS:example.net, DNS:example.org, DNS:www.example.com, DNS:www.example.edu, DNS:www.example.net", + }; + + const chain3 = { + fingerprint: "5F:B7:EE:06:33:E2:59:DB:AD:0C:4C:9A:E6:D3:8F:1A:61:C7:DC:25", + valid_from: "Oct 22 12:00:00 2013 GMT", + valid_to: "Oct 22 12:00:00 2028 GMT", + subjectaltname: "DNS:www.example.org, DNS:example.com, DNS:example.edu, DNS:example.net, DNS:example.org, DNS:www.example.com, DNS:www.example.edu, DNS:www.example.net", + }; + + const chain4 = { + fingerprint: "haha", + valid_from: "Oct 22 12:00:00 2013 GMT", + valid_to: "Oct 22 12:00:00 2028 GMT", + subjectaltname: "DNS:www.example.org, DNS:example.com, DNS:example.edu, DNS:example.net, DNS:example.org, DNS:www.example.com, DNS:www.example.edu, DNS:www.example.net", + }; + + chain1.issuerCertificate = chain2; + chain2.issuerCertificate = chain3; + chain3.issuerCertificate = chain4; + chain4.issuerCertificate = undefined; + + const info = parseCertificateInfo(chain1); + expect(chain1).toEqual(info); + }, 5000); +}); describe("Test genSecret", () => { @@ -42,3 +163,4 @@ describe("Test reset-password", () => { await require("../extra/reset-password").main(); }, 120000); }); + From 0275d7a42b30760e906f59e59f8fb52feb06d416 Mon Sep 17 00:00:00 2001 From: Louis Lam <louislam@users.noreply.github.com> Date: Mon, 8 Nov 2021 15:51:32 +0800 Subject: [PATCH 25/25] minor --- server/util-server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/util-server.js b/server/util-server.js index bfb4a9cb..68f59f67 100644 --- a/server/util-server.js +++ b/server/util-server.js @@ -242,7 +242,7 @@ exports.checkCertificate = function (res) { const info = res.request.res.socket.getPeerCertificate(true); const valid = res.request.res.socket.authorized || false; - console.log("Parsing Certificate Info"); + debug("Parsing Certificate Info"); const parsedInfo = parseCertificateInfo(info); return {