From a1882b67c41fe9901a0cd8059b5cc78a5beadec0 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 26 Nov 2024 09:28:28 +0100 Subject: Adding upstream version 2.0.0~beta.0+dfsg. Signed-off-by: Daniel Baumann --- .dockerignore | 55 + .editorconfig | 24 + .eslintrc.js | 168 + .github/FUNDING.yml | 12 + .github/ISSUE_TEMPLATE/ask-for-help.yaml | 75 + .github/ISSUE_TEMPLATE/bug_report.yaml | 100 + .github/ISSUE_TEMPLATE/feature_request.yaml | 66 + .github/ISSUE_TEMPLATE/security.md | 17 + .github/PULL_REQUEST_TEMPLATE.md | 33 + .github/config/exclude.txt | 1 + .github/workflows/auto-test.yml | 93 + .github/workflows/close-incorrect-issue.yml | 25 + .github/workflows/codeql-analysis.yml | 43 + .github/workflows/conflict_labeler.yml | 25 + .github/workflows/prevent-file-change.yml | 17 + .github/workflows/stale-bot.yml | 42 + .github/workflows/validate.yml | 43 + .gitignore | 26 + .npmrc | 1 + .stylelintrc | 16 + CNAME | 1 + CODE_OF_CONDUCT.md | 128 + CONTRIBUTING.md | 512 + LICENSE | 21 + README.md | 195 + SECURITY.md | 30 + compose.yaml | 9 + config/jest-backend.config.js | 5 + config/playwright.config.js | 66 + config/vite.config.js | 55 + db/knex_init_db.js | 565 + .../2023-08-16-0000-create-uptime.js | 41 + db/knex_migrations/2023-08-18-0301-heartbeat.js | 16 + .../2023-09-29-0000-heartbeat-retires.js | 15 + db/knex_migrations/2023-10-08-0000-mqtt-query.js | 16 + .../2023-10-11-1915-push-token-to-32.js | 14 + .../2023-10-16-0000-create-remote-browsers.js | 21 + .../2023-12-20-0000-alter-status-page.js | 12 + .../2023-12-21-0000-stat-ping-min-max.js | 24 + .../2023-12-22-0000-hourly-uptime.js | 26 + db/knex_migrations/2024-01-22-0000-stats-extras.js | 26 + db/knex_migrations/2024-04-26-0000-snmp-monitor.js | 16 + .../2024-08-24-000-add-cache-bust.js | 13 + db/knex_migrations/2024-08-24-0000-conditions.js | 12 + .../2024-10-1315-rabbitmq-monitor.js | 17 + .../2024-11-27-1927-fix-info-json-data-type.js | 13 + db/knex_migrations/README.md | 56 + db/kuma.db | Bin 0 -> 61440 bytes db/old_migrations/README.md | 3 + .../patch-2fa-invalidate-used-token.sql | 7 + db/old_migrations/patch-2fa.sql | 10 + .../patch-add-certificate-expiry-status-page.sql | 7 + .../patch-add-clickable-status-page-link.sql | 7 + .../patch-add-description-monitor.sql | 7 + db/old_migrations/patch-add-docker-columns.sql | 18 + db/old_migrations/patch-add-gamedig-given-port.sql | 7 + db/old_migrations/patch-add-gamedig-monitor.sql | 7 + .../patch-add-google-analytics-status-page-tag.sql | 7 + db/old_migrations/patch-add-invert-keyword.sql | 7 + db/old_migrations/patch-add-other-auth.sql | 18 + db/old_migrations/patch-add-parent-monitor.sql | 7 + db/old_migrations/patch-add-radius-monitor.sql | 19 + .../patch-add-retry-interval-monitor.sql | 7 + db/old_migrations/patch-add-sqlserver-monitor.sql | 10 + db/old_migrations/patch-add-timeout-monitor.sql | 7 + db/old_migrations/patch-added-json-query.sql | 10 + db/old_migrations/patch-added-kafka-producer.sql | 22 + db/old_migrations/patch-added-mqtt-monitor.sql | 16 + db/old_migrations/patch-api-key-table.sql | 15 + .../patch-fix-kafka-producer-booleans.sql | 34 + db/old_migrations/patch-group-table.sql | 30 + db/old_migrations/patch-grpc-monitor.sql | 25 + db/old_migrations/patch-http-body-encoding.sql | 12 + .../patch-http-monitor-method-body-and-headers.sql | 13 + db/old_migrations/patch-improve-performance.sql | 10 + db/old_migrations/patch-incident-table.sql | 18 + db/old_migrations/patch-maintenance-cron.sql | 11 + db/old_migrations/patch-maintenance-table2.sql | 83 + .../patch-monitor-add-resend-interval.sql | 10 + db/old_migrations/patch-monitor-basic-auth.sql | 10 + .../patch-monitor-expiry-notification.sql | 7 + db/old_migrations/patch-monitor-oauth-cc.sql | 19 + db/old_migrations/patch-monitor-push_token.sql | 7 + .../patch-monitor-tls-info-add-fk.sql | 18 + db/old_migrations/patch-monitor-tls.sql | 13 + db/old_migrations/patch-notification-config.sql | 10 + .../patch-notification_sent_history.sql | 18 + db/old_migrations/patch-ping-packet-size.sql | 7 + db/old_migrations/patch-proxy.sql | 23 + db/old_migrations/patch-setting-value-type.sql | 21 + db/old_migrations/patch-status-page-footer-css.sql | 11 + db/old_migrations/patch-status-page.sql | 31 + db/old_migrations/patch-timeout.sql | 7 + db/old_migrations/patch1.sql | 37 + db/old_migrations/patch10.sql | 19 + db/old_migrations/patch2.sql | 10 + db/old_migrations/patch3.sql | 37 + db/old_migrations/patch4.sql | 40 + db/old_migrations/patch5.sql | 70 + db/old_migrations/patch6.sql | 74 + db/old_migrations/patch7.sql | 10 + db/old_migrations/patch8.sql | 7 + db/old_migrations/patch9.sql | 7 + db/patch-monitor-tls-info-add-fk.sql | 18 + docker/builder-go.dockerfile | 16 + docker/debian-base.dockerfile | 72 + docker/docker-compose-dev.yml | 14 + docker/dockerfile | 114 + docker/etc/nscd.conf | 90 + docker/etc/sudoers | 31 + ecosystem.config.js | 6 + extra/beta/update-version.js | 84 + extra/build-healthcheck.js | 27 + extra/check-knex-filenames.mjs | 72 + extra/check-lang-json.js | 27 + extra/checkout-pr.js | 33 + extra/close-incorrect-issue.js | 57 + extra/compile-install-script.ps1 | 2 + extra/deploy-demo-server.js | 60 + extra/download-apprise.mjs | 57 + extra/download-dist.js | 69 + extra/healthcheck.go | 90 + extra/healthcheck.js | 55 + extra/mark-as-nightly.js | 24 + extra/push-examples/.gitignore | 3 + extra/push-examples/bash-curl/index.sh | 10 + extra/push-examples/csharp/index.cs | 24 + extra/push-examples/docker/index.sh | 1 + extra/push-examples/go/index.go | 20 + extra/push-examples/java/index.java | 32 + extra/push-examples/javascript-fetch/index.js | 11 + extra/push-examples/javascript-fetch/package.json | 5 + extra/push-examples/php/index.php | 13 + extra/push-examples/powershell/index.ps1 | 9 + extra/push-examples/python/index.py | 10 + extra/push-examples/typescript-fetch/README.md | 19 + extra/push-examples/typescript-fetch/index.ts | 11 + extra/push-examples/typescript-fetch/package.json | 13 + extra/rebase-pr.js | 40 + extra/reformat-changelog.js | 44 + extra/release/beta.mjs | 65 + extra/release/final.mjs | 57 + extra/release/lib.mjs | 191 + extra/release/nightly.mjs | 16 + extra/remove-2fa.js | 65 + extra/remove-empty-lang-keys.js | 25 + extra/remove-playwright-test-data.js | 6 + extra/reset-migrate-aggregate-table-state.js | 24 + extra/reset-password.js | 141 + extra/simple-dns-server.js | 149 + extra/simple-mqtt-server.js | 57 + extra/sort-contributors.js | 22 + extra/update-language-files/.gitignore | 3 + extra/update-language-files/index.js | 103 + extra/update-language-files/package.json | 12 + extra/update-version.js | 81 + extra/update-wiki-version.js | 58 + extra/upload-github-release-asset.sh | 64 + extra/uptime-kuma-push/.gitignore | 1 + extra/uptime-kuma-push/Dockerfile | 18 + extra/uptime-kuma-push/build.js | 48 + extra/uptime-kuma-push/package.json | 13 + extra/uptime-kuma-push/uptime-kuma-push.go | 44 + index.html | 33 + package-lock.json | 17209 +++++++++++++++++++ package.json | 210 + public/apple-touch-icon-precomposed.png | Bin 0 -> 5792 bytes public/apple-touch-icon.png | Bin 0 -> 4807 bytes public/favicon.ico | Bin 0 -> 15086 bytes public/icon-192x192.png | Bin 0 -> 2707 bytes public/icon-512x512.png | Bin 0 -> 9739 bytes public/icon.png | Bin 0 -> 11361 bytes public/icon.svg | 9 + public/manifest.json | 19 + server/2fa.js | 18 + server/auth.js | 179 + server/check-version.js | 69 + server/client.js | 252 + server/config.js | 46 + server/database.js | 912 + server/docker.js | 179 + server/embedded-mariadb.js | 176 + server/google-analytics.js | 28 + server/image-data-uri.js | 79 + server/jobs.js | 58 + server/jobs/clear-old-data.js | 65 + server/jobs/incremental-vacuum.js | 27 + server/model/api_key.js | 76 + server/model/docker_host.js | 19 + server/model/group.js | 46 + server/model/heartbeat.js | 45 + server/model/incident.js | 23 + server/model/maintenance.js | 457 + server/model/monitor.js | 1740 ++ server/model/proxy.js | 25 + server/model/remote_browser.js | 17 + server/model/status_page.js | 491 + server/model/tag.js | 18 + server/model/user.js | 53 + server/modules/apicache/apicache.js | 917 + server/modules/apicache/index.js | 14 + server/modules/apicache/memory-cache.js | 87 + server/modules/axios-ntlm/LICENSE | 21 + server/modules/axios-ntlm/lib/flags.js | 77 + server/modules/axios-ntlm/lib/hash.js | 122 + server/modules/axios-ntlm/lib/ntlm.js | 220 + server/modules/axios-ntlm/lib/ntlmClient.js | 127 + server/modules/dayjs/plugin/timezone.d.ts | 20 + server/modules/dayjs/plugin/timezone.js | 115 + server/monitor-conditions/evaluator.js | 71 + server/monitor-conditions/expression.js | 111 + server/monitor-conditions/operators.js | 318 + server/monitor-conditions/variables.js | 31 + server/monitor-types/dns.js | 85 + server/monitor-types/mongodb.js | 63 + server/monitor-types/monitor-type.js | 31 + server/monitor-types/mqtt.js | 117 + server/monitor-types/rabbitmq.js | 67 + server/monitor-types/real-browser-monitor-type.js | 273 + server/monitor-types/snmp.js | 63 + server/monitor-types/tailscale-ping.js | 77 + server/notification-providers/46elks.js | 35 + server/notification-providers/alerta.js | 68 + server/notification-providers/alertnow.js | 53 + server/notification-providers/aliyun-sms.js | 143 + server/notification-providers/apprise.js | 37 + server/notification-providers/bitrix24.js | 31 + server/notification-providers/call-me-bot.js | 23 + server/notification-providers/cellsynt.js | 39 + server/notification-providers/clicksendsms.js | 45 + server/notification-providers/dingding.js | 101 + server/notification-providers/discord.js | 120 + server/notification-providers/feishu.js | 104 + server/notification-providers/flashduty.js | 108 + server/notification-providers/freemobile.js | 27 + server/notification-providers/goalert.js | 36 + server/notification-providers/google-chat.js | 94 + server/notification-providers/gorush.js | 44 + server/notification-providers/gotify.js | 31 + server/notification-providers/grafana-oncall.js | 51 + server/notification-providers/gtx-messaging.js | 33 + server/notification-providers/heii-oncall.js | 52 + server/notification-providers/home-assistant.js | 45 + server/notification-providers/keep.js | 42 + server/notification-providers/kook.js | 34 + server/notification-providers/line.js | 69 + server/notification-providers/linenotify.js | 52 + server/notification-providers/lunasea.js | 67 + server/notification-providers/matrix.js | 48 + server/notification-providers/mattermost.js | 110 + server/notification-providers/nostr.js | 122 + .../notification-provider.js | 73 + server/notification-providers/ntfy.js | 83 + server/notification-providers/octopush.js | 76 + server/notification-providers/onebot.js | 48 + server/notification-providers/onesender.js | 47 + server/notification-providers/opsgenie.js | 96 + server/notification-providers/pagerduty.js | 114 + server/notification-providers/pagertree.js | 93 + server/notification-providers/promosms.js | 53 + server/notification-providers/pushbullet.js | 56 + server/notification-providers/pushdeer.js | 55 + server/notification-providers/pushover.js | 58 + server/notification-providers/pushy.js | 32 + server/notification-providers/rocket-chat.js | 67 + server/notification-providers/send-grid.js | 65 + server/notification-providers/serverchan.js | 51 + server/notification-providers/serwersms.js | 47 + server/notification-providers/sevenio.js | 57 + server/notification-providers/signal.js | 29 + server/notification-providers/signl4.js | 52 + server/notification-providers/slack.js | 173 + server/notification-providers/smsc.js | 47 + server/notification-providers/smseagle.js | 73 + server/notification-providers/smsmanager.js | 29 + server/notification-providers/smspartner.js | 46 + server/notification-providers/smtp.js | 120 + server/notification-providers/splunk.js | 114 + server/notification-providers/squadcast.js | 60 + server/notification-providers/stackfield.js | 44 + server/notification-providers/teams.js | 240 + server/notification-providers/techulus-push.js | 36 + server/notification-providers/telegram.js | 36 + server/notification-providers/threema.js | 77 + server/notification-providers/twilio.js | 38 + server/notification-providers/webhook.js | 66 + server/notification-providers/wecom.js | 51 + server/notification-providers/whapi.js | 39 + server/notification-providers/wpush.js | 51 + server/notification-providers/zoho-cliq.js | 101 + server/notification.js | 284 + server/password-hash.js | 44 + server/prometheus.js | 123 + server/proxy.js | 202 + server/rate-limiter.js | 75 + server/remote-browser.js | 74 + server/routers/api-router.js | 631 + server/routers/status-page-router.js | 241 + server/server.js | 1877 ++ server/settings.js | 177 + server/setup-database.js | 271 + server/socket-handlers/api-key-socket-handler.js | 155 + server/socket-handlers/chart-socket-handler.js | 38 + .../socket-handlers/cloudflared-socket-handler.js | 122 + server/socket-handlers/database-socket-handler.js | 42 + server/socket-handlers/docker-socket-handler.js | 82 + server/socket-handlers/general-socket-handler.js | 127 + .../socket-handlers/maintenance-socket-handler.js | 337 + server/socket-handlers/proxy-socket-handler.js | 61 + .../remote-browser-socket-handler.js | 82 + .../socket-handlers/status-page-socket-handler.js | 374 + server/uptime-calculator.js | 865 + server/uptime-kuma-server.js | 557 + server/util-server.js | 1064 ++ server/utils/array-with-key.js | 85 + .../mysql2/schema/mysql2-columncompiler.js | 22 + server/utils/limit-queue.js | 48 + server/utils/simple-migration-server.js | 84 + src/App.vue | 12 + src/assets/app.scss | 650 + src/assets/localization.scss | 9 + src/assets/multiselect.scss | 82 + src/assets/vars.scss | 23 + src/assets/vue-datepicker.scss | 39 + src/components/APIKeyDialog.vue | 233 + src/components/ActionInput.vue | 93 + src/components/ActionSelect.vue | 100 + src/components/BadgeGeneratorDialog.vue | 306 + src/components/CertificateInfo.vue | 54 + src/components/CertificateInfoRow.vue | 129 + src/components/Confirm.vue | 84 + src/components/CopyableInput.vue | 142 + src/components/CountUp.vue | 79 + src/components/CreateGroupDialog.vue | 63 + src/components/Datetime.vue | 30 + src/components/DockerHostDialog.vue | 198 + src/components/EditMonitorCondition.vue | 152 + src/components/EditMonitorConditionGroup.vue | 189 + src/components/EditMonitorConditions.vue | 149 + src/components/HeartbeatBar.vue | 348 + src/components/HiddenInput.vue | 93 + src/components/Login.vue | 113 + src/components/MaintenanceTime.vue | 60 + src/components/MonitorList.vue | 485 + src/components/MonitorListFilter.vue | 293 + src/components/MonitorListFilterDropdown.vue | 137 + src/components/MonitorListItem.vue | 256 + src/components/MonitorSettingDialog.vue | 125 + src/components/NotificationDialog.vue | 352 + src/components/PingChart.vue | 610 + src/components/ProxyDialog.vue | 224 + src/components/PublicGroupList.vue | 273 + src/components/RemoteBrowserDialog.vue | 185 + src/components/ScreenshotDialog.vue | 52 + src/components/Status.vue | 63 + src/components/Tag.vue | 87 + src/components/TagEditDialog.vue | 485 + src/components/TagsManager.vue | 475 + src/components/ToggleSection.vue | 69 + src/components/TwoFADialog.vue | 225 + src/components/Uptime.vue | 103 + src/components/notifications/46elks.vue | 48 + src/components/notifications/AlertNow.vue | 13 + src/components/notifications/Alerta.vue | 14 + src/components/notifications/AliyunSms.vue | 25 + src/components/notifications/Apprise.vue | 38 + src/components/notifications/Bark.vue | 60 + src/components/notifications/Bitrix24.vue | 24 + src/components/notifications/CallMeBot.vue | 13 + src/components/notifications/Cellsynt.vue | 54 + src/components/notifications/ClickSendSMS.vue | 37 + src/components/notifications/DingDing.vue | 37 + src/components/notifications/Discord.vue | 65 + src/components/notifications/Feishu.vue | 15 + src/components/notifications/FlashDuty.vue | 29 + src/components/notifications/FreeMobile.vue | 12 + src/components/notifications/GoAlert.vue | 28 + src/components/notifications/GoogleChat.vue | 13 + src/components/notifications/Gorush.vue | 47 + src/components/notifications/Gotify.vue | 30 + src/components/notifications/GrafanaOncall.vue | 7 + src/components/notifications/GtxMessaging.vue | 49 + src/components/notifications/HeiiOnCall.vue | 34 + src/components/notifications/HomeAssistant.vue | 40 + src/components/notifications/Keep.vue | 42 + src/components/notifications/Kook.vue | 33 + src/components/notifications/Line.vue | 29 + src/components/notifications/LineNotify.vue | 9 + src/components/notifications/LunaSea.vue | 33 + src/components/notifications/Matrix.vue | 34 + src/components/notifications/Mattermost.vue | 32 + src/components/notifications/Nostr.vue | 26 + src/components/notifications/Ntfy.vue | 82 + src/components/notifications/Octopush.vue | 50 + src/components/notifications/OneBot.vue | 34 + src/components/notifications/Onesender.vue | 81 + src/components/notifications/Opsgenie.vue | 36 + src/components/notifications/PagerDuty.vue | 45 + src/components/notifications/PagerTree.vue | 31 + src/components/notifications/PromoSMS.vue | 43 + src/components/notifications/PushDeer.vue | 24 + src/components/notifications/Pushbullet.vue | 20 + src/components/notifications/Pushover.vue | 70 + src/components/notifications/Pushy.vue | 24 + src/components/notifications/RocketChat.vue | 27 + src/components/notifications/SIGNL4.vue | 16 + src/components/notifications/SMSC.vue | 43 + src/components/notifications/SMSEagle.vue | 40 + src/components/notifications/SMSManager.vue | 31 + src/components/notifications/SMSPartner.vue | 39 + src/components/notifications/SMTP.vue | 149 + src/components/notifications/SendGrid.vue | 47 + src/components/notifications/ServerChan.vue | 16 + src/components/notifications/SerwerSMS.vue | 28 + src/components/notifications/SevenIO.vue | 31 + src/components/notifications/Signal.vue | 34 + src/components/notifications/Slack.vue | 45 + src/components/notifications/Splunk.vue | 32 + src/components/notifications/Squadcast.vue | 6 + src/components/notifications/Stackfield.vue | 13 + src/components/notifications/Teams.vue | 18 + src/components/notifications/TechulusPush.vue | 81 + src/components/notifications/Telegram.vue | 117 + src/components/notifications/Threema.vue | 87 + src/components/notifications/Twilio.vue | 38 + src/components/notifications/WPush.vue | 31 + src/components/notifications/WeCom.vue | 12 + src/components/notifications/Webhook.vue | 100 + src/components/notifications/Whapi.vue | 33 + src/components/notifications/ZohoCliq.vue | 18 + src/components/notifications/index.js | 147 + src/components/settings/APIKeys.vue | 273 + src/components/settings/About.vue | 66 + src/components/settings/Appearance.vue | 190 + src/components/settings/Docker.vue | 48 + src/components/settings/General.vue | 283 + src/components/settings/MonitorHistory.vue | 155 + src/components/settings/Notifications.vue | 218 + src/components/settings/Proxies.vue | 48 + src/components/settings/RemoteBrowsers.vue | 53 + src/components/settings/ReverseProxy.vue | 211 + src/components/settings/Security.vue | 228 + src/components/settings/Tags.vue | 175 + src/i18n.js | 97 + src/icon.js | 103 + src/lang/README.md | 20 + src/lang/ab.json | 1 + src/lang/af.json | 66 + src/lang/ar-SY.json | 718 + src/lang/ar.json | 737 + src/lang/bar.json | 6 + src/lang/be.json | 937 + src/lang/bg-BG.json | 1101 ++ src/lang/bn.json | 18 + src/lang/ca.json | 217 + src/lang/ckb.json | 46 + src/lang/cs-CZ.json | 1059 ++ src/lang/da-DK.json | 660 + src/lang/de-CH.json | 1099 ++ src/lang/de-DE.json | 1102 ++ src/lang/el-GR.json | 712 + src/lang/en.json | 1055 ++ src/lang/enm.json | 1 + src/lang/es-ES.json | 992 ++ src/lang/et-EE.json | 317 + src/lang/eu.json | 591 + src/lang/fa.json | 1024 ++ src/lang/fi.json | 1099 ++ src/lang/fr-FR.json | 1101 ++ src/lang/ga.json | 1020 ++ src/lang/gl.json | 23 + src/lang/he-IL.json | 780 + src/lang/he.json | 5 + src/lang/hi.json | 110 + src/lang/hr-HR.json | 1095 ++ src/lang/hu.json | 853 + src/lang/id-ID.json | 1092 ++ src/lang/it-IT.json | 741 + src/lang/ja.json | 706 + src/lang/ka.json | 21 + src/lang/ko-KR.json | 789 + src/lang/lt.json | 222 + src/lang/lzh.json | 1 + src/lang/mk.json | 92 + src/lang/ml.json | 52 + src/lang/ms.json | 53 + src/lang/my.json | 95 + src/lang/nb-NO.json | 563 + src/lang/nl-NL.json | 1045 ++ src/lang/pa.json | 7 + src/lang/pa_PK.json | 12 + src/lang/pl.json | 1092 ++ src/lang/pt-BR.json | 991 ++ src/lang/pt-PT.json | 476 + src/lang/pt.json | 91 + src/lang/ro.json | 1043 ++ src/lang/ru-RU.json | 990 ++ src/lang/sk.json | 562 + src/lang/sl-SI.json | 632 + src/lang/sq.json | 255 + src/lang/sr-latn.json | 115 + src/lang/sr.json | 114 + src/lang/sv-SE.json | 994 ++ src/lang/te.json | 314 + src/lang/th-TH.json | 697 + src/lang/tr-TR.json | 1101 ++ src/lang/ug.json | 1 + src/lang/uk-UA.json | 1107 ++ src/lang/ur.json | 569 + src/lang/uz.json | 97 + src/lang/vi-VN.json | 559 + src/lang/xh.json | 7 + src/lang/yue.json | 110 + src/lang/zh-CN.json | 1104 ++ src/lang/zh-HK.json | 764 + src/lang/zh-TW.json | 946 + src/layouts/EmptyLayout.vue | 8 + src/layouts/Layout.vue | 400 + src/main.js | 58 + src/mixins/datetime.js | 138 + src/mixins/lang.js | 38 + src/mixins/mobile.js | 44 + src/mixins/public.js | 55 + src/mixins/socket.js | 879 + src/mixins/theme.js | 111 + src/modules/dayjs/constant.js | 25 + src/modules/dayjs/plugin/timezone/index.d.ts | 20 + src/modules/dayjs/plugin/timezone/index.js | 188 + src/pages/AddStatusPage.vue | 88 + src/pages/Dashboard.vue | 42 + src/pages/DashboardHome.vue | 248 + src/pages/Details.vue | 826 + src/pages/EditMaintenance.vue | 611 + src/pages/EditMonitor.vue | 1858 ++ src/pages/Entry.vue | 54 + src/pages/List.vue | 24 + src/pages/MaintenanceDetails.vue | 169 + src/pages/ManageMaintenance.vue | 317 + src/pages/ManageStatusPage.vue | 123 + src/pages/NotFound.vue | 104 + src/pages/Settings.vue | 317 + src/pages/Setup.vue | 138 + src/pages/SetupDatabase.vue | 238 + src/pages/StatusPage.vue | 1271 ++ src/router.js | 199 + src/util-frontend.js | 215 + src/util.js | 461 + src/util.ts | 724 + test/backend-test/README.md | 22 + .../monitor-conditions/test-evaluator.js | 46 + .../monitor-conditions/test-expressions.js | 55 + .../monitor-conditions/test-operators.js | 108 + test/backend-test/test-mqtt.js | 102 + test/backend-test/test-rabbitmq.js | 53 + test/backend-test/test-uptime-calculator.js | 425 + test/e2e/specs/example.spec.js | 39 + test/e2e/specs/monitor-form.spec.js | 104 + test/e2e/specs/setup-process.once.js | 55 + test/e2e/specs/status-page.spec.js | 129 + test/e2e/util-test.js | 62 + test/prepare-test-server.js | 10 + test/test-radius.dockerfile | 13 + tsconfig.json | 21 + 563 files changed, 107524 insertions(+) create mode 100644 .dockerignore create mode 100644 .editorconfig create mode 100644 .eslintrc.js create mode 100644 .github/FUNDING.yml create mode 100644 .github/ISSUE_TEMPLATE/ask-for-help.yaml create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yaml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yaml create mode 100644 .github/ISSUE_TEMPLATE/security.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/config/exclude.txt create mode 100644 .github/workflows/auto-test.yml create mode 100644 .github/workflows/close-incorrect-issue.yml create mode 100644 .github/workflows/codeql-analysis.yml create mode 100644 .github/workflows/conflict_labeler.yml create mode 100644 .github/workflows/prevent-file-change.yml create mode 100644 .github/workflows/stale-bot.yml create mode 100644 .github/workflows/validate.yml create mode 100644 .gitignore create mode 100644 .npmrc create mode 100644 .stylelintrc create mode 100644 CNAME create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE create mode 100644 README.md create mode 100644 SECURITY.md create mode 100644 compose.yaml create mode 100644 config/jest-backend.config.js create mode 100644 config/playwright.config.js create mode 100644 config/vite.config.js create mode 100644 db/knex_init_db.js create mode 100644 db/knex_migrations/2023-08-16-0000-create-uptime.js create mode 100644 db/knex_migrations/2023-08-18-0301-heartbeat.js create mode 100644 db/knex_migrations/2023-09-29-0000-heartbeat-retires.js create mode 100644 db/knex_migrations/2023-10-08-0000-mqtt-query.js create mode 100644 db/knex_migrations/2023-10-11-1915-push-token-to-32.js create mode 100644 db/knex_migrations/2023-10-16-0000-create-remote-browsers.js create mode 100644 db/knex_migrations/2023-12-20-0000-alter-status-page.js create mode 100644 db/knex_migrations/2023-12-21-0000-stat-ping-min-max.js create mode 100644 db/knex_migrations/2023-12-22-0000-hourly-uptime.js create mode 100644 db/knex_migrations/2024-01-22-0000-stats-extras.js create mode 100644 db/knex_migrations/2024-04-26-0000-snmp-monitor.js create mode 100644 db/knex_migrations/2024-08-24-000-add-cache-bust.js create mode 100644 db/knex_migrations/2024-08-24-0000-conditions.js create mode 100644 db/knex_migrations/2024-10-1315-rabbitmq-monitor.js create mode 100644 db/knex_migrations/2024-11-27-1927-fix-info-json-data-type.js create mode 100644 db/knex_migrations/README.md create mode 100644 db/kuma.db create mode 100644 db/old_migrations/README.md create mode 100644 db/old_migrations/patch-2fa-invalidate-used-token.sql create mode 100644 db/old_migrations/patch-2fa.sql create mode 100644 db/old_migrations/patch-add-certificate-expiry-status-page.sql create mode 100644 db/old_migrations/patch-add-clickable-status-page-link.sql create mode 100644 db/old_migrations/patch-add-description-monitor.sql create mode 100644 db/old_migrations/patch-add-docker-columns.sql create mode 100644 db/old_migrations/patch-add-gamedig-given-port.sql create mode 100644 db/old_migrations/patch-add-gamedig-monitor.sql create mode 100644 db/old_migrations/patch-add-google-analytics-status-page-tag.sql create mode 100644 db/old_migrations/patch-add-invert-keyword.sql create mode 100644 db/old_migrations/patch-add-other-auth.sql create mode 100644 db/old_migrations/patch-add-parent-monitor.sql create mode 100644 db/old_migrations/patch-add-radius-monitor.sql create mode 100644 db/old_migrations/patch-add-retry-interval-monitor.sql create mode 100644 db/old_migrations/patch-add-sqlserver-monitor.sql create mode 100644 db/old_migrations/patch-add-timeout-monitor.sql create mode 100644 db/old_migrations/patch-added-json-query.sql create mode 100644 db/old_migrations/patch-added-kafka-producer.sql create mode 100644 db/old_migrations/patch-added-mqtt-monitor.sql create mode 100644 db/old_migrations/patch-api-key-table.sql create mode 100644 db/old_migrations/patch-fix-kafka-producer-booleans.sql create mode 100644 db/old_migrations/patch-group-table.sql create mode 100644 db/old_migrations/patch-grpc-monitor.sql create mode 100644 db/old_migrations/patch-http-body-encoding.sql create mode 100644 db/old_migrations/patch-http-monitor-method-body-and-headers.sql create mode 100644 db/old_migrations/patch-improve-performance.sql create mode 100644 db/old_migrations/patch-incident-table.sql create mode 100644 db/old_migrations/patch-maintenance-cron.sql create mode 100644 db/old_migrations/patch-maintenance-table2.sql create mode 100644 db/old_migrations/patch-monitor-add-resend-interval.sql create mode 100644 db/old_migrations/patch-monitor-basic-auth.sql create mode 100644 db/old_migrations/patch-monitor-expiry-notification.sql create mode 100644 db/old_migrations/patch-monitor-oauth-cc.sql create mode 100644 db/old_migrations/patch-monitor-push_token.sql create mode 100644 db/old_migrations/patch-monitor-tls-info-add-fk.sql create mode 100644 db/old_migrations/patch-monitor-tls.sql create mode 100644 db/old_migrations/patch-notification-config.sql create mode 100644 db/old_migrations/patch-notification_sent_history.sql create mode 100644 db/old_migrations/patch-ping-packet-size.sql create mode 100644 db/old_migrations/patch-proxy.sql create mode 100644 db/old_migrations/patch-setting-value-type.sql create mode 100644 db/old_migrations/patch-status-page-footer-css.sql create mode 100644 db/old_migrations/patch-status-page.sql create mode 100644 db/old_migrations/patch-timeout.sql create mode 100644 db/old_migrations/patch1.sql create mode 100644 db/old_migrations/patch10.sql create mode 100644 db/old_migrations/patch2.sql create mode 100644 db/old_migrations/patch3.sql create mode 100644 db/old_migrations/patch4.sql create mode 100644 db/old_migrations/patch5.sql create mode 100644 db/old_migrations/patch6.sql create mode 100644 db/old_migrations/patch7.sql create mode 100644 db/old_migrations/patch8.sql create mode 100644 db/old_migrations/patch9.sql create mode 100644 db/patch-monitor-tls-info-add-fk.sql create mode 100644 docker/builder-go.dockerfile create mode 100644 docker/debian-base.dockerfile create mode 100644 docker/docker-compose-dev.yml create mode 100644 docker/dockerfile create mode 100644 docker/etc/nscd.conf create mode 100644 docker/etc/sudoers create mode 100644 ecosystem.config.js create mode 100644 extra/beta/update-version.js create mode 100644 extra/build-healthcheck.js create mode 100644 extra/check-knex-filenames.mjs create mode 100644 extra/check-lang-json.js create mode 100644 extra/checkout-pr.js create mode 100644 extra/close-incorrect-issue.js create mode 100644 extra/compile-install-script.ps1 create mode 100644 extra/deploy-demo-server.js create mode 100644 extra/download-apprise.mjs create mode 100644 extra/download-dist.js create mode 100644 extra/healthcheck.go create mode 100644 extra/healthcheck.js create mode 100644 extra/mark-as-nightly.js create mode 100644 extra/push-examples/.gitignore create mode 100644 extra/push-examples/bash-curl/index.sh create mode 100644 extra/push-examples/csharp/index.cs create mode 100644 extra/push-examples/docker/index.sh create mode 100644 extra/push-examples/go/index.go create mode 100644 extra/push-examples/java/index.java create mode 100644 extra/push-examples/javascript-fetch/index.js create mode 100644 extra/push-examples/javascript-fetch/package.json create mode 100644 extra/push-examples/php/index.php create mode 100644 extra/push-examples/powershell/index.ps1 create mode 100644 extra/push-examples/python/index.py create mode 100644 extra/push-examples/typescript-fetch/README.md create mode 100644 extra/push-examples/typescript-fetch/index.ts create mode 100644 extra/push-examples/typescript-fetch/package.json create mode 100644 extra/rebase-pr.js create mode 100644 extra/reformat-changelog.js create mode 100644 extra/release/beta.mjs create mode 100644 extra/release/final.mjs create mode 100644 extra/release/lib.mjs create mode 100644 extra/release/nightly.mjs create mode 100644 extra/remove-2fa.js create mode 100644 extra/remove-empty-lang-keys.js create mode 100644 extra/remove-playwright-test-data.js create mode 100644 extra/reset-migrate-aggregate-table-state.js create mode 100644 extra/reset-password.js create mode 100644 extra/simple-dns-server.js create mode 100644 extra/simple-mqtt-server.js create mode 100644 extra/sort-contributors.js create mode 100644 extra/update-language-files/.gitignore create mode 100644 extra/update-language-files/index.js create mode 100644 extra/update-language-files/package.json create mode 100644 extra/update-version.js create mode 100644 extra/update-wiki-version.js create mode 100644 extra/upload-github-release-asset.sh create mode 100644 extra/uptime-kuma-push/.gitignore create mode 100644 extra/uptime-kuma-push/Dockerfile create mode 100644 extra/uptime-kuma-push/build.js create mode 100644 extra/uptime-kuma-push/package.json create mode 100644 extra/uptime-kuma-push/uptime-kuma-push.go create mode 100644 index.html create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 public/apple-touch-icon-precomposed.png create mode 100644 public/apple-touch-icon.png create mode 100644 public/favicon.ico create mode 100644 public/icon-192x192.png create mode 100644 public/icon-512x512.png create mode 100644 public/icon.png create mode 100644 public/icon.svg create mode 100644 public/manifest.json create mode 100644 server/2fa.js create mode 100644 server/auth.js create mode 100644 server/check-version.js create mode 100644 server/client.js create mode 100644 server/config.js create mode 100644 server/database.js create mode 100644 server/docker.js create mode 100644 server/embedded-mariadb.js create mode 100644 server/google-analytics.js create mode 100644 server/image-data-uri.js create mode 100644 server/jobs.js create mode 100644 server/jobs/clear-old-data.js create mode 100644 server/jobs/incremental-vacuum.js create mode 100644 server/model/api_key.js create mode 100644 server/model/docker_host.js create mode 100644 server/model/group.js create mode 100644 server/model/heartbeat.js create mode 100644 server/model/incident.js create mode 100644 server/model/maintenance.js create mode 100644 server/model/monitor.js create mode 100644 server/model/proxy.js create mode 100644 server/model/remote_browser.js create mode 100644 server/model/status_page.js create mode 100644 server/model/tag.js create mode 100644 server/model/user.js create mode 100644 server/modules/apicache/apicache.js create mode 100644 server/modules/apicache/index.js create mode 100644 server/modules/apicache/memory-cache.js create mode 100644 server/modules/axios-ntlm/LICENSE create mode 100644 server/modules/axios-ntlm/lib/flags.js create mode 100644 server/modules/axios-ntlm/lib/hash.js create mode 100644 server/modules/axios-ntlm/lib/ntlm.js create mode 100644 server/modules/axios-ntlm/lib/ntlmClient.js create mode 100644 server/modules/dayjs/plugin/timezone.d.ts create mode 100644 server/modules/dayjs/plugin/timezone.js create mode 100644 server/monitor-conditions/evaluator.js create mode 100644 server/monitor-conditions/expression.js create mode 100644 server/monitor-conditions/operators.js create mode 100644 server/monitor-conditions/variables.js create mode 100644 server/monitor-types/dns.js create mode 100644 server/monitor-types/mongodb.js create mode 100644 server/monitor-types/monitor-type.js create mode 100644 server/monitor-types/mqtt.js create mode 100644 server/monitor-types/rabbitmq.js create mode 100644 server/monitor-types/real-browser-monitor-type.js create mode 100644 server/monitor-types/snmp.js create mode 100644 server/monitor-types/tailscale-ping.js create mode 100644 server/notification-providers/46elks.js create mode 100644 server/notification-providers/alerta.js create mode 100644 server/notification-providers/alertnow.js create mode 100644 server/notification-providers/aliyun-sms.js create mode 100644 server/notification-providers/apprise.js create mode 100644 server/notification-providers/bitrix24.js create mode 100644 server/notification-providers/call-me-bot.js create mode 100644 server/notification-providers/cellsynt.js create mode 100644 server/notification-providers/clicksendsms.js create mode 100644 server/notification-providers/dingding.js create mode 100644 server/notification-providers/discord.js create mode 100644 server/notification-providers/feishu.js create mode 100644 server/notification-providers/flashduty.js create mode 100644 server/notification-providers/freemobile.js create mode 100644 server/notification-providers/goalert.js create mode 100644 server/notification-providers/google-chat.js create mode 100644 server/notification-providers/gorush.js create mode 100644 server/notification-providers/gotify.js create mode 100644 server/notification-providers/grafana-oncall.js create mode 100644 server/notification-providers/gtx-messaging.js create mode 100644 server/notification-providers/heii-oncall.js create mode 100644 server/notification-providers/home-assistant.js create mode 100644 server/notification-providers/keep.js create mode 100644 server/notification-providers/kook.js create mode 100644 server/notification-providers/line.js create mode 100644 server/notification-providers/linenotify.js create mode 100644 server/notification-providers/lunasea.js create mode 100644 server/notification-providers/matrix.js create mode 100644 server/notification-providers/mattermost.js create mode 100644 server/notification-providers/nostr.js create mode 100644 server/notification-providers/notification-provider.js create mode 100644 server/notification-providers/ntfy.js create mode 100644 server/notification-providers/octopush.js create mode 100644 server/notification-providers/onebot.js create mode 100644 server/notification-providers/onesender.js create mode 100644 server/notification-providers/opsgenie.js create mode 100644 server/notification-providers/pagerduty.js create mode 100644 server/notification-providers/pagertree.js create mode 100644 server/notification-providers/promosms.js create mode 100644 server/notification-providers/pushbullet.js create mode 100644 server/notification-providers/pushdeer.js create mode 100644 server/notification-providers/pushover.js create mode 100644 server/notification-providers/pushy.js create mode 100644 server/notification-providers/rocket-chat.js create mode 100644 server/notification-providers/send-grid.js create mode 100644 server/notification-providers/serverchan.js create mode 100644 server/notification-providers/serwersms.js create mode 100644 server/notification-providers/sevenio.js create mode 100644 server/notification-providers/signal.js create mode 100644 server/notification-providers/signl4.js create mode 100644 server/notification-providers/slack.js create mode 100644 server/notification-providers/smsc.js create mode 100644 server/notification-providers/smseagle.js create mode 100644 server/notification-providers/smsmanager.js create mode 100644 server/notification-providers/smspartner.js create mode 100644 server/notification-providers/smtp.js create mode 100644 server/notification-providers/splunk.js create mode 100644 server/notification-providers/squadcast.js create mode 100644 server/notification-providers/stackfield.js create mode 100644 server/notification-providers/teams.js create mode 100644 server/notification-providers/techulus-push.js create mode 100644 server/notification-providers/telegram.js create mode 100644 server/notification-providers/threema.js create mode 100644 server/notification-providers/twilio.js create mode 100644 server/notification-providers/webhook.js create mode 100644 server/notification-providers/wecom.js create mode 100644 server/notification-providers/whapi.js create mode 100644 server/notification-providers/wpush.js create mode 100644 server/notification-providers/zoho-cliq.js create mode 100644 server/notification.js create mode 100644 server/password-hash.js create mode 100644 server/prometheus.js create mode 100644 server/proxy.js create mode 100644 server/rate-limiter.js create mode 100644 server/remote-browser.js create mode 100644 server/routers/api-router.js create mode 100644 server/routers/status-page-router.js create mode 100644 server/server.js create mode 100644 server/settings.js create mode 100644 server/setup-database.js create mode 100644 server/socket-handlers/api-key-socket-handler.js create mode 100644 server/socket-handlers/chart-socket-handler.js create mode 100644 server/socket-handlers/cloudflared-socket-handler.js create mode 100644 server/socket-handlers/database-socket-handler.js create mode 100644 server/socket-handlers/docker-socket-handler.js create mode 100644 server/socket-handlers/general-socket-handler.js create mode 100644 server/socket-handlers/maintenance-socket-handler.js create mode 100644 server/socket-handlers/proxy-socket-handler.js create mode 100644 server/socket-handlers/remote-browser-socket-handler.js create mode 100644 server/socket-handlers/status-page-socket-handler.js create mode 100644 server/uptime-calculator.js create mode 100644 server/uptime-kuma-server.js create mode 100644 server/util-server.js create mode 100644 server/utils/array-with-key.js create mode 100644 server/utils/knex/lib/dialects/mysql2/schema/mysql2-columncompiler.js create mode 100644 server/utils/limit-queue.js create mode 100644 server/utils/simple-migration-server.js create mode 100644 src/App.vue create mode 100644 src/assets/app.scss create mode 100644 src/assets/localization.scss create mode 100644 src/assets/multiselect.scss create mode 100644 src/assets/vars.scss create mode 100644 src/assets/vue-datepicker.scss create mode 100644 src/components/APIKeyDialog.vue create mode 100644 src/components/ActionInput.vue create mode 100644 src/components/ActionSelect.vue create mode 100644 src/components/BadgeGeneratorDialog.vue create mode 100644 src/components/CertificateInfo.vue create mode 100644 src/components/CertificateInfoRow.vue create mode 100644 src/components/Confirm.vue create mode 100644 src/components/CopyableInput.vue create mode 100644 src/components/CountUp.vue create mode 100644 src/components/CreateGroupDialog.vue create mode 100644 src/components/Datetime.vue create mode 100644 src/components/DockerHostDialog.vue create mode 100644 src/components/EditMonitorCondition.vue create mode 100644 src/components/EditMonitorConditionGroup.vue create mode 100644 src/components/EditMonitorConditions.vue create mode 100644 src/components/HeartbeatBar.vue create mode 100644 src/components/HiddenInput.vue create mode 100644 src/components/Login.vue create mode 100644 src/components/MaintenanceTime.vue create mode 100644 src/components/MonitorList.vue create mode 100644 src/components/MonitorListFilter.vue create mode 100644 src/components/MonitorListFilterDropdown.vue create mode 100644 src/components/MonitorListItem.vue create mode 100644 src/components/MonitorSettingDialog.vue create mode 100644 src/components/NotificationDialog.vue create mode 100644 src/components/PingChart.vue create mode 100644 src/components/ProxyDialog.vue create mode 100644 src/components/PublicGroupList.vue create mode 100644 src/components/RemoteBrowserDialog.vue create mode 100644 src/components/ScreenshotDialog.vue create mode 100644 src/components/Status.vue create mode 100644 src/components/Tag.vue create mode 100644 src/components/TagEditDialog.vue create mode 100644 src/components/TagsManager.vue create mode 100644 src/components/ToggleSection.vue create mode 100644 src/components/TwoFADialog.vue create mode 100644 src/components/Uptime.vue create mode 100644 src/components/notifications/46elks.vue create mode 100644 src/components/notifications/AlertNow.vue create mode 100644 src/components/notifications/Alerta.vue create mode 100644 src/components/notifications/AliyunSms.vue create mode 100644 src/components/notifications/Apprise.vue create mode 100644 src/components/notifications/Bark.vue create mode 100644 src/components/notifications/Bitrix24.vue create mode 100644 src/components/notifications/CallMeBot.vue create mode 100644 src/components/notifications/Cellsynt.vue create mode 100644 src/components/notifications/ClickSendSMS.vue create mode 100644 src/components/notifications/DingDing.vue create mode 100644 src/components/notifications/Discord.vue create mode 100644 src/components/notifications/Feishu.vue create mode 100644 src/components/notifications/FlashDuty.vue create mode 100644 src/components/notifications/FreeMobile.vue create mode 100644 src/components/notifications/GoAlert.vue create mode 100644 src/components/notifications/GoogleChat.vue create mode 100644 src/components/notifications/Gorush.vue create mode 100644 src/components/notifications/Gotify.vue create mode 100644 src/components/notifications/GrafanaOncall.vue create mode 100644 src/components/notifications/GtxMessaging.vue create mode 100644 src/components/notifications/HeiiOnCall.vue create mode 100644 src/components/notifications/HomeAssistant.vue create mode 100644 src/components/notifications/Keep.vue create mode 100644 src/components/notifications/Kook.vue create mode 100644 src/components/notifications/Line.vue create mode 100644 src/components/notifications/LineNotify.vue create mode 100644 src/components/notifications/LunaSea.vue create mode 100644 src/components/notifications/Matrix.vue create mode 100644 src/components/notifications/Mattermost.vue create mode 100644 src/components/notifications/Nostr.vue create mode 100644 src/components/notifications/Ntfy.vue create mode 100644 src/components/notifications/Octopush.vue create mode 100644 src/components/notifications/OneBot.vue create mode 100644 src/components/notifications/Onesender.vue create mode 100644 src/components/notifications/Opsgenie.vue create mode 100644 src/components/notifications/PagerDuty.vue create mode 100644 src/components/notifications/PagerTree.vue create mode 100644 src/components/notifications/PromoSMS.vue create mode 100644 src/components/notifications/PushDeer.vue create mode 100644 src/components/notifications/Pushbullet.vue create mode 100644 src/components/notifications/Pushover.vue create mode 100644 src/components/notifications/Pushy.vue create mode 100644 src/components/notifications/RocketChat.vue create mode 100644 src/components/notifications/SIGNL4.vue create mode 100644 src/components/notifications/SMSC.vue create mode 100644 src/components/notifications/SMSEagle.vue create mode 100644 src/components/notifications/SMSManager.vue create mode 100644 src/components/notifications/SMSPartner.vue create mode 100644 src/components/notifications/SMTP.vue create mode 100644 src/components/notifications/SendGrid.vue create mode 100644 src/components/notifications/ServerChan.vue create mode 100644 src/components/notifications/SerwerSMS.vue create mode 100644 src/components/notifications/SevenIO.vue create mode 100644 src/components/notifications/Signal.vue create mode 100644 src/components/notifications/Slack.vue create mode 100644 src/components/notifications/Splunk.vue create mode 100644 src/components/notifications/Squadcast.vue create mode 100644 src/components/notifications/Stackfield.vue create mode 100644 src/components/notifications/Teams.vue create mode 100644 src/components/notifications/TechulusPush.vue create mode 100644 src/components/notifications/Telegram.vue create mode 100644 src/components/notifications/Threema.vue create mode 100644 src/components/notifications/Twilio.vue create mode 100644 src/components/notifications/WPush.vue create mode 100644 src/components/notifications/WeCom.vue create mode 100644 src/components/notifications/Webhook.vue create mode 100644 src/components/notifications/Whapi.vue create mode 100644 src/components/notifications/ZohoCliq.vue create mode 100644 src/components/notifications/index.js create mode 100644 src/components/settings/APIKeys.vue create mode 100644 src/components/settings/About.vue create mode 100644 src/components/settings/Appearance.vue create mode 100644 src/components/settings/Docker.vue create mode 100644 src/components/settings/General.vue create mode 100644 src/components/settings/MonitorHistory.vue create mode 100644 src/components/settings/Notifications.vue create mode 100644 src/components/settings/Proxies.vue create mode 100644 src/components/settings/RemoteBrowsers.vue create mode 100644 src/components/settings/ReverseProxy.vue create mode 100644 src/components/settings/Security.vue create mode 100644 src/components/settings/Tags.vue create mode 100644 src/i18n.js create mode 100644 src/icon.js create mode 100644 src/lang/README.md create mode 100644 src/lang/ab.json create mode 100644 src/lang/af.json create mode 100644 src/lang/ar-SY.json create mode 100644 src/lang/ar.json create mode 100644 src/lang/bar.json create mode 100644 src/lang/be.json create mode 100644 src/lang/bg-BG.json create mode 100644 src/lang/bn.json create mode 100644 src/lang/ca.json create mode 100644 src/lang/ckb.json create mode 100644 src/lang/cs-CZ.json create mode 100644 src/lang/da-DK.json create mode 100644 src/lang/de-CH.json create mode 100644 src/lang/de-DE.json create mode 100644 src/lang/el-GR.json create mode 100644 src/lang/en.json create mode 100644 src/lang/enm.json create mode 100644 src/lang/es-ES.json create mode 100644 src/lang/et-EE.json create mode 100644 src/lang/eu.json create mode 100644 src/lang/fa.json create mode 100644 src/lang/fi.json create mode 100644 src/lang/fr-FR.json create mode 100644 src/lang/ga.json create mode 100644 src/lang/gl.json create mode 100644 src/lang/he-IL.json create mode 100644 src/lang/he.json create mode 100644 src/lang/hi.json create mode 100644 src/lang/hr-HR.json create mode 100644 src/lang/hu.json create mode 100644 src/lang/id-ID.json create mode 100644 src/lang/it-IT.json create mode 100644 src/lang/ja.json create mode 100644 src/lang/ka.json create mode 100644 src/lang/ko-KR.json create mode 100644 src/lang/lt.json create mode 100644 src/lang/lzh.json create mode 100644 src/lang/mk.json create mode 100644 src/lang/ml.json create mode 100644 src/lang/ms.json create mode 100644 src/lang/my.json create mode 100644 src/lang/nb-NO.json create mode 100644 src/lang/nl-NL.json create mode 100644 src/lang/pa.json create mode 100644 src/lang/pa_PK.json create mode 100644 src/lang/pl.json create mode 100644 src/lang/pt-BR.json create mode 100644 src/lang/pt-PT.json create mode 100644 src/lang/pt.json create mode 100644 src/lang/ro.json create mode 100644 src/lang/ru-RU.json create mode 100644 src/lang/sk.json create mode 100644 src/lang/sl-SI.json create mode 100644 src/lang/sq.json create mode 100644 src/lang/sr-latn.json create mode 100644 src/lang/sr.json create mode 100644 src/lang/sv-SE.json create mode 100644 src/lang/te.json create mode 100644 src/lang/th-TH.json create mode 100644 src/lang/tr-TR.json create mode 100644 src/lang/ug.json create mode 100644 src/lang/uk-UA.json create mode 100644 src/lang/ur.json create mode 100644 src/lang/uz.json create mode 100644 src/lang/vi-VN.json create mode 100644 src/lang/xh.json create mode 100644 src/lang/yue.json create mode 100644 src/lang/zh-CN.json create mode 100644 src/lang/zh-HK.json create mode 100644 src/lang/zh-TW.json create mode 100644 src/layouts/EmptyLayout.vue create mode 100644 src/layouts/Layout.vue create mode 100644 src/main.js create mode 100644 src/mixins/datetime.js create mode 100644 src/mixins/lang.js create mode 100644 src/mixins/mobile.js create mode 100644 src/mixins/public.js create mode 100644 src/mixins/socket.js create mode 100644 src/mixins/theme.js create mode 100644 src/modules/dayjs/constant.js create mode 100644 src/modules/dayjs/plugin/timezone/index.d.ts create mode 100644 src/modules/dayjs/plugin/timezone/index.js create mode 100644 src/pages/AddStatusPage.vue create mode 100644 src/pages/Dashboard.vue create mode 100644 src/pages/DashboardHome.vue create mode 100644 src/pages/Details.vue create mode 100644 src/pages/EditMaintenance.vue create mode 100644 src/pages/EditMonitor.vue create mode 100644 src/pages/Entry.vue create mode 100644 src/pages/List.vue create mode 100644 src/pages/MaintenanceDetails.vue create mode 100644 src/pages/ManageMaintenance.vue create mode 100644 src/pages/ManageStatusPage.vue create mode 100644 src/pages/NotFound.vue create mode 100644 src/pages/Settings.vue create mode 100644 src/pages/Setup.vue create mode 100644 src/pages/SetupDatabase.vue create mode 100644 src/pages/StatusPage.vue create mode 100644 src/router.js create mode 100644 src/util-frontend.js create mode 100644 src/util.js create mode 100644 src/util.ts create mode 100644 test/backend-test/README.md create mode 100644 test/backend-test/monitor-conditions/test-evaluator.js create mode 100644 test/backend-test/monitor-conditions/test-expressions.js create mode 100644 test/backend-test/monitor-conditions/test-operators.js create mode 100644 test/backend-test/test-mqtt.js create mode 100644 test/backend-test/test-rabbitmq.js create mode 100644 test/backend-test/test-uptime-calculator.js create mode 100644 test/e2e/specs/example.spec.js create mode 100644 test/e2e/specs/monitor-form.spec.js create mode 100644 test/e2e/specs/setup-process.once.js create mode 100644 test/e2e/specs/status-page.spec.js create mode 100644 test/e2e/util-test.js create mode 100644 test/prepare-test-server.js create mode 100644 test/test-radius.dockerfile create mode 100644 tsconfig.json diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5db08b7 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,55 @@ +/.idea +/node_modules +/data* +/out +/test +/kubernetes +/.do +**/.dockerignore +/private +**/.git +**/.gitignore +**/docker-compose* +**/[Dd]ockerfile* +LICENSE +README.md +.editorconfig +.vscode +.eslint* +.stylelint* +/.github +yarn.lock +app.json +CODE_OF_CONDUCT.md +CONTRIBUTING.md +CNAME +install.sh +SECURITY.md +tsconfig.json +.env +/tmp +/ecosystem.config.js +/extra/healthcheck.exe +/extra/healthcheck +/extra/exe-builder +/extra/push-examples +/extra/uptime-kuma-push + +# Comment the following line if you want to rebuild the healthcheck binary +/extra/healthcheck-armv7 + + +### .gitignore content (commented rules are duplicated) + +#node_modules +.DS_Store +#dist +dist-ssr +*.local +#.idea + +#/data +#!/data/.gitkeep +#.vscode + +### End of .gitignore content diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..47bf476 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,24 @@ +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false + +[*.yaml] +indent_size = 2 + +[*.yml] +indent_size = 2 + +[*.vue] +trim_trailing_whitespace = false + +[*.go] +indent_style = tab diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..5da22e7 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,168 @@ +module.exports = { + ignorePatterns: [ + "test/*.js", + "server/modules/*", + "src/util.js" + ], + root: true, + env: { + browser: true, + commonjs: true, + es2020: true, + node: true, + }, + extends: [ + "eslint:recommended", + "plugin:vue/vue3-recommended", + "plugin:jsdoc/recommended-error", + ], + parser: "vue-eslint-parser", + parserOptions: { + parser: "@typescript-eslint/parser", + sourceType: "module", + requireConfigFile: false, + }, + plugins: [ + "jsdoc", + "@typescript-eslint", + ], + rules: { + "yoda": "error", + eqeqeq: [ "warn", "smart" ], + "linebreak-style": [ "error", "unix" ], + "camelcase": [ "warn", { + "properties": "never", + "ignoreImports": true + }], + "no-unused-vars": [ "warn", { + "args": "none" + }], + indent: [ + "error", + 4, + { + ignoredNodes: [ "TemplateLiteral" ], + SwitchCase: 1, + }, + ], + quotes: [ "error", "double" ], + semi: "error", + "vue/html-indent": [ "error", 4 ], // default: 2 + "vue/max-attributes-per-line": "off", + "vue/singleline-html-element-content-newline": "off", + "vue/html-self-closing": "off", + "vue/require-component-is": "off", // not allow is="style" https://github.com/vuejs/eslint-plugin-vue/issues/462#issuecomment-430234675 + "vue/attribute-hyphenation": "off", // This change noNL to "no-n-l" unexpectedly + "vue/multi-word-component-names": "off", + "no-multi-spaces": [ "error", { + ignoreEOLComments: true, + }], + "array-bracket-spacing": [ "warn", "always", { + "singleValue": true, + "objectsInArrays": false, + "arraysInArrays": false + }], + "space-before-function-paren": [ "error", { + "anonymous": "always", + "named": "never", + "asyncArrow": "always" + }], + "curly": "error", + "object-curly-spacing": [ "error", "always" ], + "object-curly-newline": "off", + "object-property-newline": "error", + "comma-spacing": "error", + "brace-style": "error", + "no-var": "error", + "key-spacing": "warn", + "keyword-spacing": "warn", + "space-infix-ops": "error", + "arrow-spacing": "warn", + "no-trailing-spaces": "error", + "no-constant-condition": [ "error", { + "checkLoops": false, + }], + "space-before-blocks": "warn", + //"no-console": "warn", + "no-extra-boolean-cast": "off", + "no-multiple-empty-lines": [ "warn", { + "max": 1, + "maxBOF": 0, + }], + "lines-between-class-members": [ "warn", "always", { + exceptAfterSingleLine: true, + }], + "no-unneeded-ternary": "error", + "array-bracket-newline": [ "error", "consistent" ], + "eol-last": [ "error", "always" ], + //"prefer-template": "error", + "template-curly-spacing": [ "warn", "never" ], + "comma-dangle": [ "warn", "only-multiline" ], + "no-empty": [ "error", { + "allowEmptyCatch": true + }], + "no-control-regex": "off", + "one-var": [ "error", "never" ], + "max-statements-per-line": [ "error", { "max": 1 }], + "jsdoc/check-tag-names": [ + "error", + { + "definedTags": [ "link" ] + } + ], + "jsdoc/no-undefined-types": "off", + "jsdoc/no-defaults": [ + "error", + { "noOptionalParamNames": true } + ], + "jsdoc/require-throws": "warn", + "jsdoc/require-jsdoc": [ + "error", + { + "require": { + "FunctionDeclaration": true, + "MethodDefinition": true, + } + } + ], + "jsdoc/no-blank-block-descriptions": "error", + "jsdoc/require-returns-description": "warn", + "jsdoc/require-returns-check": [ + "error", + { "reportMissingReturnForUndefinedTypes": false } + ], + "jsdoc/require-returns": [ + "warn", + { + "forceRequireReturn": true, + "forceReturnsWithAsync": true + } + ], + "jsdoc/require-param-type": "warn", + "jsdoc/require-param-description": "warn" + }, + "overrides": [ + { + "files": [ "src/languages/*.js", "src/icon.js" ], + "rules": { + "comma-dangle": [ "error", "always-multiline" ], + } + }, + + // Override for TypeScript + { + "files": [ + "**/*.ts", + ], + extends: [ + "plugin:@typescript-eslint/recommended", + ], + "rules": { + "jsdoc/require-returns-type": "off", + "jsdoc/require-param-type": "off", + "@typescript-eslint/no-explicit-any": "off", + "prefer-const": "off", + } + } + ] +}; diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..d55fbd4 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: louislam # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +#patreon: # Replace with a single Patreon username +open_collective: uptime-kuma # Replace with a single Open Collective username +#ko_fi: # Replace with a single Ko-fi username +#tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +#community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +#liberapay: # Replace with a single Liberapay username +#issuehunt: # Replace with a single IssueHunt username +#otechie: # Replace with a single Otechie username +#custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/.github/ISSUE_TEMPLATE/ask-for-help.yaml b/.github/ISSUE_TEMPLATE/ask-for-help.yaml new file mode 100644 index 0000000..a708dbf --- /dev/null +++ b/.github/ISSUE_TEMPLATE/ask-for-help.yaml @@ -0,0 +1,75 @@ +name: "❓ Ask for help" +description: "Submit any question related to Uptime Kuma" +#title: "[Help] " +labels: [help] +body: + - type: checkboxes + id: no-duplicate-issues + attributes: + label: "⚠️ Please verify that this question has NOT been raised before." + description: "Search in the issues sections by clicking [HERE](https://github.com/louislam/uptime-kuma/issues?q=)" + options: + - label: "I checked and didn't find similar issue" + required: true + - type: checkboxes + attributes: + label: "🛡️ Security Policy" + description: Please review the security policy before reporting security related issues/bugs. + options: + - label: I agree to have read this project [Security Policy](https://github.com/louislam/uptime-kuma/security/policy) + required: true + - type: textarea + id: steps-to-reproduce + validations: + required: true + attributes: + label: "📝 Describe your problem" + description: "Please walk us through it step by step. Include all important details and add screenshots where appropriate" + placeholder: "Describe what are you asking for..." + - type: textarea + id: error-msg + validations: + required: false + attributes: + label: "📝 Error Message(s) or Log" + - type: input + id: uptime-kuma-version + attributes: + label: "🐻 Uptime-Kuma Version" + description: "Which version of Uptime-Kuma are you running? Please do NOT provide the docker tag such as latest or 1" + placeholder: "Ex. 1.10.0" + validations: + required: true + - type: input + id: operating-system + attributes: + label: "💻 Operating System and Arch" + description: "Which OS is your server/device running on? (For Replit, please do not report this bug)" + placeholder: "Ex. Ubuntu 20.04 x86" + validations: + required: true + - type: input + id: browser-vendor + attributes: + label: "🌐 Browser" + description: "Which browser are you running on? (For Replit, please do not report this bug)" + placeholder: "Ex. Google Chrome 95.0.4638.69" + validations: + required: true + - type: textarea + id: deployment-info + attributes: + label: "🖥️ Deployment Environment" + description: | + examples: + - **Runtime**: Docker 20.10.9 / nodejs 14.18.0 / K8S via ... v1.3.3 / .. + - **Database**: sqlite/embedded mariadb/external mariadb + - **Filesystem used to store the database on**: Windows/ZFS/btrfs/NFSv3 on a SSD/HDD/eMMC + - **number of monitors**: 42 + value: | + - Runtime: + - Database: + - Filesystem used to store the database on: + - number of monitors: + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml new file mode 100644 index 0000000..9745a76 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -0,0 +1,100 @@ +name: "🐛 Bug Report" +description: "Submit a bug report to help us improve" +#title: "[Bug] " +labels: [bug] +body: + - type: textarea + id: related-issues + validations: + required: true + attributes: + label: "📑 I have found these related issues/pull requests" + description: "Search related issues by clicking [HERE](https://github.com/louislam/uptime-kuma/issues?q=) and explain what the difference between them or explain that you are unable to find any related issues" + placeholder: "Related to #1 by also touching the ... system. They should not be merged because ..." + - type: checkboxes + attributes: + label: "🛡️ Security Policy" + description: Please review the security policy before reporting security related issues/bugs. + options: + - label: I agree to have read this project [Security Policy](https://github.com/louislam/uptime-kuma/security/policy) + required: true + - type: textarea + id: description + validations: + required: false + attributes: + label: "Description" + description: "You could also upload screenshots" + - type: textarea + id: steps-to-reproduce + validations: + required: true + attributes: + label: "👟 Reproduction steps" + description: "How do you trigger this bug? Please walk us through it step by step. Include all important details and add screenshots where appropriate" + placeholder: "..." + - type: textarea + id: expected-behavior + validations: + required: true + attributes: + label: "👀 Expected behavior" + description: "What did you think would happen?" + placeholder: "..." + - type: textarea + id: actual-behavior + validations: + required: true + attributes: + label: "😓 Actual Behavior" + description: "What actually happen?" + placeholder: "..." + - type: input + id: uptime-kuma-version + attributes: + label: "🐻 Uptime-Kuma Version" + description: "Which version of Uptime-Kuma are you running? Please do NOT provide the docker tag such as latest or 1" + placeholder: "Ex. 1.10.0" + validations: + required: true + - type: input + id: operating-system + attributes: + label: "💻 Operating System and Arch" + description: "Which OS is your server/device running on? (For Replit, please do not report this bug)" + placeholder: "Ex. Ubuntu 20.04 x64 " + validations: + required: true + - type: input + id: browser-vendor + attributes: + label: "🌐 Browser" + description: "Which browser are you running on?" + placeholder: "Ex. Google Chrome 95.0.4638.69" + validations: + required: true + - type: textarea + id: deployment-info + attributes: + label: "🖥️ Deployment Environment" + description: | + examples: + - **Runtime**: Docker 20.10.9 / nodejs 18.17.1 / K8S via ... v1.3.3 / .. + - **Database**: sqlite/embedded mariadb/external mariadb + - **Filesystem used to store the database on**: Windows/ZFS/btrfs/NFSv3 on a SSD/HDD/eMMC + - **number of monitors**: 42 + value: | + - Runtime: + - Database: + - Filesystem used to store the database on: + - number of monitors: + validations: + required: true + - type: textarea + id: logs + attributes: + label: "📝 Relevant log output" + description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + render: shell + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/feature_request.yaml b/.github/ISSUE_TEMPLATE/feature_request.yaml new file mode 100644 index 0000000..531a2c2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yaml @@ -0,0 +1,66 @@ +name: 🚀 Feature Request +description: "Submit a proposal for a new feature" +#title: "[Feature] " +labels: [feature-request] +body: + - type: textarea + id: related-issues + validations: + required: true + attributes: + label: "📑 I have found these related issues/pull requests" + description: "Search related issues by clicking [HERE](https://github.com/louislam/uptime-kuma/issues?q=) and explain what the difference between them or explain that you are unable to find any related issues" + placeholder: "Related to #1 by also touching the ... system. They should not be merged because ..." + - type: dropdown + id: feature-area + attributes: + label: "🏷️ Feature Request Type" + description: "What kind of feature request is this?" + multiple: true + options: + - API / automation options + - New notification-provider + - Change to existing notification-provider + - New monitor + - Change to existing monitor + - Dashboard + - Status-page + - Maintenance + - Deployment + - Certificate expiry + - Settings + - Other + validations: + required: true + - type: textarea + id: feature-description + validations: + required: true + attributes: + label: "🔖 Feature description" + description: "A clear and concise description of what the feature request is." + placeholder: "You should add ..." + - type: textarea + id: solution + validations: + required: true + attributes: + label: "✔️ Solution" + description: "A clear and concise description of what you want to happen." + placeholder: "In my use-case, ..." + - type: textarea + id: alternatives + validations: + required: false + attributes: + label: "❓ Alternatives" + description: "A clear and concise description of any alternative solutions or features you've considered." + placeholder: "I have considered ..." + - type: textarea + id: additional-context + validations: + required: false + attributes: + label: "📝 Additional Context" + description: "Add any other context or screenshots about the feature request here." + placeholder: "..." diff --git a/.github/ISSUE_TEMPLATE/security.md b/.github/ISSUE_TEMPLATE/security.md new file mode 100644 index 0000000..708670e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/security.md @@ -0,0 +1,17 @@ +--- + +name: "Security Issue" +about: "Just for alerting @louislam, do not provide any details here" +title: "Security Issue" +ref: "main" +labels: + +- security + +--- + +DO NOT PROVIDE ANY DETAILS HERE. Please privately report to https://github.com/louislam/uptime-kuma/security/advisories/new. + +Why need this issue? It is because GitHub Advisory do not send a notification to @louislam, it is a workaround to do so. + +Your GitHub Advisory URL: diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..0dfb5fa --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,33 @@ +⚠️⚠️⚠️ Since we do not accept all types of pull requests and do not want to waste your time. Please be sure that you have read pull request rules: +https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md#can-i-create-a-pull-request-for-uptime-kuma + +Tick the checkbox if you understand [x]: +- [ ] I have read and understand the pull request rules. + +# Description + +Fixes #(issue) + +## Type of change + +Please delete any options that are not relevant. + +- Bug fix (non-breaking change which fixes an issue) +- User interface (UI) +- New feature (non-breaking change which adds functionality) +- Breaking change (a fix or feature that would cause existing functionality to not work as expected) +- Other +- This change requires a documentation update + +## Checklist + +- [ ] My code follows the style guidelines of this project +- [ ] I ran ESLint and other linters for modified files +- [ ] I have performed a self-review of my own code and tested it +- [ ] I have commented my code, particularly in hard-to-understand areas (including JSDoc for methods) +- [ ] My changes generates no new warnings +- [ ] 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 or drag and drop the image here, and it will be uploaded automatically. diff --git a/.github/config/exclude.txt b/.github/config/exclude.txt new file mode 100644 index 0000000..2532588 --- /dev/null +++ b/.github/config/exclude.txt @@ -0,0 +1 @@ +# This is a .gitignore style file for 'GrantBirki/json-yaml-validate' Action workflow diff --git a/.github/workflows/auto-test.yml b/.github/workflows/auto-test.yml new file mode 100644 index 0000000..bf76d9e --- /dev/null +++ b/.github/workflows/auto-test.yml @@ -0,0 +1,93 @@ +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Auto Test + +on: + push: + branches: [ master, 1.23.X ] + paths-ignore: + - '*.md' + pull_request: + branches: [ master, 1.23.X ] + paths-ignore: + - '*.md' + +jobs: + auto-test: + needs: [ check-linters ] + runs-on: ${{ matrix.os }} + timeout-minutes: 15 + + strategy: + matrix: + os: [macos-latest, ubuntu-latest, windows-latest, ARM64] + node: [ 18, 20 ] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - run: git config --global core.autocrlf false # Mainly for Windows + - uses: actions/checkout@v4 + + - name: Use Node.js ${{ matrix.node }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node }} + - run: npm install + - run: npm run build + - run: npm run test-backend + env: + HEADLESS_TEST: 1 + JUST_FOR_TEST: ${{ secrets.JUST_FOR_TEST }} + + # As a lot of dev dependencies are not supported on ARMv7, we have to test it separately and just test if `npm ci --production` works + armv7-simple-test: + needs: [ ] + runs-on: ${{ matrix.os }} + timeout-minutes: 15 + if: ${{ github.repository == 'louislam/uptime-kuma' }} + strategy: + matrix: + os: [ ARMv7 ] + node: [ 18, 20 ] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - run: git config --global core.autocrlf false # Mainly for Windows + - uses: actions/checkout@v4 + + - name: Use Node.js ${{ matrix.node }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node }} + - run: npm ci --production + + check-linters: + runs-on: ubuntu-latest + + steps: + - run: git config --global core.autocrlf false # Mainly for Windows + - uses: actions/checkout@v4 + + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + - run: npm install + - run: npm run lint:prod + + e2e-test: + needs: [ ] + runs-on: ARM64 + steps: + - run: git config --global core.autocrlf false # Mainly for Windows + - uses: actions/checkout@v4 + + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + - run: npm install + - run: npx playwright install + - run: npm run build + - run: npm run test-e2e diff --git a/.github/workflows/close-incorrect-issue.yml b/.github/workflows/close-incorrect-issue.yml new file mode 100644 index 0000000..3ef5ba3 --- /dev/null +++ b/.github/workflows/close-incorrect-issue.yml @@ -0,0 +1,25 @@ +name: Close Incorrect Issue + +on: + issues: + types: [opened] + +jobs: + close-incorrect-issue: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ubuntu-latest] + node-version: [18] + + steps: + - uses: actions/checkout@v4 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm ci + - run: node extra/close-incorrect-issue.js ${{ secrets.GITHUB_TOKEN }} ${{ github.event.issue.number }} ${{ github.event.issue.user.login }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..0e3b72c --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,43 @@ +name: "CodeQL" + +on: + push: + branches: [ "master", "1.23.X"] + pull_request: + branches: [ "master", "1.23.X"] + schedule: + - cron: '16 22 * * 0' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + timeout-minutes: 360 + + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'go', 'javascript-typescript' ] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/conflict_labeler.yml b/.github/workflows/conflict_labeler.yml new file mode 100644 index 0000000..fdcc9c5 --- /dev/null +++ b/.github/workflows/conflict_labeler.yml @@ -0,0 +1,25 @@ +name: Merge Conflict Labeler + +on: + push: + branches: + - master + pull_request_target: + branches: + - master + types: [synchronize] + +jobs: + label: + name: Labeling + runs-on: ubuntu-latest + if: ${{ github.repository == 'louislam/uptime-kuma' }} + permissions: + contents: read + pull-requests: write + steps: + - name: Apply label + uses: eps1lon/actions-label-merge-conflict@v3 + with: + dirtyLabel: 'needs:resolve-merge-conflict' + repoToken: '${{ secrets.GITHUB_TOKEN }}' diff --git a/.github/workflows/prevent-file-change.yml b/.github/workflows/prevent-file-change.yml new file mode 100644 index 0000000..0af3a6c --- /dev/null +++ b/.github/workflows/prevent-file-change.yml @@ -0,0 +1,17 @@ +name: prevent-file-change + +on: + pull_request: + +jobs: + check-file-changes: + runs-on: ubuntu-latest + steps: + - name: Prevent file change + uses: xalvarez/prevent-file-change-action@v1 + with: + githubToken: ${{ secrets.GITHUB_TOKEN }} + # Regex, /src/lang/*.json is not allowed to be changed, except for /src/lang/en.json + pattern: '^(?!src/lang/en\.json$)src/lang/.*\.json$' + trustedAuthors: UptimeKumaBot + diff --git a/.github/workflows/stale-bot.yml b/.github/workflows/stale-bot.yml new file mode 100644 index 0000000..60eca64 --- /dev/null +++ b/.github/workflows/stale-bot.yml @@ -0,0 +1,42 @@ +name: 'Automatically close stale issues' +on: + workflow_dispatch: + schedule: + - cron: '0 */6 * * *' +#Run every 6 hours + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v9 + with: + stale-issue-message: |- + We are clearing up our old `help`-issues and your issue has been open for 60 days with no activity. + If no comment is made and the stale label is not removed, this issue will be closed in 7 days. + days-before-stale: 60 + days-before-close: 7 + days-before-pr-stale: -1 + days-before-pr-close: -1 + exempt-issue-labels: 'News,Medium,High,discussion,bug,doc,feature-request' + exempt-issue-assignees: 'louislam' + operations-per-run: 200 + - uses: actions/stale@v9 + with: + stale-issue-message: |- + This issue was marked as `cannot-reproduce` by a maintainer. + If an issue is non-reproducible, we cannot fix it, as we do not know what the underlying issue is. + If you have any ideas how we can reproduce this issue, we would love to hear them. + + We don't have a good way to deal with truely unreproducible issues and are going to close this issue in a month. + If think there might be other differences in our environment or in how we tried to reproduce this, we would appreciate any ideas. + close-issue-message: |- + This issue will be closed as no way to reproduce it has been found. + If you/somebody finds a way how to (semi-reliably) reproduce this, we can reopen this issue. ^^ + days-before-stale: 180 + days-before-close: 30 + days-before-pr-stale: -1 + days-before-pr-close: -1 + any-of-issue-labels: 'cannot-reproduce' + operations-per-run: 200 + diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml new file mode 100644 index 0000000..7e631cc --- /dev/null +++ b/.github/workflows/validate.yml @@ -0,0 +1,43 @@ +name: validate +on: + push: + branches: + - master + pull_request: + branches: + - master + - 1.23.X + workflow_dispatch: + +permissions: + contents: read + pull-requests: write # enable write permissions for pull request comments + +jobs: + json-yaml-validate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: json-yaml-validate + id: json-yaml-validate + uses: GrantBirki/json-yaml-validate@v2.4.0 + with: + comment: "true" # enable comment mode + exclude_file: ".github/config/exclude.txt" # gitignore style file for exclusions + + # General validations + validate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Validate language JSON files + run: node ./extra/check-lang-json.js + + - name: Validate knex migrations filename + run: node ./extra/check-knex-filenames.mjs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b11a793 --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +node_modules +.DS_Store +dist +dist-ssr +*.local +.idea + +/data +!/data/.gitkeep +/data* +.vscode + +/private +/out +/tmp +.env + +/extra/healthcheck.exe +/extra/healthcheck +/extra/healthcheck-armv7 + +extra/exe-builder/bin +extra/exe-builder/obj + +.vs +.vscode diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..521a9f7 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +legacy-peer-deps=true diff --git a/.stylelintrc b/.stylelintrc new file mode 100644 index 0000000..0bcdb7c --- /dev/null +++ b/.stylelintrc @@ -0,0 +1,16 @@ +{ + "extends": "stylelint-config-standard", + "customSyntax": "postcss-html", + "rules": { + "indentation": 4, + "no-descending-specificity": null, + "selector-list-comma-newline-after": null, + "declaration-empty-line-before": null, + "alpha-value-notation": "number", + "color-function-notation": "legacy", + "shorthand-property-no-redundant-values": null, + "color-hex-length": null, + "declaration-block-no-redundant-longhand-properties": null, + "at-rule-no-unknown": null + } +} diff --git a/CNAME b/CNAME new file mode 100644 index 0000000..4425051 --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +git.kuma.pet diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..746334e --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,128 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +uptime@kuma.pet. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at +https://www.contributor-covenant.org/translations. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..2e10be4 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,512 @@ +# Project Info + +First of all, I want to thank everyone who has submitted issues or shared pull requests for Uptime Kuma. +I never thought the GitHub community would be so nice! +Because of this, I also never thought that other people would actually read and edit my code. +Parts of the code are not very well-structured or commented, sorry about that. + +The project was created with `vite.js` and is written in `vue3`. +Our backend lives in the `server`-directory and mostly communicates via websockets. +Both frontend and backend share the same `package.json`. + +For production, the frontend is built into the `dist`-directory and the server (`express.js`) exposes the `dist` directory as the root of the endpoint. +For development, we run vite in development mode on another port. + +## Directories + +- `config` (dev config files) +- `data` (App data) +- `db` (Base database and migration scripts) +- `dist` (Frontend build) +- `docker` (Dockerfiles) +- `extra` (Extra useful scripts) +- `public` (Frontend resources for dev only) +- `server` (Server source code) +- `src` (Frontend source code) +- `test` (unit test) + +## Can I create a pull request for Uptime Kuma? + +Yes or no, it depends on what you will try to do. +Both yours and our maintainers' time is precious, and we don't want to waste either. + +If you have any questions about any process/.. is not clear, you are likely not alone => please ask them ^^ + +Different guidelines exist for different types of pull requests (PRs): +-
security fixes +

+ + Submitting security fixes is something that may put the community at risk. + Please read through our [security policy](SECURITY.md) and submit vulnerabilities via an [advisory](https://github.com/louislam/uptime-kuma/security/advisories/new) + [issue](https://github.com/louislam/uptime-kuma/issues/new?assignees=&labels=help&template=security.md) instead. + We encourage you to submit how to fix a vulnerability if you know how to, this is not required. + Following the security policy allows us to properly test, fix bugs. + This review allows us to notice, if there are any changes necessary to unrelated parts like the documentation. + [**PLEASE SEE OUR SECURITY POLICY.**](SECURITY.md) + +

+
+-
small, non-breaking bug fixes +

+ + If you come across a bug and think you can solve, we appreciate your work. + Please make sure that you follow these rules: + - keep the PR as small as possible, fix only one thing at a time => keeping it reviewable + - test that your code does what you claim it does. + + Because maintainer time is precious, junior maintainers may merge uncontroversial PRs in this area. +

+
+-
translations / internationalisation (i18n) +

+ + We use weblate to localise this project into many languages. + If you are unhappy with a translation this is the best start. + On how to translate using weblate, please see [these instructions](https://github.com/louislam/uptime-kuma/blob/master/src/lang/README.md). + + There are two cases in which a change cannot be done in weblate and requires a PR: + - A text may not be currently localisable. In this case, **adding a new language key** via `$t("languageKey")` might be nessesary + - language keys need to be **added to `en.json`** to be visible in weblate. If this has not happened, a PR is appreciated. + - **Adding a new language** requires a new file see [these instructions](https://github.com/louislam/uptime-kuma/blob/master/src/lang/README.md) + + Because maintainer time is precious, junior maintainers may merge uncontroversial PRs in this area. +

+
+-
new notification providers +

+ + To set up a new notification provider these files need to be modified/created: + - `server/notification-providers/PROVIDER_NAME.js` is where the heart of the notification provider lives. + - Both `monitorJSON` and `heartbeatJSON` can be `null` for some events. + If both are `null`, this is a general testing message, but if just `heartbeatJSON` is `null` this is a certificate expiry. + - Please wrap the axios call into a + ```js + try { + let result = await axios.post(...); + if (result.status === ...) ... + } catch (error) { + this.throwGeneralAxiosError(error); + } + ``` + - `server/notification.js` is where the backend of the notification provider needs to be registered. + *If you have an idea how we can skip this step, we would love to hear about it ^^* + - `src/components/NotificationDialog.vue` you need to decide if the provider is a regional or a global one and add it with a name to the respective list + - `src/components/notifications/PROVIDER_NAME.vue` is where the frontend of each provider lives. + Please make sure that you have: + - used `HiddenInput` for secret credentials + - included all the necessary helptexts/placeholder/.. to make sure the notification provider is simple to setup for new users. + - include all translations (`{{ $t("Translation key") }}`, [`i18n-t keypath="Translation key">`](https://vue-i18n.intlify.dev/guide/advanced/component.html)) in `src/lang/en.json` to enable our translators to translate this + - `src/components/notifications/index.js` is where the frontend of the provider needs to be registered. + *If you have an idea how we can skip this step, we would love to hear about it ^^* + + Offering notifications is close to the core of what we are as an uptime monitor. + Therefore, making sure that they work is also really important. + Because testing notification providers is quite time intensive, we mostly offload this onto the person contributing a notification provider. + + To make sure you have tested the notification provider, please include screenshots of the following events in the pull-request description: + - `UP`/`DOWN` + - Certificate Expiry via https://expired.badssl.com/ + - Testing (the test button on the notification provider setup page) + + Using the following way to format this is encouraged: + ```md + | Event | Before | After | + ------------------ + | `UP` | paste-image-here | paste-image-here | + | `DOWN` | paste-image-here | paste-image-here | + | Certificate-expiry | paste-image-here | paste-image-here | + | Testing | paste-image-here | paste-image-here | + ``` + + Because maintainer time is precious, junior maintainers may merge uncontroversial PRs in this area. +

+
+-
new monitoring types +

+ + To set up a new notification provider these files need to be modified/created: + - `server/monitor-types/MONITORING_TYPE.js` is the core of each monitor. + the `async check(...)`-function should: + - throw an error for each fault that is detected with an actionable error message + - in the happy-path, you should set `heartbeat.msg` to a successful message and set `heartbeat.status = UP` + - `server/uptime-kuma-server.js` is where the monitoring backend needs to be registered. + *If you have an idea how we can skip this step, we would love to hear about it ^^* + - `src/pages/EditMonitor.vue` is the shared frontend users interact with. + Please make sure that you have: + - used `HiddenInput` for secret credentials + - included all the necessary helptexts/placeholder/.. to make sure the notification provider is simple to setup for new users. + - include all translations (`{{ $t("Translation key") }}`, [`i18n-t keypath="Translation key">`](https://vue-i18n.intlify.dev/guide/advanced/component.html)) in `src/lang/en.json` to enable our translators to translate this + - + + + Because maintainer time is precious, junior maintainers may merge uncontroversial PRs in this area. +

+
+-
new features/ major changes / breaking bugfixes +

+ + be sure to **create an empty draft pull request or open an issue, so we can have a discussion first**. + This is especially important for a large pull request or when you don't know if it will be merged or not. + + Because of the large impact of this work, only senior maintainers may merge PRs in this area. +

+
+ +The following rules are essential for making your PR mergable: +- Merging multiple issues by a huge PR is more difficult to review and causes conflicts with other PRs. Please + - (if possible) **create one PR for one issue** or + - (if not possible) **explain which issues a PR addresses and why this PR should not be broken apart** +- Make sure your **PR passes our continuous integration**. + PRs will not be merged unless all CI-Checks are green. +- **Breaking changes** (unless for a good reason and discussed beforehand) will not get merged / not get merged quickly. + Such changes require a major version release. +- **Test your code** before submitting a PR. + Buggy PRs will not be merged. +- Make sure the **UI/UX is close to Uptime Kuma**. +- **Think about the maintainability**: + Don't add functionality that is completely **out of scope**. + Keep in mind that we need to be able to maintain the functionality. +- Don't modify or delete existing logic without a valid reason. +- Don't convert existing code into other programming languages for no reason. + +I ([@louislam](https://github.com/louislam)) have the final say. +If your pull request does not meet my expectations, I will reject it, no matter how much time you spent on it. +Therefore, it is essential to have a discussion beforehand. + +I will assign your pull request to a [milestone](https://github.com/louislam/uptime-kuma/milestones), if I plan to review and merge it. + +Please don't rush or ask for an ETA. +We have to understand the pull request, make sure it has no breaking changes and stick to the vision of this project, especially for large pull requests. + + +## I'd like to work on an issue. How do I do that? + +We have found that assigning people to issues is management-overhead that we don't need. +A short comment that you want to try your hand at this issue is appreciated to save other devs time. +If you come across any problem during development, feel free to leave a comment with what you are stuck on. + +### Recommended Pull Request Guideline + +Before diving deep into coding, having a discussion first by creating an empty pull request for discussion is preferred. +The rationale behind this is that we can align the direction and scope of the feature to eliminate any conflicts with existing and planned work, and can help by pointing out any potential pitfalls. + +1. Fork the project +2. Clone your fork repo to local +3. Create a new branch +4. Create an empty commit: `git commit -m "" --allow-empty` +5. Push to your fork repo +6. Prepare a pull request: https://github.com/louislam/uptime-kuma/compare +7. Write a proper description. You can mention @louislam in it, so @louislam will get the notification. +8. Create your pull request as a Draft +9. Wait for the discussion + +## Project Styles + +I personally do not like something that requires a lot of configuration before you can finally start the app. +The goal is to make the Uptime Kuma installation as easy as installing a mobile app. + +- Easy to install for non-Docker users + - no native build dependency is needed (for `x86_64`/`armv7`/`arm64`) + - no extra configuration and + - no extra effort required to get it running +- Single container for Docker users + - no complex docker-compose file + - mapping the volume and exposing the port should be the only requirements +- Settings should be configurable in the frontend. Environment variables are discouraged, unless it is related to startup such as `DATA_DIR` +- Easy to use +- The web UI styling should be consistent and nice + +## Coding Styles + +- 4 spaces indentation +- Follow `.editorconfig` +- Follow ESLint +- Methods and functions should be documented with JSDoc + +## Name Conventions + +- Javascript/Typescript: camelCaseType +- SQLite: snake_case (Underscore) +- CSS/SCSS: kebab-case (Dash) + +## Tools + +- [`Node.js`](https://nodejs.org/) >= 18 +- [`npm`](https://www.npmjs.com/) >= 9.3 +- [`git`](https://git-scm.com/) +- IDE that supports [`ESLint`](https://eslint.org/) and EditorConfig (I am using [`IntelliJ IDEA`](https://www.jetbrains.com/idea/)) +- A SQLite GUI tool (f.ex. [`SQLite Expert Personal`](https://www.sqliteexpert.com/download.html) or [`DBeaver Community`](https://dbeaver.io/download/)) + +## Git Branches + +- `master`: 2.X.X development. If you want to add a new feature, your pull request should base on this. +- `1.23.X`: 1.23.X development. If you want to fix a bug for v1 and v2, your pull request should base on this. +- All other branches are unused, outdated or for dev. + +## Install Dependencies for Development + +```bash +npm ci +``` + +## Dev Server + +(2022-04-26 Update) + +We can start the frontend dev server and the backend dev server in one command. + +Port `3000` and port `3001` will be used. + +```bash +npm run dev +``` + +But sometimes you may want to restart the server without restarting the frontend. In that case, you can run these commands in two terminals: + +```bash +npm run start-frontend-dev +npm run start-server-dev +``` + +## Backend Server + +It binds to `0.0.0.0:3001` by default. + +The backend is an `express.js` server with `socket.io` integrated. +It uses `socket.io` to communicate with clients, and most server logic is encapsulated in the `socket.io` handlers. +`express.js` is also used to serve: + +- as an entry point for redirecting to a status page or the dashboard +- the frontend built files (`index.html`, `*.js`, `*.css`, etc.) +- internal APIs of the status page + +### Structure in `/server/` + +- `jobs/` (Jobs that are running in another process) +- `model/` (Object model, auto-mapping to the database table name) +- `modules/` (Modified 3rd-party modules) +- `monitor_types/` (Monitor Types) +- `notification-providers/` (individual notification logic) +- `routers/` (Express Routers) +- `socket-handler/` (Socket.io Handlers) +- `server.js` (Server entry point) +- `uptime-kuma-server.js` (UptimeKumaServer class, main logic should be here, but some still in `server.js`) + +## Frontend Dev Server + +It binds to `0.0.0.0:3000` by default. The frontend dev server is used for development only. + +For production, it is not used. It will be compiled to `dist` directory instead. + +You can use Vue.js devtools Chrome extension for debugging. + +### Build the frontend + +```bash +npm run build +``` + +### Frontend Details + +Uptime Kuma Frontend is a single page application (SPA). Most paths are handled by Vue Router. + +The router is in `src/router.js` + +As you can see, most data in the frontend is stored at the root level, even though you changed the current router to any other pages. + +The data and socket logic are in `src/mixins/socket.js`. + +## Database Migration + +See: https://github.com/louislam/uptime-kuma/tree/master/db/knex_migrations + +## Unit Test + +```bash +npm run build +npm test +``` + +## Dependencies + +Both frontend and backend share the same `package.json`. +However, the frontend dependencies are eventually not used in the production environment, because it is usually also baked into `dist` files. So: + +- Frontend dependencies = "devDependencies" + - Examples: `vue`, `chart.js` +- Backend dependencies = "dependencies" + - Examples: `socket.io`, `sqlite3` +- Development dependencies = "devDependencies" + - Examples: `eslint`, `sass` + +### Update Dependencies + +Since previously updating Vite 2.5.10 to 2.6.0 broke the application completely, from now on, it should update the patch release version only. + +Patch release = the third digit ([Semantic Versioning](https://semver.org/)) + +If for security / bug / other reasons, a library must be updated, breaking changes need to be checked by the person proposing the change. + +## Translations + +Please add **all** the strings which are translatable to `src/lang/en.json` (if translation keys are omitted, they can not be translated.) + +**Don't include any other languages in your initial pull request** (even if this is your mother tongue), to avoid merge-conflicts between weblate and `master`. +The translations can then (after merging a PR into `master`) be translated by awesome people donating their language skills. + +If you want to help by translating Uptime Kuma into your language, please visit the [instructions on how to translate using weblate](https://github.com/louislam/uptime-kuma/blob/master/src/lang/README.md). + +## Spelling & Grammar + +Feel free to correct the grammar in the documentation or code. +My mother language is not English and my grammar is not that great. + +## Wiki + +Since there is no way to make a pull request to the wiki, I have set up another repo to do that. + +https://github.com/louislam/uptime-kuma-wiki + +## Docker + +### Arch + +- amd64 +- arm64 +- armv7 + +### Docker Tags + +#### v2 + +- `2`, `latest-2`: v2 with full features such as Chromium and bundled MariaDB +- `2.x.x` +- `2-slim`: v2 with basic features +- `2.x.x-slim` +- `beta2`: Latest beta build +- `2.x.x-beta.x` +- `nightly2`: Dev build +- `base2`: Basic Debian setup without Uptime Kuma source code (Full features) +- `base2-slim`: Basic Debian setup without Uptime Kuma source code +- `pr-test2`: For testing pull request without setting up a local environment + +#### v1 + +- `1`, `latest`, `1-debian`, `debian`: Latest version of v1 +- `1.x.x`, `1.x.x-debian` +- `1.x.x-beta.x`: Beta build +- `beta`: Latest beta build +- `nightly`: Dev build +- `base-debian`: Basic Debian setup without Uptime Kuma source code +- `pr-test`: For testing pull request without setting up a local environment +- `base-alpine`: (Deprecated) Basic Alpine setup without Uptime Kuma source code +- `1-alpine`, `alpine`: (Deprecated) +- `1.x.x-alpine`: (Deprecated) + +## Maintainer + +Check the latest issues and pull requests: +https://github.com/louislam/uptime-kuma/issues?q=sort%3Aupdated-desc + +### What is a maintainer and what are their roles? + +This project has multiple maintainers who specialise in different areas. +Currently, there are 3 maintainers: + +| Person | Role | Main Area | +|-------------------|-------------------|------------------| +| `@louislam` | senior maintainer | major features | +| `@chakflying` | junior maintainer | fixing bugs | +| `@commanderstorm` | junior maintainer | issue-management | + +### Procedures + +We have a few procedures we follow. These are documented here: +-
Set up a Docker Builder +

+ + - amd64, armv7 using local. + - arm64 using remote arm64 cpu, as the emulator is too slow and can no longer pass the `npm ci` command. + 1. Add the public key to the remote server. + 2. Add the remote context. The remote machine must be arm64 and installed Docker CE. + ``` + docker context create oracle-arm64-jp --docker "host=ssh://root@100.107.174.88" + ``` + 3. Create a new builder. + ``` + docker buildx create --name kuma-builder --platform linux/amd64,linux/arm/v7 + docker buildx use kuma-builder + docker buildx inspect --bootstrap + ``` + 4. Append the remote context to the builder. + ``` + docker buildx create --append --name kuma-builder --platform linux/arm64 oracle-arm64-jp + ``` + 5. Verify the builder and check if the builder is using `kuma-builder`. + ``` + docker buildx inspect kuma-builder + docker buildx ls + ``` +

+
+-
Release +

+ + 1. Draft a release note + 2. Make sure the repo is cleared + 3. If the healthcheck is updated, remember to re-compile it: `npm run build-docker-builder-go` + 4. `npm run release-final` with env vars: `VERSION` and `GITHUB_TOKEN` + 5. Wait until the `Press any key to continue` + 6. `git push` + 7. Publish the release note as `1.X.X` + 8. Press any key to continue + 9. Deploy to the demo server: `npm run deploy-demo-server` + + These Items need to be checked: + + - [ ] Check all tags is fine on https://hub.docker.com/r/louislam/uptime-kuma/tags + - [ ] Try the Docker image with tag 1.X.X (Clean install / amd64 / arm64 / armv7) + - [ ] Try clean installation with Node.js + +

+
+-
Release Beta +

+ + 1. Draft a release note, check `This is a pre-release` + 2. Make sure the repo is cleared + 3. `npm run release-beta` with env vars: `VERSION` and `GITHUB_TOKEN` + 4. Wait until the `Press any key to continue` + 5. Publish the release note as `1.X.X-beta.X` + 6. Press any key to continue + +

+
+-
Release Wiki +

+ + **Setup Repo** + + ```bash + git clone https://github.com/louislam/uptime-kuma-wiki.git + cd uptime-kuma-wiki + git remote add production https://github.com/louislam/uptime-kuma.wiki.git + ``` + + **Push to Production Wiki** + + ```bash + git pull + git push production master + ``` + +

+
+-
Change the base of a pull request such as master to 1.23.X +

+ + ```bash + git rebase --onto + ``` + +

+
diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b811362 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Louis Lam + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..1b4c885 --- /dev/null +++ b/README.md @@ -0,0 +1,195 @@ +
+ +
+ +# Uptime Kuma + +Uptime Kuma is an easy-to-use self-hosted monitoring tool. + + +[![GitHub Sponsors](https://img.shields.io/github/sponsors/louislam?label=GitHub%20Sponsors)](https://github.com/sponsors/louislam) +Translation status + + + + +## 🥔 Live Demo + +Try it! + +Demo Server (Location: Frankfurt - Germany): https://demo.kuma.pet/start-demo + +It is a temporary live demo, all data will be deleted after 10 minutes. Sponsored by [Uptime Kuma Sponsors](https://github.com/louislam/uptime-kuma#%EF%B8%8F-sponsors). + +## ⭐ Features + +- Monitoring uptime for HTTP(s) / TCP / HTTP(s) Keyword / HTTP(s) Json Query / Ping / DNS Record / Push / Steam Game Server / Docker Containers +- Fancy, Reactive, Fast UI/UX +- Notifications via Telegram, Discord, Gotify, Slack, Pushover, Email (SMTP), and [90+ notification services, click here for the full list](https://github.com/louislam/uptime-kuma/tree/master/src/components/notifications) +- 20-second intervals +- [Multi Languages](https://github.com/louislam/uptime-kuma/tree/master/src/lang) +- Multiple status pages +- Map status pages to specific domains +- Ping chart +- Certificate info +- Proxy support +- 2FA support + +## 🔧 How to Install + +### 🐳 Docker + +```bash +docker run -d --restart=always -p 3001:3001 -v uptime-kuma:/app/data --name uptime-kuma louislam/uptime-kuma:1 +``` + +Uptime Kuma is now running on . + +> [!WARNING] +> File Systems like **NFS** (Network File System) are **NOT** supported. Please map to a local directory or volume. + +> [!NOTE] +> If you want to limit exposure to localhost (without exposing port for other users or to use a [reverse proxy](https://github.com/louislam/uptime-kuma/wiki/Reverse-Proxy)), you can expose the port like this: +> +> ```bash +> docker run -d --restart=always -p 127.0.0.1:3001:3001 -v uptime-kuma:/app/data --name uptime-kuma louislam/uptime-kuma:1 +> ``` + +### 💪🏻 Non-Docker + +Requirements: + +- Platform + - ✅ Major Linux distros such as Debian, Ubuntu, CentOS, Fedora and ArchLinux etc. + - ✅ Windows 10 (x64), Windows Server 2012 R2 (x64) or higher + - ❌ Replit / Heroku +- [Node.js](https://nodejs.org/en/download/) 18 / 20.4 +- [npm](https://docs.npmjs.com/cli/) 9 +- [Git](https://git-scm.com/downloads) +- [pm2](https://pm2.keymetrics.io/) - For running Uptime Kuma in the background + +```bash +git clone https://github.com/louislam/uptime-kuma.git +cd uptime-kuma +npm run setup + +# Option 1. Try it +node server/server.js + +# (Recommended) Option 2. Run in the background using PM2 +# Install PM2 if you don't have it: +npm install pm2 -g && pm2 install pm2-logrotate + +# Start Server +pm2 start server/server.js --name uptime-kuma +``` + +Uptime Kuma is now running on http://localhost:3001 + +More useful PM2 Commands + +```bash +# If you want to see the current console output +pm2 monit + +# If you want to add it to startup +pm2 save && pm2 startup +``` + +### Advanced Installation + +If you need more options or need to browse via a reverse proxy, please read: + +https://github.com/louislam/uptime-kuma/wiki/%F0%9F%94%A7-How-to-Install + +## 🆙 How to Update + +Please read: + +https://github.com/louislam/uptime-kuma/wiki/%F0%9F%86%99-How-to-Update + +## 🆕 What's Next? + +I will assign requests/issues to the next milestone. + +https://github.com/louislam/uptime-kuma/milestones + +## ❤️ Sponsors + +Thank you so much! (GitHub Sponsors will be updated manually. OpenCollective sponsors will be updated automatically, the list will be cached by GitHub though. It may need some time to be updated) + + + +## 🖼 More Screenshots + +Light Mode: + + + +Status Page: + + + +Settings Page: + + + +Telegram Notification Sample: + + + +## Motivation + +- I was looking for a self-hosted monitoring tool like "Uptime Robot", but it is hard to find a suitable one. One of the closest ones is statping. Unfortunately, it is not stable and no longer maintained. +- Wanted to build a fancy UI. +- Learn Vue 3 and vite.js. +- Show the power of Bootstrap 5. +- Try to use WebSocket with SPA instead of a REST API. +- Deploy my first Docker image to Docker Hub. + +If you love this project, please consider giving it a ⭐. + +## 🗣️ Discussion / Ask for Help + +⚠️ For any general or technical questions, please don't send me an email, as I am unable to provide support in that manner. I will not respond if you ask questions there. + +I recommend using Google, GitHub Issues, or Uptime Kuma's subreddit for finding answers to your question. If you cannot find the information you need, feel free to ask: + +- [GitHub Issues](https://github.com/louislam/uptime-kuma/issues) +- [Subreddit (r/UptimeKuma)](https://www.reddit.com/r/UptimeKuma/) + +My Reddit account: [u/louislamlam](https://reddit.com/u/louislamlam) +You can mention me if you ask a question on the subreddit. + +## Contributions + +### Create Pull Requests + +We DO NOT accept all types of pull requests and do not want to waste your time. Please be sure that you have read and follow pull request rules: +[CONTRIBUTING.md#can-i-create-a-pull-request-for-uptime-kuma](https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md#can-i-create-a-pull-request-for-uptime-kuma) + +### Test Pull Requests + +There are a lot of pull requests right now, but I don't have time to test them all. + +If you want to help, you can check this: +https://github.com/louislam/uptime-kuma/wiki/Test-Pull-Requests + +### Test Beta Version + +Check out the latest beta release here: https://github.com/louislam/uptime-kuma/releases + +### Bug Reports / Feature Requests + +If you want to report a bug or request a new feature, feel free to open a [new issue](https://github.com/louislam/uptime-kuma/issues). + +### Translations + +If you want to translate Uptime Kuma into your language, please visit [Weblate Readme](https://github.com/louislam/uptime-kuma/blob/master/src/lang/README.md). + +### Spelling & Grammar + +Feel free to correct the grammar in the documentation or code. +My mother language is not English and my grammar is not that great. + + diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..72b4fc0 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,30 @@ +# Security Policy + +## Reporting a Vulnerability + +1. Please report security issues to https://github.com/louislam/uptime-kuma/security/advisories/new. +2. Please also create an empty security issue to alert me, as GitHub Advisories do not send a notification, I probably will miss it without this. https://github.com/louislam/uptime-kuma/issues/new?assignees=&labels=help&template=security.md + +Do not use the public issue tracker or discuss it in public as it will cause more damage. + +## Do you accept other 3rd-party bug bounty platforms? + +At this moment, I DO NOT accept other bug bounty platforms, because I am not familiar with these platforms and someone has tried to send a phishing link to me by doing this already. To minimize my own risk, please report through GitHub Advisories only. I will ignore all 3rd-party bug bounty platforms emails. + +## Supported Versions + +### Uptime Kuma Versions + +You should use or upgrade to the latest version of Uptime Kuma. All `1.X.X` versions are upgradable to the latest version. + +### Upgradable Docker Tags + +| Tag | Supported | +|-|-| +| 1 | :white_check_mark: | +| 1-debian | :white_check_mark: | +| latest | :white_check_mark: | +| debian | :white_check_mark: | +| 1-alpine | ⚠️ Deprecated | +| alpine | ⚠️ Deprecated | +| All other tags | ❌ | diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..004705a --- /dev/null +++ b/compose.yaml @@ -0,0 +1,9 @@ +services: + uptime-kuma: + image: louislam/uptime-kuma:1 + volumes: + - ./data:/app/data + ports: + # : + - 3001:3001 + restart: unless-stopped diff --git a/config/jest-backend.config.js b/config/jest-backend.config.js new file mode 100644 index 0000000..1a88d9a --- /dev/null +++ b/config/jest-backend.config.js @@ -0,0 +1,5 @@ +module.exports = { + "rootDir": "..", + "testRegex": "./test/backend.spec.js", +}; + diff --git a/config/playwright.config.js b/config/playwright.config.js new file mode 100644 index 0000000..5c574ee --- /dev/null +++ b/config/playwright.config.js @@ -0,0 +1,66 @@ +import { defineConfig, devices } from "@playwright/test"; + +const port = 30001; +export const url = `http://localhost:${port}`; + +export default defineConfig({ + // Look for test files in the "tests" directory, relative to this configuration file. + testDir: "../test/e2e/specs", + outputDir: "../private/playwright-test-results", + fullyParallel: false, + locale: "en-US", + + // Fail the build on CI if you accidentally left test.only in the source code. + forbidOnly: !!process.env.CI, + + // Retry on CI only. + retries: process.env.CI ? 2 : 0, + + // Opt out of parallel tests on CI. + workers: 1, + + // Reporter to use + reporter: [ + [ + "html", { + outputFolder: "../private/playwright-report", + open: "never", + } + ], + ], + + use: { + // Base URL to use in actions like `await page.goto('/')`. + baseURL: url, + + // Collect trace when retrying the failed test. + trace: "on-first-retry", + }, + + // Configure projects for major browsers. + projects: [ + { + name: "run-once setup", + testMatch: /setup-process\.once\.js/, + use: { ...devices["Desktop Chrome"] }, + }, + { + name: "specs", + use: { ...devices["Desktop Chrome"] }, + dependencies: [ "run-once setup" ], + }, + /* + { + name: "firefox", + use: { browserName: "firefox" } + },*/ + ], + + // Run your local dev server before starting the tests. + webServer: { + command: `node extra/remove-playwright-test-data.js && cross-env NODE_ENV=development node server/server.js --port=${port} --data-dir=./data/playwright-test`, + url, + reuseExistingServer: false, + cwd: "../", + }, +}); diff --git a/config/vite.config.js b/config/vite.config.js new file mode 100644 index 0000000..7f2dfb6 --- /dev/null +++ b/config/vite.config.js @@ -0,0 +1,55 @@ +import vue from "@vitejs/plugin-vue"; +import { defineConfig } from "vite"; +import visualizer from "rollup-plugin-visualizer"; +import viteCompression from "vite-plugin-compression"; +import VueDevTools from "vite-plugin-vue-devtools"; + +const postCssScss = require("postcss-scss"); +const postcssRTLCSS = require("postcss-rtlcss"); + +const viteCompressionFilter = /\.(js|mjs|json|css|html|svg)$/i; + +// https://vitejs.dev/config/ +export default defineConfig({ + server: { + port: 3000, + }, + define: { + "FRONTEND_VERSION": JSON.stringify(process.env.npm_package_version), + "process.env": {}, + }, + plugins: [ + vue(), + visualizer({ + filename: "tmp/dist-stats.html" + }), + viteCompression({ + algorithm: "gzip", + filter: viteCompressionFilter, + }), + viteCompression({ + algorithm: "brotliCompress", + filter: viteCompressionFilter, + }), + VueDevTools(), + ], + css: { + postcss: { + "parser": postCssScss, + "map": false, + "plugins": [ postcssRTLCSS ] + } + }, + build: { + commonjsOptions: { + include: [ /.js$/ ], + }, + rollupOptions: { + output: { + manualChunks(id, { getModuleInfo, getModuleIds }) { + + } + } + }, + } +}); diff --git a/db/knex_init_db.js b/db/knex_init_db.js new file mode 100644 index 0000000..46bff4b --- /dev/null +++ b/db/knex_init_db.js @@ -0,0 +1,565 @@ +const { R } = require("redbean-node"); +const { log } = require("../src/util"); + +/** + * ⚠️⚠️⚠️⚠️⚠️⚠️ DO NOT ADD ANYTHING HERE! + * IF YOU NEED TO ADD FIELDS, ADD IT TO ./db/knex_migrations + * See ./db/knex_migrations/README.md for more information + * @returns {Promise} + */ +async function createTables() { + log.info("mariadb", "Creating basic tables for MariaDB"); + const knex = R.knex; + + // TODO: Should check later if it is really the final patch sql file. + + // docker_host + await knex.schema.createTable("docker_host", (table) => { + table.increments("id"); + table.integer("user_id").unsigned().notNullable(); + table.string("docker_daemon", 255); + table.string("docker_type", 255); + table.string("name", 255); + }); + + // group + await knex.schema.createTable("group", (table) => { + table.increments("id"); + table.string("name", 255).notNullable(); + table.datetime("created_date").notNullable().defaultTo(knex.fn.now()); + table.boolean("public").notNullable().defaultTo(false); + table.boolean("active").notNullable().defaultTo(true); + table.integer("weight").notNullable().defaultTo(1000); + table.integer("status_page_id").unsigned(); + }); + + // proxy + await knex.schema.createTable("proxy", (table) => { + table.increments("id"); + table.integer("user_id").unsigned().notNullable(); + table.string("protocol", 10).notNullable(); + table.string("host", 255).notNullable(); + table.smallint("port").notNullable(); // TODO: Maybe a issue with MariaDB, need migration to int + table.boolean("auth").notNullable(); + table.string("username", 255).nullable(); + table.string("password", 255).nullable(); + table.boolean("active").notNullable().defaultTo(true); + table.boolean("default").notNullable().defaultTo(false); + table.datetime("created_date").notNullable().defaultTo(knex.fn.now()); + + table.index("user_id", "proxy_user_id"); + }); + + // user + await knex.schema.createTable("user", (table) => { + table.increments("id"); + table.string("username", 255).notNullable().unique().collate("utf8_general_ci"); + table.string("password", 255); + table.boolean("active").notNullable().defaultTo(true); + table.string("timezone", 150); + table.string("twofa_secret", 64); + table.boolean("twofa_status").notNullable().defaultTo(false); + table.string("twofa_last_token", 6); + }); + + // monitor + await knex.schema.createTable("monitor", (table) => { + table.increments("id"); + table.string("name", 150); + table.boolean("active").notNullable().defaultTo(true); + table.integer("user_id").unsigned() + .references("id").inTable("user") + .onDelete("SET NULL") + .onUpdate("CASCADE"); + table.integer("interval").notNullable().defaultTo(20); + table.text("url"); + table.string("type", 20); + table.integer("weight").defaultTo(2000); + table.string("hostname", 255); + table.integer("port"); + table.datetime("created_date").notNullable().defaultTo(knex.fn.now()); + table.string("keyword", 255); + table.integer("maxretries").notNullable().defaultTo(0); + table.boolean("ignore_tls").notNullable().defaultTo(false); + table.boolean("upside_down").notNullable().defaultTo(false); + table.integer("maxredirects").notNullable().defaultTo(10); + table.text("accepted_statuscodes_json").notNullable().defaultTo("[\"200-299\"]"); + table.string("dns_resolve_type", 5); + table.string("dns_resolve_server", 255); + table.string("dns_last_result", 255); + table.integer("retry_interval").notNullable().defaultTo(0); + table.string("push_token", 20).defaultTo(null); + table.text("method").notNullable().defaultTo("GET"); + table.text("body").defaultTo(null); + table.text("headers").defaultTo(null); + table.text("basic_auth_user").defaultTo(null); + table.text("basic_auth_pass").defaultTo(null); + table.integer("docker_host").unsigned() + .references("id").inTable("docker_host"); + table.string("docker_container", 255); + table.integer("proxy_id").unsigned() + .references("id").inTable("proxy"); + table.boolean("expiry_notification").defaultTo(true); + table.text("mqtt_topic"); + table.string("mqtt_success_message", 255); + table.string("mqtt_username", 255); + table.string("mqtt_password", 255); + table.string("database_connection_string", 2000); + table.text("database_query"); + table.string("auth_method", 250); + table.text("auth_domain"); + table.text("auth_workstation"); + table.string("grpc_url", 255).defaultTo(null); + table.text("grpc_protobuf").defaultTo(null); + table.text("grpc_body").defaultTo(null); + table.text("grpc_metadata").defaultTo(null); + table.text("grpc_method").defaultTo(null); + table.text("grpc_service_name").defaultTo(null); + table.boolean("grpc_enable_tls").notNullable().defaultTo(false); + table.string("radius_username", 255); + table.string("radius_password", 255); + table.string("radius_calling_station_id", 50); + table.string("radius_called_station_id", 50); + table.string("radius_secret", 255); + table.integer("resend_interval").notNullable().defaultTo(0); + table.integer("packet_size").notNullable().defaultTo(56); + table.string("game", 255); + }); + + // heartbeat + await knex.schema.createTable("heartbeat", (table) => { + table.increments("id"); + table.boolean("important").notNullable().defaultTo(false); + table.integer("monitor_id").unsigned().notNullable() + .references("id").inTable("monitor") + .onDelete("CASCADE") + .onUpdate("CASCADE"); + table.smallint("status").notNullable(); + + table.text("msg"); + table.datetime("time").notNullable(); + table.integer("ping"); + table.integer("duration").notNullable().defaultTo(0); + table.integer("down_count").notNullable().defaultTo(0); + + table.index("important"); + table.index([ "monitor_id", "time" ], "monitor_time_index"); + table.index("monitor_id"); + table.index([ "monitor_id", "important", "time" ], "monitor_important_time_index"); + }); + + // incident + await knex.schema.createTable("incident", (table) => { + table.increments("id"); + table.string("title", 255).notNullable(); + table.text("content", 255).notNullable(); + table.string("style", 30).notNullable().defaultTo("warning"); + table.datetime("created_date").notNullable().defaultTo(knex.fn.now()); + table.datetime("last_updated_date"); + table.boolean("pin").notNullable().defaultTo(true); + table.boolean("active").notNullable().defaultTo(true); + table.integer("status_page_id").unsigned(); + }); + + // maintenance + await knex.schema.createTable("maintenance", (table) => { + table.increments("id"); + table.string("title", 150).notNullable(); + table.text("description").notNullable(); + table.integer("user_id").unsigned() + .references("id").inTable("user") + .onDelete("SET NULL") + .onUpdate("CASCADE"); + table.boolean("active").notNullable().defaultTo(true); + table.string("strategy", 50).notNullable().defaultTo("single"); + table.datetime("start_date"); + table.datetime("end_date"); + table.time("start_time"); + table.time("end_time"); + table.string("weekdays", 250).defaultTo("[]"); + table.text("days_of_month").defaultTo("[]"); + table.integer("interval_day"); + + table.index("active"); + table.index([ "strategy", "active" ], "manual_active"); + table.index("user_id", "maintenance_user_id"); + }); + + // status_page + await knex.schema.createTable("status_page", (table) => { + table.increments("id"); + table.string("slug", 255).notNullable().unique().collate("utf8_general_ci"); + table.string("title", 255).notNullable(); + table.text("description"); + table.string("icon", 255).notNullable(); + table.string("theme", 30).notNullable(); + table.boolean("published").notNullable().defaultTo(true); + table.boolean("search_engine_index").notNullable().defaultTo(true); + table.boolean("show_tags").notNullable().defaultTo(false); + table.string("password"); + table.datetime("created_date").notNullable().defaultTo(knex.fn.now()); + table.datetime("modified_date").notNullable().defaultTo(knex.fn.now()); + table.text("footer_text"); + table.text("custom_css"); + table.boolean("show_powered_by").notNullable().defaultTo(true); + table.string("google_analytics_tag_id"); + }); + + // maintenance_status_page + await knex.schema.createTable("maintenance_status_page", (table) => { + table.increments("id"); + + table.integer("status_page_id").unsigned().notNullable() + .references("id").inTable("status_page") + .onDelete("CASCADE") + .onUpdate("CASCADE"); + + table.integer("maintenance_id").unsigned().notNullable() + .references("id").inTable("maintenance") + .onDelete("CASCADE") + .onUpdate("CASCADE"); + }); + + // maintenance_timeslot + await knex.schema.createTable("maintenance_timeslot", (table) => { + table.increments("id"); + table.integer("maintenance_id").unsigned().notNullable() + .references("id").inTable("maintenance") + .onDelete("CASCADE") + .onUpdate("CASCADE"); + table.datetime("start_date").notNullable(); + table.datetime("end_date"); + table.boolean("generated_next").defaultTo(false); + + table.index("maintenance_id"); + table.index([ "maintenance_id", "start_date", "end_date" ], "active_timeslot_index"); + table.index("generated_next", "generated_next_index"); + }); + + // monitor_group + await knex.schema.createTable("monitor_group", (table) => { + table.increments("id"); + table.integer("monitor_id").unsigned().notNullable() + .references("id").inTable("monitor") + .onDelete("CASCADE") + .onUpdate("CASCADE"); + table.integer("group_id").unsigned().notNullable() + .references("id").inTable("group") + .onDelete("CASCADE") + .onUpdate("CASCADE"); + table.integer("weight").notNullable().defaultTo(1000); + table.boolean("send_url").notNullable().defaultTo(false); + + table.index([ "monitor_id", "group_id" ], "fk"); + }); + // monitor_maintenance + await knex.schema.createTable("monitor_maintenance", (table) => { + table.increments("id"); + table.integer("monitor_id").unsigned().notNullable() + .references("id").inTable("monitor") + .onDelete("CASCADE") + .onUpdate("CASCADE"); + table.integer("maintenance_id").unsigned().notNullable() + .references("id").inTable("maintenance") + .onDelete("CASCADE") + .onUpdate("CASCADE"); + + table.index("maintenance_id", "maintenance_id_index2"); + table.index("monitor_id", "monitor_id_index"); + }); + + // notification + await knex.schema.createTable("notification", (table) => { + table.increments("id"); + table.string("name", 255); + table.boolean("active").notNullable().defaultTo(true); + table.integer("user_id").unsigned(); + table.boolean("is_default").notNullable().defaultTo(false); + table.text("config", "longtext"); + }); + + // monitor_notification + await knex.schema.createTable("monitor_notification", (table) => { + table.increments("id").unsigned(); // TODO: no auto increment???? + table.integer("monitor_id").unsigned().notNullable() + .references("id").inTable("monitor") + .onDelete("CASCADE") + .onUpdate("CASCADE"); + table.integer("notification_id").unsigned().notNullable() + .references("id").inTable("notification") + .onDelete("CASCADE") + .onUpdate("CASCADE"); + + table.index([ "monitor_id", "notification_id" ], "monitor_notification_index"); + }); + + // tag + await knex.schema.createTable("tag", (table) => { + table.increments("id"); + table.string("name", 255).notNullable(); + table.string("color", 255).notNullable(); + table.datetime("created_date").notNullable().defaultTo(knex.fn.now()); + }); + + // monitor_tag + await knex.schema.createTable("monitor_tag", (table) => { + table.increments("id"); + table.integer("monitor_id").unsigned().notNullable() + .references("id").inTable("monitor") + .onDelete("CASCADE") + .onUpdate("CASCADE"); + table.integer("tag_id").unsigned().notNullable() + .references("id").inTable("tag") + .onDelete("CASCADE") + .onUpdate("CASCADE"); + table.text("value"); + }); + + // monitor_tls_info + await knex.schema.createTable("monitor_tls_info", (table) => { + table.increments("id"); + table.integer("monitor_id").unsigned().notNullable() + .references("id").inTable("monitor") + .onDelete("CASCADE") + .onUpdate("CASCADE"); + table.text("info_json"); + }); + + // notification_sent_history + await knex.schema.createTable("notification_sent_history", (table) => { + table.increments("id"); + table.string("type", 50).notNullable(); + table.integer("monitor_id").unsigned().notNullable(); + table.integer("days").notNullable(); + table.unique([ "type", "monitor_id", "days" ]); + table.index([ "type", "monitor_id", "days" ], "good_index"); + }); + + // setting + await knex.schema.createTable("setting", (table) => { + table.increments("id"); + table.string("key", 200).notNullable().unique().collate("utf8_general_ci"); + table.text("value"); + table.string("type", 20); + }); + + // status_page_cname + await knex.schema.createTable("status_page_cname", (table) => { + table.increments("id"); + table.integer("status_page_id").unsigned() + .references("id").inTable("status_page") + .onDelete("CASCADE") + .onUpdate("CASCADE"); + table.string("domain").notNullable().unique().collate("utf8_general_ci"); + }); + + /********************* + * Converted Patch here + *********************/ + + // 2023-06-30-1348-http-body-encoding.js + // ALTER TABLE monitor ADD http_body_encoding VARCHAR(25); + // UPDATE monitor SET http_body_encoding = 'json' WHERE (type = 'http' or type = 'keyword') AND http_body_encoding IS NULL; + await knex.schema.table("monitor", function (table) { + table.string("http_body_encoding", 25); + }); + + await knex("monitor") + .where(function () { + this.where("type", "http").orWhere("type", "keyword"); + }) + .whereNull("http_body_encoding") + .update({ + http_body_encoding: "json", + }); + + // 2023-06-30-1354-add-description-monitor.js + // ALTER TABLE monitor ADD description TEXT default null; + await knex.schema.table("monitor", function (table) { + table.text("description").defaultTo(null); + }); + + // 2023-06-30-1357-api-key-table.js + /* + CREATE TABLE [api_key] ( + [id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + [key] VARCHAR(255) NOT NULL, + [name] VARCHAR(255) NOT NULL, + [user_id] INTEGER NOT NULL, + [created_date] DATETIME DEFAULT (DATETIME('now')) NOT NULL, + [active] BOOLEAN DEFAULT 1 NOT NULL, + [expires] DATETIME DEFAULT NULL, + CONSTRAINT FK_user FOREIGN KEY ([user_id]) REFERENCES [user]([id]) ON DELETE CASCADE ON UPDATE CASCADE + ); + */ + await knex.schema.createTable("api_key", function (table) { + table.increments("id").primary(); + table.string("key", 255).notNullable(); + table.string("name", 255).notNullable(); + table.integer("user_id").unsigned().notNullable() + .references("id").inTable("user") + .onDelete("CASCADE") + .onUpdate("CASCADE"); + table.dateTime("created_date").defaultTo(knex.fn.now()).notNullable(); + table.boolean("active").defaultTo(1).notNullable(); + table.dateTime("expires").defaultTo(null); + }); + + // 2023-06-30-1400-monitor-tls.js + /* + ALTER TABLE monitor + ADD tls_ca TEXT default null; + + ALTER TABLE monitor + ADD tls_cert TEXT default null; + + ALTER TABLE monitor + ADD tls_key TEXT default null; + */ + await knex.schema.table("monitor", function (table) { + table.text("tls_ca").defaultTo(null); + table.text("tls_cert").defaultTo(null); + table.text("tls_key").defaultTo(null); + }); + + // 2023-06-30-1401-maintenance-cron.js + /* + -- 999 characters. https://stackoverflow.com/questions/46134830/maximum-length-for-cron-job + DROP TABLE maintenance_timeslot; + ALTER TABLE maintenance ADD cron TEXT; + ALTER TABLE maintenance ADD timezone VARCHAR(255); + ALTER TABLE maintenance ADD duration INTEGER; + */ + await knex.schema + .dropTableIfExists("maintenance_timeslot") + .table("maintenance", function (table) { + table.text("cron"); + table.string("timezone", 255); + table.integer("duration"); + }); + + // 2023-06-30-1413-add-parent-monitor.js. + /* + ALTER TABLE monitor + ADD parent INTEGER REFERENCES [monitor] ([id]) ON DELETE SET NULL ON UPDATE CASCADE; + */ + await knex.schema.table("monitor", function (table) { + table.integer("parent").unsigned() + .references("id").inTable("monitor") + .onDelete("SET NULL") + .onUpdate("CASCADE"); + }); + + /* + patch-add-invert-keyword.sql + ALTER TABLE monitor + ADD invert_keyword BOOLEAN default 0 not null; + */ + await knex.schema.table("monitor", function (table) { + table.boolean("invert_keyword").defaultTo(0).notNullable(); + }); + + /* + patch-added-json-query.sql + ALTER TABLE monitor + ADD json_path TEXT; + + ALTER TABLE monitor + ADD expected_value VARCHAR(255); + */ + await knex.schema.table("monitor", function (table) { + table.text("json_path"); + table.string("expected_value", 255); + }); + + /* + patch-added-kafka-producer.sql + + ALTER TABLE monitor + ADD kafka_producer_topic VARCHAR(255); + +ALTER TABLE monitor + ADD kafka_producer_brokers TEXT; + +ALTER TABLE monitor + ADD kafka_producer_ssl INTEGER; + +ALTER TABLE monitor + ADD kafka_producer_allow_auto_topic_creation VARCHAR(255); + +ALTER TABLE monitor + ADD kafka_producer_sasl_options TEXT; + +ALTER TABLE monitor + ADD kafka_producer_message TEXT; + */ + await knex.schema.table("monitor", function (table) { + table.string("kafka_producer_topic", 255); + table.text("kafka_producer_brokers"); + + // patch-fix-kafka-producer-booleans.sql + table.boolean("kafka_producer_ssl").defaultTo(0).notNullable(); + table.boolean("kafka_producer_allow_auto_topic_creation").defaultTo(0).notNullable(); + + table.text("kafka_producer_sasl_options"); + table.text("kafka_producer_message"); + }); + + /* + patch-add-certificate-expiry-status-page.sql + ALTER TABLE status_page + ADD show_certificate_expiry BOOLEAN default 0 NOT NULL; + */ + await knex.schema.table("status_page", function (table) { + table.boolean("show_certificate_expiry").defaultTo(0).notNullable(); + }); + + /* + patch-monitor-oauth-cc.sql + ALTER TABLE monitor + ADD oauth_client_id TEXT default null; + +ALTER TABLE monitor + ADD oauth_client_secret TEXT default null; + +ALTER TABLE monitor + ADD oauth_token_url TEXT default null; + +ALTER TABLE monitor + ADD oauth_scopes TEXT default null; + +ALTER TABLE monitor + ADD oauth_auth_method TEXT default null; + */ + await knex.schema.table("monitor", function (table) { + table.text("oauth_client_id").defaultTo(null); + table.text("oauth_client_secret").defaultTo(null); + table.text("oauth_token_url").defaultTo(null); + table.text("oauth_scopes").defaultTo(null); + table.text("oauth_auth_method").defaultTo(null); + }); + + /* + patch-add-timeout-monitor.sql + ALTER TABLE monitor + ADD timeout DOUBLE default 0 not null; + */ + await knex.schema.table("monitor", function (table) { + table.double("timeout").defaultTo(0).notNullable(); + }); + + /* + patch-add-gamedig-given-port.sql + ALTER TABLE monitor + ADD gamedig_given_port_only BOOLEAN default 1 not null; + */ + await knex.schema.table("monitor", function (table) { + table.boolean("gamedig_given_port_only").defaultTo(1).notNullable(); + }); + + log.info("mariadb", "Created basic tables for MariaDB"); +} + +module.exports = { + createTables, +}; diff --git a/db/knex_migrations/2023-08-16-0000-create-uptime.js b/db/knex_migrations/2023-08-16-0000-create-uptime.js new file mode 100644 index 0000000..ab89931 --- /dev/null +++ b/db/knex_migrations/2023-08-16-0000-create-uptime.js @@ -0,0 +1,41 @@ +exports.up = function (knex) { + return knex.schema + .createTable("stat_minutely", function (table) { + table.increments("id"); + table.comment("This table contains the minutely aggregate statistics for each monitor"); + table.integer("monitor_id").unsigned().notNullable() + .references("id").inTable("monitor") + .onDelete("CASCADE") + .onUpdate("CASCADE"); + table.integer("timestamp") + .notNullable() + .comment("Unix timestamp rounded down to the nearest minute"); + table.float("ping").notNullable().comment("Average ping in milliseconds"); + table.smallint("up").notNullable(); + table.smallint("down").notNullable(); + + table.unique([ "monitor_id", "timestamp" ]); + }) + .createTable("stat_daily", function (table) { + table.increments("id"); + table.comment("This table contains the daily aggregate statistics for each monitor"); + table.integer("monitor_id").unsigned().notNullable() + .references("id").inTable("monitor") + .onDelete("CASCADE") + .onUpdate("CASCADE"); + table.integer("timestamp") + .notNullable() + .comment("Unix timestamp rounded down to the nearest day"); + table.float("ping").notNullable().comment("Average ping in milliseconds"); + table.smallint("up").notNullable(); + table.smallint("down").notNullable(); + + table.unique([ "monitor_id", "timestamp" ]); + }); +}; + +exports.down = function (knex) { + return knex.schema + .dropTable("stat_minutely") + .dropTable("stat_daily"); +}; diff --git a/db/knex_migrations/2023-08-18-0301-heartbeat.js b/db/knex_migrations/2023-08-18-0301-heartbeat.js new file mode 100644 index 0000000..fe4152b --- /dev/null +++ b/db/knex_migrations/2023-08-18-0301-heartbeat.js @@ -0,0 +1,16 @@ +exports.up = function (knex) { + // Add new column heartbeat.end_time + return knex.schema + .alterTable("heartbeat", function (table) { + table.datetime("end_time").nullable().defaultTo(null); + }); + +}; + +exports.down = function (knex) { + // Rename heartbeat.start_time to heartbeat.time + return knex.schema + .alterTable("heartbeat", function (table) { + table.dropColumn("end_time"); + }); +}; diff --git a/db/knex_migrations/2023-09-29-0000-heartbeat-retires.js b/db/knex_migrations/2023-09-29-0000-heartbeat-retires.js new file mode 100644 index 0000000..a6b9c7b --- /dev/null +++ b/db/knex_migrations/2023-09-29-0000-heartbeat-retires.js @@ -0,0 +1,15 @@ +exports.up = function (knex) { + // Add new column heartbeat.retries + return knex.schema + .alterTable("heartbeat", function (table) { + table.integer("retries").notNullable().defaultTo(0); + }); + +}; + +exports.down = function (knex) { + return knex.schema + .alterTable("heartbeat", function (table) { + table.dropColumn("retries"); + }); +}; diff --git a/db/knex_migrations/2023-10-08-0000-mqtt-query.js b/db/knex_migrations/2023-10-08-0000-mqtt-query.js new file mode 100644 index 0000000..f37bab8 --- /dev/null +++ b/db/knex_migrations/2023-10-08-0000-mqtt-query.js @@ -0,0 +1,16 @@ +exports.up = function (knex) { + // Add new column monitor.mqtt_check_type + return knex.schema + .alterTable("monitor", function (table) { + table.string("mqtt_check_type", 255).notNullable().defaultTo("keyword"); + }); + +}; + +exports.down = function (knex) { + // Drop column monitor.mqtt_check_type + return knex.schema + .alterTable("monitor", function (table) { + table.dropColumn("mqtt_check_type"); + }); +}; diff --git a/db/knex_migrations/2023-10-11-1915-push-token-to-32.js b/db/knex_migrations/2023-10-11-1915-push-token-to-32.js new file mode 100644 index 0000000..47e5ac0 --- /dev/null +++ b/db/knex_migrations/2023-10-11-1915-push-token-to-32.js @@ -0,0 +1,14 @@ +exports.up = function (knex) { + // update monitor.push_token to 32 length + return knex.schema + .alterTable("monitor", function (table) { + table.string("push_token", 32).alter(); + }); +}; + +exports.down = function (knex) { + return knex.schema + .alterTable("monitor", function (table) { + table.string("push_token", 20).alter(); + }); +}; diff --git a/db/knex_migrations/2023-10-16-0000-create-remote-browsers.js b/db/knex_migrations/2023-10-16-0000-create-remote-browsers.js new file mode 100644 index 0000000..c720d3f --- /dev/null +++ b/db/knex_migrations/2023-10-16-0000-create-remote-browsers.js @@ -0,0 +1,21 @@ +exports.up = function (knex) { + return knex.schema + .createTable("remote_browser", function (table) { + table.increments("id"); + table.string("name", 255).notNullable(); + table.string("url", 255).notNullable(); + table.integer("user_id").unsigned(); + }).alterTable("monitor", function (table) { + // Add new column monitor.remote_browser + table.integer("remote_browser").nullable().defaultTo(null).unsigned() + .index() + .references("id") + .inTable("remote_browser"); + }); +}; + +exports.down = function (knex) { + return knex.schema.dropTable("remote_browser").alterTable("monitor", function (table) { + table.dropColumn("remote_browser"); + }); +}; diff --git a/db/knex_migrations/2023-12-20-0000-alter-status-page.js b/db/knex_migrations/2023-12-20-0000-alter-status-page.js new file mode 100644 index 0000000..61ef5d6 --- /dev/null +++ b/db/knex_migrations/2023-12-20-0000-alter-status-page.js @@ -0,0 +1,12 @@ +exports.up = function (knex) { + return knex.schema + .alterTable("status_page", function (table) { + table.integer("auto_refresh_interval").defaultTo(300).unsigned(); + }); +}; + +exports.down = function (knex) { + return knex.schema.alterTable("status_page", function (table) { + table.dropColumn("auto_refresh_interval"); + }); +}; diff --git a/db/knex_migrations/2023-12-21-0000-stat-ping-min-max.js b/db/knex_migrations/2023-12-21-0000-stat-ping-min-max.js new file mode 100644 index 0000000..d936ce5 --- /dev/null +++ b/db/knex_migrations/2023-12-21-0000-stat-ping-min-max.js @@ -0,0 +1,24 @@ +exports.up = function (knex) { + return knex.schema + .alterTable("stat_daily", function (table) { + table.float("ping_min").notNullable().defaultTo(0).comment("Minimum ping during this period in milliseconds"); + table.float("ping_max").notNullable().defaultTo(0).comment("Maximum ping during this period in milliseconds"); + }) + .alterTable("stat_minutely", function (table) { + table.float("ping_min").notNullable().defaultTo(0).comment("Minimum ping during this period in milliseconds"); + table.float("ping_max").notNullable().defaultTo(0).comment("Maximum ping during this period in milliseconds"); + }); + +}; + +exports.down = function (knex) { + return knex.schema + .alterTable("stat_daily", function (table) { + table.dropColumn("ping_min"); + table.dropColumn("ping_max"); + }) + .alterTable("stat_minutely", function (table) { + table.dropColumn("ping_min"); + table.dropColumn("ping_max"); + }); +}; diff --git a/db/knex_migrations/2023-12-22-0000-hourly-uptime.js b/db/knex_migrations/2023-12-22-0000-hourly-uptime.js new file mode 100644 index 0000000..4305900 --- /dev/null +++ b/db/knex_migrations/2023-12-22-0000-hourly-uptime.js @@ -0,0 +1,26 @@ +exports.up = function (knex) { + return knex.schema + .createTable("stat_hourly", function (table) { + table.increments("id"); + table.comment("This table contains the hourly aggregate statistics for each monitor"); + table.integer("monitor_id").unsigned().notNullable() + .references("id").inTable("monitor") + .onDelete("CASCADE") + .onUpdate("CASCADE"); + table.integer("timestamp") + .notNullable() + .comment("Unix timestamp rounded down to the nearest hour"); + table.float("ping").notNullable().comment("Average ping in milliseconds"); + table.float("ping_min").notNullable().defaultTo(0).comment("Minimum ping during this period in milliseconds"); + table.float("ping_max").notNullable().defaultTo(0).comment("Maximum ping during this period in milliseconds"); + table.smallint("up").notNullable(); + table.smallint("down").notNullable(); + + table.unique([ "monitor_id", "timestamp" ]); + }); +}; + +exports.down = function (knex) { + return knex.schema + .dropTable("stat_hourly"); +}; diff --git a/db/knex_migrations/2024-01-22-0000-stats-extras.js b/db/knex_migrations/2024-01-22-0000-stats-extras.js new file mode 100644 index 0000000..b92e889 --- /dev/null +++ b/db/knex_migrations/2024-01-22-0000-stats-extras.js @@ -0,0 +1,26 @@ +exports.up = function (knex) { + return knex.schema + .alterTable("stat_daily", function (table) { + table.text("extras").defaultTo(null).comment("Extra statistics during this time period"); + }) + .alterTable("stat_minutely", function (table) { + table.text("extras").defaultTo(null).comment("Extra statistics during this time period"); + }) + .alterTable("stat_hourly", function (table) { + table.text("extras").defaultTo(null).comment("Extra statistics during this time period"); + }); + +}; + +exports.down = function (knex) { + return knex.schema + .alterTable("stat_daily", function (table) { + table.dropColumn("extras"); + }) + .alterTable("stat_minutely", function (table) { + table.dropColumn("extras"); + }) + .alterTable("stat_hourly", function (table) { + table.dropColumn("extras"); + }); +}; diff --git a/db/knex_migrations/2024-04-26-0000-snmp-monitor.js b/db/knex_migrations/2024-04-26-0000-snmp-monitor.js new file mode 100644 index 0000000..24752f2 --- /dev/null +++ b/db/knex_migrations/2024-04-26-0000-snmp-monitor.js @@ -0,0 +1,16 @@ +exports.up = function (knex) { + return knex.schema + .alterTable("monitor", function (table) { + table.string("snmp_oid").defaultTo(null); + table.enum("snmp_version", [ "1", "2c", "3" ]).defaultTo("2c"); + table.string("json_path_operator").defaultTo(null); + }); +}; + +exports.down = function (knex) { + return knex.schema.alterTable("monitor", function (table) { + table.dropColumn("snmp_oid"); + table.dropColumn("snmp_version"); + table.dropColumn("json_path_operator"); + }); +}; diff --git a/db/knex_migrations/2024-08-24-000-add-cache-bust.js b/db/knex_migrations/2024-08-24-000-add-cache-bust.js new file mode 100644 index 0000000..3644377 --- /dev/null +++ b/db/knex_migrations/2024-08-24-000-add-cache-bust.js @@ -0,0 +1,13 @@ +exports.up = function (knex) { + return knex.schema + .alterTable("monitor", function (table) { + table.boolean("cache_bust").notNullable().defaultTo(false); + }); +}; + +exports.down = function (knex) { + return knex.schema + .alterTable("monitor", function (table) { + table.dropColumn("cache_bust"); + }); +}; diff --git a/db/knex_migrations/2024-08-24-0000-conditions.js b/db/knex_migrations/2024-08-24-0000-conditions.js new file mode 100644 index 0000000..96352fd --- /dev/null +++ b/db/knex_migrations/2024-08-24-0000-conditions.js @@ -0,0 +1,12 @@ +exports.up = function (knex) { + return knex.schema + .alterTable("monitor", function (table) { + table.text("conditions").notNullable().defaultTo("[]"); + }); +}; + +exports.down = function (knex) { + return knex.schema.alterTable("monitor", function (table) { + table.dropColumn("conditions"); + }); +}; diff --git a/db/knex_migrations/2024-10-1315-rabbitmq-monitor.js b/db/knex_migrations/2024-10-1315-rabbitmq-monitor.js new file mode 100644 index 0000000..6a17f33 --- /dev/null +++ b/db/knex_migrations/2024-10-1315-rabbitmq-monitor.js @@ -0,0 +1,17 @@ +exports.up = function (knex) { + return knex.schema.alterTable("monitor", function (table) { + table.text("rabbitmq_nodes"); + table.string("rabbitmq_username"); + table.string("rabbitmq_password"); + }); + +}; + +exports.down = function (knex) { + return knex.schema.alterTable("monitor", function (table) { + table.dropColumn("rabbitmq_nodes"); + table.dropColumn("rabbitmq_username"); + table.dropColumn("rabbitmq_password"); + }); + +}; diff --git a/db/knex_migrations/2024-11-27-1927-fix-info-json-data-type.js b/db/knex_migrations/2024-11-27-1927-fix-info-json-data-type.js new file mode 100644 index 0000000..0f3f75e --- /dev/null +++ b/db/knex_migrations/2024-11-27-1927-fix-info-json-data-type.js @@ -0,0 +1,13 @@ +// Update info_json column to LONGTEXT mainly for MariaDB +exports.up = function (knex) { + return knex.schema + .alterTable("monitor_tls_info", function (table) { + table.text("info_json", "longtext").alter(); + }); +}; + +exports.down = function (knex) { + return knex.schema.alterTable("monitor_tls_info", function (table) { + table.text("info_json", "text").alter(); + }); +}; diff --git a/db/knex_migrations/README.md b/db/knex_migrations/README.md new file mode 100644 index 0000000..d2b8470 --- /dev/null +++ b/db/knex_migrations/README.md @@ -0,0 +1,56 @@ +# Info + +https://knexjs.org/guide/migrations.html#knexfile-in-other-languages + +## Basic rules + +- All tables must have a primary key named `id` +- Filename format: `YYYY-MM-DD-HHMM-patch-name.js` +- Avoid native SQL syntax, use knex methods, because Uptime Kuma supports SQLite and MariaDB. + +## Template + +```js +exports.up = function(knex) { + +}; + +exports.down = function(knex) { + +}; + +// exports.config = { transaction: false }; +``` + +## Example + +Filename: 2023-06-30-1348-create-user-and-product.js + +```js +exports.up = function(knex) { + return knex.schema + .createTable('user', function (table) { + table.increments('id'); + table.string('first_name', 255).notNullable(); + table.string('last_name', 255).notNullable(); + }) + .createTable('product', function (table) { + table.increments('id'); + table.decimal('price').notNullable(); + table.string('name', 1000).notNullable(); + }).then(() => { + knex("products").insert([ + { price: 10, name: "Apple" }, + { price: 20, name: "Orange" }, + ]); + }); +}; + +exports.down = function(knex) { + return knex.schema + .dropTable("product") + .dropTable("user"); +}; +``` + +https://knexjs.org/guide/migrations.html#transactions-in-migrations diff --git a/db/kuma.db b/db/kuma.db new file mode 100644 index 0000000..6e02ccc Binary files /dev/null and b/db/kuma.db differ diff --git a/db/old_migrations/README.md b/db/old_migrations/README.md new file mode 100644 index 0000000..3b2bd96 --- /dev/null +++ b/db/old_migrations/README.md @@ -0,0 +1,3 @@ +# Don't create a new migration file here + +Please go to ./db/knex_migrations/README.md diff --git a/db/old_migrations/patch-2fa-invalidate-used-token.sql b/db/old_migrations/patch-2fa-invalidate-used-token.sql new file mode 100644 index 0000000..2f0b42c --- /dev/null +++ b/db/old_migrations/patch-2fa-invalidate-used-token.sql @@ -0,0 +1,7 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE user + ADD twofa_last_token VARCHAR(6); + +COMMIT; diff --git a/db/old_migrations/patch-2fa.sql b/db/old_migrations/patch-2fa.sql new file mode 100644 index 0000000..35069d8 --- /dev/null +++ b/db/old_migrations/patch-2fa.sql @@ -0,0 +1,10 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE user + ADD twofa_secret VARCHAR(64); + +ALTER TABLE user + ADD twofa_status BOOLEAN default 0 NOT NULL; + +COMMIT; diff --git a/db/old_migrations/patch-add-certificate-expiry-status-page.sql b/db/old_migrations/patch-add-certificate-expiry-status-page.sql new file mode 100644 index 0000000..63a2010 --- /dev/null +++ b/db/old_migrations/patch-add-certificate-expiry-status-page.sql @@ -0,0 +1,7 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE status_page + ADD show_certificate_expiry BOOLEAN default 0 NOT NULL; + +COMMIT; diff --git a/db/old_migrations/patch-add-clickable-status-page-link.sql b/db/old_migrations/patch-add-clickable-status-page-link.sql new file mode 100644 index 0000000..cd11cdd --- /dev/null +++ b/db/old_migrations/patch-add-clickable-status-page-link.sql @@ -0,0 +1,7 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor_group + ADD send_url BOOLEAN DEFAULT 0 NOT NULL; + +COMMIT; diff --git a/db/old_migrations/patch-add-description-monitor.sql b/db/old_migrations/patch-add-description-monitor.sql new file mode 100644 index 0000000..da1aa55 --- /dev/null +++ b/db/old_migrations/patch-add-description-monitor.sql @@ -0,0 +1,7 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD description TEXT default null; + +COMMIT; diff --git a/db/old_migrations/patch-add-docker-columns.sql b/db/old_migrations/patch-add-docker-columns.sql new file mode 100644 index 0000000..4cea448 --- /dev/null +++ b/db/old_migrations/patch-add-docker-columns.sql @@ -0,0 +1,18 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +CREATE TABLE docker_host ( + id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + user_id INT NOT NULL, + docker_daemon VARCHAR(255), + docker_type VARCHAR(255), + name VARCHAR(255) +); + +ALTER TABLE monitor + ADD docker_host INTEGER REFERENCES docker_host(id); + +ALTER TABLE monitor + ADD docker_container VARCHAR(255); + +COMMIT; diff --git a/db/old_migrations/patch-add-gamedig-given-port.sql b/db/old_migrations/patch-add-gamedig-given-port.sql new file mode 100644 index 0000000..897a9c7 --- /dev/null +++ b/db/old_migrations/patch-add-gamedig-given-port.sql @@ -0,0 +1,7 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD gamedig_given_port_only BOOLEAN default 1 not null; + +COMMIT; diff --git a/db/old_migrations/patch-add-gamedig-monitor.sql b/db/old_migrations/patch-add-gamedig-monitor.sql new file mode 100644 index 0000000..e20a0cd --- /dev/null +++ b/db/old_migrations/patch-add-gamedig-monitor.sql @@ -0,0 +1,7 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + + ALTER TABLE monitor + ADD game VARCHAR(255); + +COMMIT; diff --git a/db/old_migrations/patch-add-google-analytics-status-page-tag.sql b/db/old_migrations/patch-add-google-analytics-status-page-tag.sql new file mode 100644 index 0000000..fe6fa34 --- /dev/null +++ b/db/old_migrations/patch-add-google-analytics-status-page-tag.sql @@ -0,0 +1,7 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE status_page + ADD google_analytics_tag_id VARCHAR; + +COMMIT; diff --git a/db/old_migrations/patch-add-invert-keyword.sql b/db/old_migrations/patch-add-invert-keyword.sql new file mode 100644 index 0000000..8ca199e --- /dev/null +++ b/db/old_migrations/patch-add-invert-keyword.sql @@ -0,0 +1,7 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD invert_keyword BOOLEAN default 0 not null; + +COMMIT; diff --git a/db/old_migrations/patch-add-other-auth.sql b/db/old_migrations/patch-add-other-auth.sql new file mode 100644 index 0000000..b83f1ee --- /dev/null +++ b/db/old_migrations/patch-add-other-auth.sql @@ -0,0 +1,18 @@ +BEGIN TRANSACTION; + + ALTER TABLE monitor + ADD auth_method VARCHAR(250); + + ALTER TABLE monitor + ADD auth_domain TEXT; + ALTER TABLE monitor + + ADD auth_workstation TEXT; + +COMMIT; + +BEGIN TRANSACTION; + UPDATE monitor + SET auth_method = 'basic' + WHERE basic_auth_user is not null; +COMMIT; diff --git a/db/old_migrations/patch-add-parent-monitor.sql b/db/old_migrations/patch-add-parent-monitor.sql new file mode 100644 index 0000000..ac2697f --- /dev/null +++ b/db/old_migrations/patch-add-parent-monitor.sql @@ -0,0 +1,7 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD parent INTEGER REFERENCES [monitor] ([id]) ON DELETE SET NULL ON UPDATE CASCADE; + +COMMIT; diff --git a/db/old_migrations/patch-add-radius-monitor.sql b/db/old_migrations/patch-add-radius-monitor.sql new file mode 100644 index 0000000..4625f21 --- /dev/null +++ b/db/old_migrations/patch-add-radius-monitor.sql @@ -0,0 +1,19 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD radius_username VARCHAR(255); + +ALTER TABLE monitor + ADD radius_password VARCHAR(255); + +ALTER TABLE monitor + ADD radius_calling_station_id VARCHAR(50); + +ALTER TABLE monitor + ADD radius_called_station_id VARCHAR(50); + +ALTER TABLE monitor + ADD radius_secret VARCHAR(255); + +COMMIT; diff --git a/db/old_migrations/patch-add-retry-interval-monitor.sql b/db/old_migrations/patch-add-retry-interval-monitor.sql new file mode 100644 index 0000000..adb6462 --- /dev/null +++ b/db/old_migrations/patch-add-retry-interval-monitor.sql @@ -0,0 +1,7 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD retry_interval INTEGER default 0 not null; + +COMMIT; \ No newline at end of file diff --git a/db/old_migrations/patch-add-sqlserver-monitor.sql b/db/old_migrations/patch-add-sqlserver-monitor.sql new file mode 100644 index 0000000..f253dd2 --- /dev/null +++ b/db/old_migrations/patch-add-sqlserver-monitor.sql @@ -0,0 +1,10 @@ +BEGIN TRANSACTION; + + ALTER TABLE monitor + ADD database_connection_string VARCHAR(2000); + + ALTER TABLE monitor + ADD database_query TEXT; + + + COMMIT diff --git a/db/old_migrations/patch-add-timeout-monitor.sql b/db/old_migrations/patch-add-timeout-monitor.sql new file mode 100644 index 0000000..b62eb14 --- /dev/null +++ b/db/old_migrations/patch-add-timeout-monitor.sql @@ -0,0 +1,7 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD timeout DOUBLE default 0 not null; + +COMMIT; diff --git a/db/old_migrations/patch-added-json-query.sql b/db/old_migrations/patch-added-json-query.sql new file mode 100644 index 0000000..d5b7f1a --- /dev/null +++ b/db/old_migrations/patch-added-json-query.sql @@ -0,0 +1,10 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD json_path TEXT; + +ALTER TABLE monitor + ADD expected_value VARCHAR(255); + +COMMIT; diff --git a/db/old_migrations/patch-added-kafka-producer.sql b/db/old_migrations/patch-added-kafka-producer.sql new file mode 100644 index 0000000..933d30b --- /dev/null +++ b/db/old_migrations/patch-added-kafka-producer.sql @@ -0,0 +1,22 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD kafka_producer_topic VARCHAR(255); + +ALTER TABLE monitor + ADD kafka_producer_brokers TEXT; + +ALTER TABLE monitor + ADD kafka_producer_ssl INTEGER; + +ALTER TABLE monitor + ADD kafka_producer_allow_auto_topic_creation VARCHAR(255); + +ALTER TABLE monitor + ADD kafka_producer_sasl_options TEXT; + +ALTER TABLE monitor + ADD kafka_producer_message TEXT; + +COMMIT; diff --git a/db/old_migrations/patch-added-mqtt-monitor.sql b/db/old_migrations/patch-added-mqtt-monitor.sql new file mode 100644 index 0000000..02b0b09 --- /dev/null +++ b/db/old_migrations/patch-added-mqtt-monitor.sql @@ -0,0 +1,16 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD mqtt_topic TEXT; + +ALTER TABLE monitor + ADD mqtt_success_message VARCHAR(255); + +ALTER TABLE monitor + ADD mqtt_username VARCHAR(255); + +ALTER TABLE monitor + ADD mqtt_password VARCHAR(255); + +COMMIT; diff --git a/db/old_migrations/patch-api-key-table.sql b/db/old_migrations/patch-api-key-table.sql new file mode 100644 index 0000000..4116db3 --- /dev/null +++ b/db/old_migrations/patch-api-key-table.sql @@ -0,0 +1,15 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +CREATE TABLE [api_key] ( + [id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + [key] VARCHAR(255) NOT NULL, + [name] VARCHAR(255) NOT NULL, + [user_id] INTEGER NOT NULL, + [created_date] DATETIME DEFAULT (DATETIME('now')) NOT NULL, + [active] BOOLEAN DEFAULT 1 NOT NULL, + [expires] DATETIME DEFAULT NULL, + CONSTRAINT FK_user FOREIGN KEY ([user_id]) REFERENCES [user]([id]) ON DELETE CASCADE ON UPDATE CASCADE +); + +COMMIT; diff --git a/db/old_migrations/patch-fix-kafka-producer-booleans.sql b/db/old_migrations/patch-fix-kafka-producer-booleans.sql new file mode 100644 index 0000000..be2e992 --- /dev/null +++ b/db/old_migrations/patch-fix-kafka-producer-booleans.sql @@ -0,0 +1,34 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +-- Rename COLUMNs to another one (suffixed by `_old`) +ALTER TABLE monitor + RENAME COLUMN kafka_producer_ssl TO kafka_producer_ssl_old; + +ALTER TABLE monitor + RENAME COLUMN kafka_producer_allow_auto_topic_creation TO kafka_producer_allow_auto_topic_creation_old; + +-- Add correct COLUMNs +ALTER TABLE monitor + ADD COLUMN kafka_producer_ssl BOOLEAN default 0 NOT NULL; + +ALTER TABLE monitor + ADD COLUMN kafka_producer_allow_auto_topic_creation BOOLEAN default 0 NOT NULL; + +-- These SQL is still not fully safe. See https://github.com/louislam/uptime-kuma/issues/4039. + +-- Set bring old values from `_old` COLUMNs to correct ones +-- UPDATE monitor SET kafka_producer_allow_auto_topic_creation = monitor.kafka_producer_allow_auto_topic_creation_old +-- WHERE monitor.kafka_producer_allow_auto_topic_creation_old IS NOT NULL; + +-- UPDATE monitor SET kafka_producer_ssl = monitor.kafka_producer_ssl_old +-- WHERE monitor.kafka_producer_ssl_old IS NOT NULL; + +-- Remove old COLUMNs +ALTER TABLE monitor + DROP COLUMN kafka_producer_allow_auto_topic_creation_old; + +ALTER TABLE monitor + DROP COLUMN kafka_producer_ssl_old; + +COMMIT; diff --git a/db/old_migrations/patch-group-table.sql b/db/old_migrations/patch-group-table.sql new file mode 100644 index 0000000..1c6f366 --- /dev/null +++ b/db/old_migrations/patch-group-table.sql @@ -0,0 +1,30 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +create table `group` +( + id INTEGER not null + constraint group_pk + primary key autoincrement, + name VARCHAR(255) not null, + created_date DATETIME default (DATETIME('now')) not null, + public BOOLEAN default 0 not null, + active BOOLEAN default 1 not null, + weight BOOLEAN NOT NULL DEFAULT 1000 +); + +CREATE TABLE [monitor_group] +( + [id] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + [monitor_id] INTEGER NOT NULL REFERENCES [monitor] ([id]) ON DELETE CASCADE ON UPDATE CASCADE, + [group_id] INTEGER NOT NULL REFERENCES [group] ([id]) ON DELETE CASCADE ON UPDATE CASCADE, + weight BOOLEAN NOT NULL DEFAULT 1000 +); + +CREATE INDEX [fk] + ON [monitor_group] ( + [monitor_id], + [group_id]); + + +COMMIT; diff --git a/db/old_migrations/patch-grpc-monitor.sql b/db/old_migrations/patch-grpc-monitor.sql new file mode 100644 index 0000000..bac024e --- /dev/null +++ b/db/old_migrations/patch-grpc-monitor.sql @@ -0,0 +1,25 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD grpc_url VARCHAR(255) default null; + +ALTER TABLE monitor + ADD grpc_protobuf TEXT default null; + +ALTER TABLE monitor + ADD grpc_body TEXT default null; + +ALTER TABLE monitor + ADD grpc_metadata TEXT default null; + +ALTER TABLE monitor + ADD grpc_method VARCHAR(255) default null; + +ALTER TABLE monitor + ADD grpc_service_name VARCHAR(255) default null; + +ALTER TABLE monitor + ADD grpc_enable_tls BOOLEAN default 0 not null; + +COMMIT; diff --git a/db/old_migrations/patch-http-body-encoding.sql b/db/old_migrations/patch-http-body-encoding.sql new file mode 100644 index 0000000..322c8b8 --- /dev/null +++ b/db/old_migrations/patch-http-body-encoding.sql @@ -0,0 +1,12 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor ADD http_body_encoding VARCHAR(25); + +COMMIT; + +BEGIN TRANSACTION; + +UPDATE monitor SET http_body_encoding = 'json' WHERE (type = 'http' or type = 'keyword') AND http_body_encoding IS NULL; + +COMMIT; diff --git a/db/old_migrations/patch-http-monitor-method-body-and-headers.sql b/db/old_migrations/patch-http-monitor-method-body-and-headers.sql new file mode 100644 index 0000000..dc2526b --- /dev/null +++ b/db/old_migrations/patch-http-monitor-method-body-and-headers.sql @@ -0,0 +1,13 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD method TEXT default 'GET' not null; + +ALTER TABLE monitor + ADD body TEXT default null; + +ALTER TABLE monitor + ADD headers TEXT default null; + +COMMIT; diff --git a/db/old_migrations/patch-improve-performance.sql b/db/old_migrations/patch-improve-performance.sql new file mode 100644 index 0000000..c07d629 --- /dev/null +++ b/db/old_migrations/patch-improve-performance.sql @@ -0,0 +1,10 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +-- For sendHeartbeatList +CREATE INDEX monitor_time_index ON heartbeat (monitor_id, time); + +-- For sendImportantHeartbeatList +CREATE INDEX monitor_important_time_index ON heartbeat (monitor_id, important,time); + +COMMIT; diff --git a/db/old_migrations/patch-incident-table.sql b/db/old_migrations/patch-incident-table.sql new file mode 100644 index 0000000..531cfb3 --- /dev/null +++ b/db/old_migrations/patch-incident-table.sql @@ -0,0 +1,18 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +create table incident +( + id INTEGER not null + constraint incident_pk + primary key autoincrement, + title VARCHAR(255) not null, + content TEXT not null, + style VARCHAR(30) default 'warning' not null, + created_date DATETIME default (DATETIME('now')) not null, + last_updated_date DATETIME, + pin BOOLEAN default 1 not null, + active BOOLEAN default 1 not null +); + +COMMIT; diff --git a/db/old_migrations/patch-maintenance-cron.sql b/db/old_migrations/patch-maintenance-cron.sql new file mode 100644 index 0000000..bc51b88 --- /dev/null +++ b/db/old_migrations/patch-maintenance-cron.sql @@ -0,0 +1,11 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +DROP TABLE maintenance_timeslot; + +-- 999 characters. https://stackoverflow.com/questions/46134830/maximum-length-for-cron-job +ALTER TABLE maintenance ADD cron TEXT; +ALTER TABLE maintenance ADD timezone VARCHAR(255); +ALTER TABLE maintenance ADD duration INTEGER; + +COMMIT; diff --git a/db/old_migrations/patch-maintenance-table2.sql b/db/old_migrations/patch-maintenance-table2.sql new file mode 100644 index 0000000..96b2ebd --- /dev/null +++ b/db/old_migrations/patch-maintenance-table2.sql @@ -0,0 +1,83 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +-- Just for someone who tested maintenance before (patch-maintenance-table.sql) +DROP TABLE IF EXISTS maintenance_status_page; +DROP TABLE IF EXISTS monitor_maintenance; +DROP TABLE IF EXISTS maintenance; +DROP TABLE IF EXISTS maintenance_timeslot; + +-- maintenance +CREATE TABLE [maintenance] ( + [id] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + [title] VARCHAR(150) NOT NULL, + [description] TEXT NOT NULL, + [user_id] INTEGER REFERENCES [user]([id]) ON DELETE SET NULL ON UPDATE CASCADE, + [active] BOOLEAN NOT NULL DEFAULT 1, + [strategy] VARCHAR(50) NOT NULL DEFAULT 'single', + [start_date] DATETIME, + [end_date] DATETIME, + [start_time] TIME, + [end_time] TIME, + [weekdays] VARCHAR2(250) DEFAULT '[]', + [days_of_month] TEXT DEFAULT '[]', + [interval_day] INTEGER +); + +CREATE INDEX [manual_active] ON [maintenance] ( + [strategy], + [active] +); + +CREATE INDEX [active] ON [maintenance] ([active]); + +CREATE INDEX [maintenance_user_id] ON [maintenance] ([user_id]); + +-- maintenance_status_page +CREATE TABLE maintenance_status_page ( + id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + status_page_id INTEGER NOT NULL, + maintenance_id INTEGER NOT NULL, + CONSTRAINT FK_maintenance FOREIGN KEY (maintenance_id) REFERENCES maintenance (id) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT FK_status_page FOREIGN KEY (status_page_id) REFERENCES status_page (id) ON DELETE CASCADE ON UPDATE CASCADE +); + +CREATE INDEX [status_page_id_index] + ON [maintenance_status_page]([status_page_id]); + +CREATE INDEX [maintenance_id_index] + ON [maintenance_status_page]([maintenance_id]); + +-- maintenance_timeslot +CREATE TABLE [maintenance_timeslot] ( + [id] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + [maintenance_id] INTEGER NOT NULL CONSTRAINT [FK_maintenance] REFERENCES [maintenance]([id]) ON DELETE CASCADE ON UPDATE CASCADE, + [start_date] DATETIME NOT NULL, + [end_date] DATETIME, + [generated_next] BOOLEAN DEFAULT 0 +); + +CREATE INDEX [maintenance_id] ON [maintenance_timeslot] ([maintenance_id] DESC); + +CREATE INDEX [active_timeslot_index] ON [maintenance_timeslot] ( + [maintenance_id] DESC, + [start_date] DESC, + [end_date] DESC +); + +CREATE INDEX [generated_next_index] ON [maintenance_timeslot] ([generated_next]); + +-- monitor_maintenance +CREATE TABLE monitor_maintenance ( + id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + monitor_id INTEGER NOT NULL, + maintenance_id INTEGER NOT NULL, + CONSTRAINT FK_maintenance FOREIGN KEY (maintenance_id) REFERENCES maintenance (id) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT FK_monitor FOREIGN KEY (monitor_id) REFERENCES monitor (id) ON DELETE CASCADE ON UPDATE CASCADE +); + +CREATE INDEX [maintenance_id_index2] ON [monitor_maintenance]([maintenance_id]); + +CREATE INDEX [monitor_id_index] ON [monitor_maintenance]([monitor_id]); + +COMMIT; diff --git a/db/old_migrations/patch-monitor-add-resend-interval.sql b/db/old_migrations/patch-monitor-add-resend-interval.sql new file mode 100644 index 0000000..8e28bf6 --- /dev/null +++ b/db/old_migrations/patch-monitor-add-resend-interval.sql @@ -0,0 +1,10 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD resend_interval INTEGER default 0 not null; + +ALTER TABLE heartbeat + ADD down_count INTEGER default 0 not null; + +COMMIT; diff --git a/db/old_migrations/patch-monitor-basic-auth.sql b/db/old_migrations/patch-monitor-basic-auth.sql new file mode 100644 index 0000000..de4bdef --- /dev/null +++ b/db/old_migrations/patch-monitor-basic-auth.sql @@ -0,0 +1,10 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD basic_auth_user TEXT default null; + +ALTER TABLE monitor + ADD basic_auth_pass TEXT default null; + +COMMIT; diff --git a/db/old_migrations/patch-monitor-expiry-notification.sql b/db/old_migrations/patch-monitor-expiry-notification.sql new file mode 100644 index 0000000..7a33001 --- /dev/null +++ b/db/old_migrations/patch-monitor-expiry-notification.sql @@ -0,0 +1,7 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD expiry_notification BOOLEAN default 1; + +COMMIT; diff --git a/db/old_migrations/patch-monitor-oauth-cc.sql b/db/old_migrations/patch-monitor-oauth-cc.sql new file mode 100644 index 0000000..f33e952 --- /dev/null +++ b/db/old_migrations/patch-monitor-oauth-cc.sql @@ -0,0 +1,19 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD oauth_client_id TEXT default null; + +ALTER TABLE monitor + ADD oauth_client_secret TEXT default null; + +ALTER TABLE monitor + ADD oauth_token_url TEXT default null; + +ALTER TABLE monitor + ADD oauth_scopes TEXT default null; + +ALTER TABLE monitor + ADD oauth_auth_method TEXT default null; + +COMMIT; diff --git a/db/old_migrations/patch-monitor-push_token.sql b/db/old_migrations/patch-monitor-push_token.sql new file mode 100644 index 0000000..8c2e7a4 --- /dev/null +++ b/db/old_migrations/patch-monitor-push_token.sql @@ -0,0 +1,7 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD push_token VARCHAR(20) DEFAULT NULL; + +COMMIT; diff --git a/db/old_migrations/patch-monitor-tls-info-add-fk.sql b/db/old_migrations/patch-monitor-tls-info-add-fk.sql new file mode 100644 index 0000000..9b9c2d2 --- /dev/null +++ b/db/old_migrations/patch-monitor-tls-info-add-fk.sql @@ -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; diff --git a/db/old_migrations/patch-monitor-tls.sql b/db/old_migrations/patch-monitor-tls.sql new file mode 100644 index 0000000..ac4edb7 --- /dev/null +++ b/db/old_migrations/patch-monitor-tls.sql @@ -0,0 +1,13 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD tls_ca TEXT default null; + +ALTER TABLE monitor + ADD tls_cert TEXT default null; + +ALTER TABLE monitor + ADD tls_key TEXT default null; + +COMMIT; diff --git a/db/old_migrations/patch-notification-config.sql b/db/old_migrations/patch-notification-config.sql new file mode 100644 index 0000000..16944fb --- /dev/null +++ b/db/old_migrations/patch-notification-config.sql @@ -0,0 +1,10 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +-- SQLite: Change the data type of the column "config" from VARCHAR to TEXT +ALTER TABLE notification RENAME COLUMN config TO config_old; +ALTER TABLE notification ADD COLUMN config TEXT; +UPDATE notification SET config = config_old; +ALTER TABLE notification DROP COLUMN config_old; + +COMMIT; diff --git a/db/old_migrations/patch-notification_sent_history.sql b/db/old_migrations/patch-notification_sent_history.sql new file mode 100644 index 0000000..759eb38 --- /dev/null +++ b/db/old_migrations/patch-notification_sent_history.sql @@ -0,0 +1,18 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +CREATE TABLE [notification_sent_history] ( + [id] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + [type] VARCHAR(50) NOT NULL, + [monitor_id] INTEGER NOT NULL, + [days] INTEGER NOT NULL, + UNIQUE([type], [monitor_id], [days]) +); + +CREATE INDEX [good_index] ON [notification_sent_history] ( + [type], + [monitor_id], + [days] +); + +COMMIT; diff --git a/db/old_migrations/patch-ping-packet-size.sql b/db/old_migrations/patch-ping-packet-size.sql new file mode 100644 index 0000000..f127fc2 --- /dev/null +++ b/db/old_migrations/patch-ping-packet-size.sql @@ -0,0 +1,7 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD packet_size INTEGER DEFAULT 56 NOT NULL; + +COMMIT; diff --git a/db/old_migrations/patch-proxy.sql b/db/old_migrations/patch-proxy.sql new file mode 100644 index 0000000..41897b1 --- /dev/null +++ b/db/old_migrations/patch-proxy.sql @@ -0,0 +1,23 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +CREATE TABLE proxy ( + id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + user_id INT NOT NULL, + protocol VARCHAR(10) NOT NULL, + host VARCHAR(255) NOT NULL, + port SMALLINT NOT NULL, + auth BOOLEAN NOT NULL, + username VARCHAR(255) NULL, + password VARCHAR(255) NULL, + active BOOLEAN NOT NULL DEFAULT 1, + 'default' BOOLEAN NOT NULL DEFAULT 0, + created_date DATETIME DEFAULT (DATETIME('now')) NOT NULL +); + +ALTER TABLE monitor ADD COLUMN proxy_id INTEGER REFERENCES proxy(id); + +CREATE INDEX proxy_id ON monitor (proxy_id); +CREATE INDEX proxy_user_id ON proxy (user_id); + +COMMIT; diff --git a/db/old_migrations/patch-setting-value-type.sql b/db/old_migrations/patch-setting-value-type.sql new file mode 100644 index 0000000..4816bc6 --- /dev/null +++ b/db/old_migrations/patch-setting-value-type.sql @@ -0,0 +1,21 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +-- Generated by Intellij IDEA +create table setting_dg_tmp +( + id INTEGER + primary key autoincrement, + key VARCHAR(200) not null + unique, + value TEXT, + type VARCHAR(20) +); + +insert into setting_dg_tmp(id, key, value, type) select id, key, value, type from setting; + +drop table setting; + +alter table setting_dg_tmp rename to setting; + +COMMIT; diff --git a/db/old_migrations/patch-status-page-footer-css.sql b/db/old_migrations/patch-status-page-footer-css.sql new file mode 100644 index 0000000..beef922 --- /dev/null +++ b/db/old_migrations/patch-status-page-footer-css.sql @@ -0,0 +1,11 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE status_page + ADD footer_text TEXT; +ALTER TABLE status_page + ADD custom_css TEXT; +ALTER TABLE status_page + ADD show_powered_by BOOLEAN NOT NULL DEFAULT 1; + +COMMIT; diff --git a/db/old_migrations/patch-status-page.sql b/db/old_migrations/patch-status-page.sql new file mode 100644 index 0000000..d23b75b --- /dev/null +++ b/db/old_migrations/patch-status-page.sql @@ -0,0 +1,31 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +CREATE TABLE [status_page]( + [id] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + [slug] VARCHAR(255) NOT NULL UNIQUE, + [title] VARCHAR(255) NOT NULL, + [description] TEXT, + [icon] VARCHAR(255) NOT NULL, + [theme] VARCHAR(30) NOT NULL, + [published] BOOLEAN NOT NULL DEFAULT 1, + [search_engine_index] BOOLEAN NOT NULL DEFAULT 1, + [show_tags] BOOLEAN NOT NULL DEFAULT 0, + [password] VARCHAR, + [created_date] DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + [modified_date] DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE UNIQUE INDEX [slug] ON [status_page]([slug]); + + +CREATE TABLE [status_page_cname]( + [id] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + [status_page_id] INTEGER NOT NULL REFERENCES [status_page]([id]) ON DELETE CASCADE ON UPDATE CASCADE, + [domain] VARCHAR NOT NULL UNIQUE +); + +ALTER TABLE incident ADD status_page_id INTEGER; +ALTER TABLE [group] ADD status_page_id INTEGER; + +COMMIT; diff --git a/db/old_migrations/patch-timeout.sql b/db/old_migrations/patch-timeout.sql new file mode 100644 index 0000000..f257112 --- /dev/null +++ b/db/old_migrations/patch-timeout.sql @@ -0,0 +1,7 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +UPDATE monitor SET timeout = (interval * 0.8) +WHERE timeout IS NULL OR timeout <= 0; + +COMMIT; diff --git a/db/old_migrations/patch1.sql b/db/old_migrations/patch1.sql new file mode 100644 index 0000000..6a31fa2 --- /dev/null +++ b/db/old_migrations/patch1.sql @@ -0,0 +1,37 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +-- Change Monitor.created_date from "TIMESTAMP" to "DATETIME" +-- SQL Generated by Intellij Idea +PRAGMA foreign_keys=off; + +BEGIN TRANSACTION; + +create table monitor_dg_tmp +( + id INTEGER not null + primary key autoincrement, + name VARCHAR(150), + active BOOLEAN default 1 not null, + user_id INTEGER + references user + on update cascade on delete set null, + interval INTEGER default 20 not null, + url TEXT, + type VARCHAR(20), + weight INTEGER default 2000, + hostname VARCHAR(255), + port INTEGER, + created_date DATETIME, + keyword VARCHAR(255) +); + +insert into monitor_dg_tmp(id, name, active, user_id, interval, url, type, weight, hostname, port, created_date, keyword) select id, name, active, user_id, interval, url, type, weight, hostname, port, created_date, keyword from monitor; + +drop table monitor; + +alter table monitor_dg_tmp rename to monitor; + +create index user_id on monitor (user_id); + +COMMIT; + +PRAGMA foreign_keys=on; diff --git a/db/old_migrations/patch10.sql b/db/old_migrations/patch10.sql new file mode 100644 index 0000000..488db11 --- /dev/null +++ b/db/old_migrations/patch10.sql @@ -0,0 +1,19 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +CREATE TABLE tag ( + id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + name VARCHAR(255) NOT NULL, + color VARCHAR(255) NOT NULL, + created_date DATETIME DEFAULT (DATETIME('now')) NOT NULL +); + +CREATE TABLE monitor_tag ( + id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + monitor_id INTEGER NOT NULL, + tag_id INTEGER NOT NULL, + value TEXT, + CONSTRAINT FK_tag FOREIGN KEY (tag_id) REFERENCES tag(id) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT FK_monitor FOREIGN KEY (monitor_id) REFERENCES monitor(id) ON DELETE CASCADE ON UPDATE CASCADE +); + +CREATE INDEX monitor_tag_monitor_id_index ON monitor_tag (monitor_id); +CREATE INDEX monitor_tag_tag_id_index ON monitor_tag (tag_id); diff --git a/db/old_migrations/patch2.sql b/db/old_migrations/patch2.sql new file mode 100644 index 0000000..2f34e29 --- /dev/null +++ b/db/old_migrations/patch2.sql @@ -0,0 +1,10 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +CREATE TABLE monitor_tls_info ( + id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + monitor_id INTEGER NOT NULL, + info_json TEXT +); + +COMMIT; diff --git a/db/old_migrations/patch3.sql b/db/old_migrations/patch3.sql new file mode 100644 index 0000000..e615632 --- /dev/null +++ b/db/old_migrations/patch3.sql @@ -0,0 +1,37 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +-- Add maxretries column to monitor +PRAGMA foreign_keys=off; + +BEGIN TRANSACTION; + +create table monitor_dg_tmp +( + id INTEGER not null + primary key autoincrement, + name VARCHAR(150), + active BOOLEAN default 1 not null, + user_id INTEGER + references user + on update cascade on delete set null, + interval INTEGER default 20 not null, + url TEXT, + type VARCHAR(20), + weight INTEGER default 2000, + hostname VARCHAR(255), + port INTEGER, + created_date DATETIME, + keyword VARCHAR(255), + maxretries INTEGER NOT NULL DEFAULT 0 +); + +insert into monitor_dg_tmp(id, name, active, user_id, interval, url, type, weight, hostname, port, created_date, keyword) select id, name, active, user_id, interval, url, type, weight, hostname, port, created_date, keyword from monitor; + +drop table monitor; + +alter table monitor_dg_tmp rename to monitor; + +create index user_id on monitor (user_id); + +COMMIT; + +PRAGMA foreign_keys=on; diff --git a/db/old_migrations/patch4.sql b/db/old_migrations/patch4.sql new file mode 100644 index 0000000..ff40da2 --- /dev/null +++ b/db/old_migrations/patch4.sql @@ -0,0 +1,40 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +-- OK.... serious wrong, missing maxretries column +-- Developers should patch it manually if you have missing the maxretries column +PRAGMA foreign_keys=off; + +BEGIN TRANSACTION; + +create table monitor_dg_tmp +( + id INTEGER not null + primary key autoincrement, + name VARCHAR(150), + active BOOLEAN default 1 not null, + user_id INTEGER + references user + on update cascade on delete set null, + interval INTEGER default 20 not null, + url TEXT, + type VARCHAR(20), + weight INTEGER default 2000, + hostname VARCHAR(255), + port INTEGER, + created_date DATETIME, + keyword VARCHAR(255), + maxretries INTEGER NOT NULL DEFAULT 0, + ignore_tls BOOLEAN default 0 not null, + upside_down BOOLEAN default 0 not null +); + +insert into monitor_dg_tmp(id, name, active, user_id, interval, url, type, weight, hostname, port, created_date, keyword, maxretries) select id, name, active, user_id, interval, url, type, weight, hostname, port, created_date, keyword, maxretries from monitor; + +drop table monitor; + +alter table monitor_dg_tmp rename to monitor; + +create index user_id on monitor (user_id); + +COMMIT; + +PRAGMA foreign_keys=on; diff --git a/db/old_migrations/patch5.sql b/db/old_migrations/patch5.sql new file mode 100644 index 0000000..5730b2d --- /dev/null +++ b/db/old_migrations/patch5.sql @@ -0,0 +1,70 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +PRAGMA foreign_keys = off; + +BEGIN TRANSACTION; + +create table monitor_dg_tmp ( + id INTEGER not null primary key autoincrement, + name VARCHAR(150), + active BOOLEAN default 1 not null, + user_id INTEGER references user on update cascade on delete + set + null, + interval INTEGER default 20 not null, + url TEXT, + type VARCHAR(20), + weight INTEGER default 2000, + hostname VARCHAR(255), + port INTEGER, + created_date DATETIME default (DATETIME('now')) not null, + keyword VARCHAR(255), + maxretries INTEGER NOT NULL DEFAULT 0, + ignore_tls BOOLEAN default 0 not null, + upside_down BOOLEAN default 0 not null +); + +insert into + monitor_dg_tmp( + id, + name, + active, + user_id, + interval, + url, + type, + weight, + hostname, + port, + keyword, + maxretries, + ignore_tls, + upside_down + ) +select + id, + name, + active, + user_id, + interval, + url, + type, + weight, + hostname, + port, + keyword, + maxretries, + ignore_tls, + upside_down +from + monitor; + +drop table monitor; + +alter table + monitor_dg_tmp rename to monitor; + +create index user_id on monitor (user_id); + +COMMIT; + +PRAGMA foreign_keys = on; diff --git a/db/old_migrations/patch6.sql b/db/old_migrations/patch6.sql new file mode 100644 index 0000000..4f539a2 --- /dev/null +++ b/db/old_migrations/patch6.sql @@ -0,0 +1,74 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +PRAGMA foreign_keys = off; + +BEGIN TRANSACTION; + +create table monitor_dg_tmp ( + id INTEGER not null primary key autoincrement, + name VARCHAR(150), + active BOOLEAN default 1 not null, + user_id INTEGER references user on update cascade on delete + set + null, + interval INTEGER default 20 not null, + url TEXT, + type VARCHAR(20), + weight INTEGER default 2000, + hostname VARCHAR(255), + port INTEGER, + created_date DATETIME default (DATETIME('now')) not null, + keyword VARCHAR(255), + maxretries INTEGER NOT NULL DEFAULT 0, + ignore_tls BOOLEAN default 0 not null, + upside_down BOOLEAN default 0 not null, + maxredirects INTEGER default 10 not null, + accepted_statuscodes_json TEXT default '["200-299"]' not null +); + +insert into + monitor_dg_tmp( + id, + name, + active, + user_id, + interval, + url, + type, + weight, + hostname, + port, + created_date, + keyword, + maxretries, + ignore_tls, + upside_down + ) +select + id, + name, + active, + user_id, + interval, + url, + type, + weight, + hostname, + port, + created_date, + keyword, + maxretries, + ignore_tls, + upside_down +from + monitor; + +drop table monitor; + +alter table + monitor_dg_tmp rename to monitor; + +create index user_id on monitor (user_id); + +COMMIT; + +PRAGMA foreign_keys = on; diff --git a/db/old_migrations/patch7.sql b/db/old_migrations/patch7.sql new file mode 100644 index 0000000..2e8eba1 --- /dev/null +++ b/db/old_migrations/patch7.sql @@ -0,0 +1,10 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD dns_resolve_type VARCHAR(5); + +ALTER TABLE monitor + ADD dns_resolve_server VARCHAR(255); + +COMMIT; diff --git a/db/old_migrations/patch8.sql b/db/old_migrations/patch8.sql new file mode 100644 index 0000000..d63a594 --- /dev/null +++ b/db/old_migrations/patch8.sql @@ -0,0 +1,7 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD dns_last_result VARCHAR(255); + +COMMIT; diff --git a/db/old_migrations/patch9.sql b/db/old_migrations/patch9.sql new file mode 100644 index 0000000..d4d13aa --- /dev/null +++ b/db/old_migrations/patch9.sql @@ -0,0 +1,7 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE notification + ADD is_default BOOLEAN default 0 NOT NULL; + +COMMIT; diff --git a/db/patch-monitor-tls-info-add-fk.sql b/db/patch-monitor-tls-info-add-fk.sql new file mode 100644 index 0000000..9b9c2d2 --- /dev/null +++ b/db/patch-monitor-tls-info-add-fk.sql @@ -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; diff --git a/docker/builder-go.dockerfile b/docker/builder-go.dockerfile new file mode 100644 index 0000000..1d25843 --- /dev/null +++ b/docker/builder-go.dockerfile @@ -0,0 +1,16 @@ +############################################ +# Build in Golang +# Run npm run build-healthcheck-armv7 in the host first, another it will be super slow where it is building the armv7 healthcheck +############################################ +FROM golang:1.19-buster +WORKDIR /app +ARG TARGETPLATFORM +COPY ./extra/ ./extra/ + +# Compile healthcheck.go +RUN apt update && \ + apt --yes --no-install-recommends install curl && \ + curl -sL https://deb.nodesource.com/setup_18.x | bash && \ + apt --yes --no-install-recommends install nodejs && \ + node ./extra/build-healthcheck.js $TARGETPLATFORM && \ + apt --yes remove nodejs diff --git a/docker/debian-base.dockerfile b/docker/debian-base.dockerfile new file mode 100644 index 0000000..a171743 --- /dev/null +++ b/docker/debian-base.dockerfile @@ -0,0 +1,72 @@ +# Download Apprise deb package +FROM node:20-bookworm-slim AS download-apprise +WORKDIR /app +COPY ./extra/download-apprise.mjs ./download-apprise.mjs +RUN apt update && \ + apt --yes --no-install-recommends install curl && \ + npm install cheerio semver && \ + node ./download-apprise.mjs + +# Base Image (Slim) +# If the image changed, the second stage image should be changed too +FROM node:20-bookworm-slim AS base2-slim +ARG TARGETPLATFORM + +# Specify --no-install-recommends to skip unused dependencies, make the base much smaller! +# sqlite3 = for debugging +# iputils-ping = for ping +# util-linux = for setpriv (Should be dropped in 2.0.0?) +# dumb-init = avoid zombie processes (#480) +# curl = for debugging +# ca-certificates = keep the cert up-to-date +# sudo = for start service nscd with non-root user +# nscd = for better DNS caching +RUN apt update && \ + apt --yes --no-install-recommends install \ + sqlite3 \ + ca-certificates \ + iputils-ping \ + util-linux \ + dumb-init \ + curl \ + sudo \ + nscd && \ + rm -rf /var/lib/apt/lists/* && \ + apt --yes autoremove + +# apprise = for notifications (Install from the deb package, as the stable one is too old) (workaround for #4867) +# Switching to testing repo is no longer working, as the testing repo is not bookworm anymore. +# python3-paho-mqtt (#4859) +# TODO: no idea how to delete the deb file after installation as it becomes a layer already +COPY --from=download-apprise /app/apprise.deb ./apprise.deb +RUN apt update && \ + apt --yes --no-install-recommends install ./apprise.deb python3-paho-mqtt && \ + rm -rf /var/lib/apt/lists/* && \ + rm -f apprise.deb && \ + apt --yes autoremove + +# Install cloudflared +RUN curl https://pkg.cloudflare.com/cloudflare-main.gpg --output /usr/share/keyrings/cloudflare-main.gpg && \ + echo 'deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared bullseye main' | tee /etc/apt/sources.list.d/cloudflared.list && \ + apt update && \ + apt install --yes --no-install-recommends -t stable cloudflared && \ + cloudflared version && \ + rm -rf /var/lib/apt/lists/* && \ + apt --yes autoremove + +# For nscd +COPY ./docker/etc/nscd.conf /etc/nscd.conf +COPY ./docker/etc/sudoers /etc/sudoers + + +# Full Base Image +# MariaDB, Chromium and fonts +# Make sure to reuse the slim image here. Uncomment the above line if you want to build it from scratch. +# FROM base2-slim AS base2 +FROM louislam/uptime-kuma:base2-slim AS base2 +ENV UPTIME_KUMA_ENABLE_EMBEDDED_MARIADB=1 +RUN apt update && \ + apt --yes --no-install-recommends install chromium fonts-indic fonts-noto fonts-noto-cjk mariadb-server && \ + rm -rf /var/lib/apt/lists/* && \ + apt --yes autoremove && \ + chown -R node:node /var/lib/mysql diff --git a/docker/docker-compose-dev.yml b/docker/docker-compose-dev.yml new file mode 100644 index 0000000..c66b24b --- /dev/null +++ b/docker/docker-compose-dev.yml @@ -0,0 +1,14 @@ +version: '3.8' + +services: + uptime-kuma: + container_name: uptime-kuma-dev + image: louislam/uptime-kuma:nightly2 + volumes: + #- ./data:/app/data + - ../server:/app/server + - ../db:/app/db + ports: + - "3001:3001" # : + - "3307:3306" + diff --git a/docker/dockerfile b/docker/dockerfile new file mode 100644 index 0000000..d55f94f --- /dev/null +++ b/docker/dockerfile @@ -0,0 +1,114 @@ +ARG BASE_IMAGE=louislam/uptime-kuma:base2 + +############################################ +# Build in Golang +# Run npm run build-healthcheck-armv7 in the host first, otherwise it will be super slow where it is building the armv7 healthcheck +# Check file: builder-go.dockerfile +############################################ +FROM louislam/uptime-kuma:builder-go AS build_healthcheck + +############################################ +# Build in Node.js +############################################ +FROM louislam/uptime-kuma:base2 AS build +USER node +WORKDIR /app + +ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 +COPY --chown=node:node .npmrc .npmrc +COPY --chown=node:node package.json package.json +COPY --chown=node:node package-lock.json package-lock.json +RUN npm ci --omit=dev +COPY . . +COPY --chown=node:node --from=build_healthcheck /app/extra/healthcheck /app/extra/healthcheck +RUN mkdir ./data + +############################################ +# ⭐ Main Image +############################################ +FROM $BASE_IMAGE AS release +WORKDIR /app + +LABEL org.opencontainers.image.source="https://github.com/louislam/uptime-kuma" + +ENV UPTIME_KUMA_IS_CONTAINER=1 + +# Copy app files from build layer +COPY --chown=node:node --from=build /app /app + +EXPOSE 3001 +HEALTHCHECK --interval=60s --timeout=30s --start-period=180s --retries=5 CMD extra/healthcheck +ENTRYPOINT ["/usr/bin/dumb-init", "--"] +CMD ["node", "server/server.js"] + +############################################ +# Rootless Image +############################################ +FROM release AS rootless +USER node + +############################################ +# Mark as Nightly +############################################ +FROM release AS nightly +RUN npm run mark-as-nightly + +FROM nightly AS nightly-rootless +USER node + +############################################ +# Build an image for testing pr +############################################ +FROM louislam/uptime-kuma:base2 AS pr-test2 +WORKDIR /app +ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 + +## Install Git +RUN apt update \ + && apt --yes --no-install-recommends install curl \ + && curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \ + && chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \ + && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ + && apt update \ + && apt --yes --no-install-recommends install git + +## Empty the directory, because we have to clone the Git repo. +RUN rm -rf ./* && chown node /app + +USER node +RUN git config --global user.email "no-reply@no-reply.com" +RUN git config --global user.name "PR Tester" +RUN git clone https://github.com/louislam/uptime-kuma.git . +RUN npm ci + +EXPOSE 3000 3001 +HEALTHCHECK --interval=60s --timeout=30s --start-period=180s --retries=5 CMD extra/healthcheck +CMD ["npm", "run", "start-pr-test"] + +############################################ +# Upload the artifact to Github +############################################ +FROM louislam/uptime-kuma:base2 AS upload-artifact +WORKDIR / +RUN apt update && \ + apt --yes install curl file + +COPY --from=build /app /app + +ARG VERSION +ARG GITHUB_TOKEN +ARG TARGETARCH +ARG PLATFORM=debian +ARG FILE=$PLATFORM-$TARGETARCH-$VERSION.tar.gz +ARG DIST=dist.tar.gz + +RUN chmod +x /app/extra/upload-github-release-asset.sh + +# Full Build +# RUN tar -zcvf $FILE app +# RUN /app/extra/upload-github-release-asset.sh github_api_token=$GITHUB_TOKEN owner=louislam repo=uptime-kuma tag=$VERSION filename=$FILE + +# Dist only +RUN cd /app && tar -zcvf $DIST dist +RUN /app/extra/upload-github-release-asset.sh github_api_token=$GITHUB_TOKEN owner=louislam repo=uptime-kuma tag=$VERSION filename=/app/$DIST + diff --git a/docker/etc/nscd.conf b/docker/etc/nscd.conf new file mode 100644 index 0000000..18b92bf --- /dev/null +++ b/docker/etc/nscd.conf @@ -0,0 +1,90 @@ +# +# /etc/nscd.conf +# +# An example Name Service Cache config file. This file is needed by nscd. +# +# Legal entries are: +# +# logfile +# debug-level +# threads +# max-threads +# server-user +# server-user is ignored if nscd is started with -S parameters +# stat-user +# reload-count unlimited| +# paranoia +# restart-interval