From 5b6fbdd68a26a71cca21a0ee4d5f0081d57329dc Mon Sep 17 00:00:00 2001 From: lyc8503 Date: Tue, 20 Aug 2024 17:23:19 +0800 Subject: [PATCH 1/6] fix #58: take hyperlink underline back --- components/MonitorDetail.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/MonitorDetail.tsx b/components/MonitorDetail.tsx index 2944360..c7e47f4 100644 --- a/components/MonitorDetail.tsx +++ b/components/MonitorDetail.tsx @@ -44,7 +44,7 @@ export default function MonitorDetail({ const monitorNameElement = ( {monitor.statusPageLink ? ( - + {statusIcon} {monitor.name} ) : ( From 79ea2fba2c7b1ededb4e3d99e957c950d3b8df11 Mon Sep 17 00:00:00 2001 From: lyc8503 Date: Wed, 21 Aug 2024 11:00:53 +0800 Subject: [PATCH 2/6] fix #54: show date in popup and add touchscreen support --- components/DetailBar.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/DetailBar.tsx b/components/DetailBar.tsx index 6be4377..88769b6 100644 --- a/components/DetailBar.tsx +++ b/components/DetailBar.tsx @@ -47,12 +47,13 @@ export default function DetailBar({ -
{dayPercent + '%'}
+
{dayPercent + '% at ' + new Date(dayStart * 1000).toLocaleDateString()}
{dayDownTime > 0 && (
{`Down for ${moment.preciseDiff(moment(0), moment(dayDownTime * 1000))}`}
)} From e2b469c39d847d31e037bcea94cfc4cbf6487263 Mon Sep 17 00:00:00 2001 From: lyc8503 Date: Wed, 21 Aug 2024 14:48:21 +0800 Subject: [PATCH 3/6] fix #12: http basic auth --- README.md | 4 ++++ middleware.ts | 27 +++++++++++++++++++++++++++ uptime.config.ts | 4 +++- 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 middleware.ts diff --git a/README.md b/README.md index 242284c..0a118fe 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ A more advanced, serverless, and free uptime monitoring & status page solution, - Responsive UI that adapts to your system theme - Customizable status page - Use your own domain with CNAME + - Optional password authentication (private status page) + - JSON API for fetching realtime status data ## 👀Demo @@ -44,4 +46,6 @@ Please refer to [Wiki](https://github.com/lyc8503/UptimeFlare/wiki) - [ ] SSL certificate checks - [ ] Self-host Dockerfile - [ ] Incident timeline +- [ ] Improve `checkLocationWorkerRoute` and fix possible `proxy failed` +- [ ] Groups - [x] Remove old incidents diff --git a/middleware.ts b/middleware.ts new file mode 100644 index 0000000..78ec4d8 --- /dev/null +++ b/middleware.ts @@ -0,0 +1,27 @@ +import { NextResponse } from 'next/server' +import type { NextRequest } from 'next/server' +import { workerConfig } from './uptime.config' + +export async function middleware(request: NextRequest) { + // @ts-ignore + const passwordProtection = workerConfig.passwordProtection + if (passwordProtection) { + const authHeader = request.headers.get('Authorization') + let authenticated = false + const expected = 'Basic ' + btoa(passwordProtection) + + if (authHeader && authHeader.length === expected.length) { + // a simple timing-safe compare + authenticated = true; + for (let i = 0; i < authHeader.length; i++) { + if (authHeader[i] !== expected[i]) authenticated = false; + } + } + + if (!authenticated) { + return NextResponse.json( + { code: 401, message: "Not authenticated" }, { status: 401, headers: { 'WWW-Authenticate': 'Basic' } } + ) + } + } +} diff --git a/uptime.config.ts b/uptime.config.ts index 00be288..acddf06 100644 --- a/uptime.config.ts +++ b/uptime.config.ts @@ -10,8 +10,10 @@ const pageConfig = { } const workerConfig = { - // Write KV at most every 3 minutes unless the status changed. + // Write KV at most every 3 minutes unless the status changed kvWriteCooldownMinutes: 3, + // Enable HTTP Basic auth for status page & API by uncommenting the line below, format `:` + // passwordProtection: 'username:password', // Define all your monitors here monitors: [ // Example HTTP Monitor From 35b7f253d97f2bd05857db57e4cd29668651e5c7 Mon Sep 17 00:00:00 2001 From: WKK Date: Wed, 21 Aug 2024 16:57:40 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=AD=E6=96=87README?= =?UTF-8?q?=E4=BB=8B=E7=BB=8D=20=20|=20=20Add=20Chinese=20README=20introdu?= =?UTF-8?q?ction=20(#45)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add chinese readme * polish translation --------- Co-authored-by: lyc8503 --- README.md | 5 +++++ README_zh-CN.md | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 README_zh-CN.md diff --git a/README.md b/README.md index 0a118fe..0c2506d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,8 @@ +
+ English + 简体中文 +
+ # ✔[UptimeFlare](https://github.com/lyc8503/UptimeFlare) A more advanced, serverless, and free uptime monitoring & status page solution, powered by Cloudflare Workers, complete with a user-friendly interface. diff --git a/README_zh-CN.md b/README_zh-CN.md new file mode 100644 index 0000000..2d2cd52 --- /dev/null +++ b/README_zh-CN.md @@ -0,0 +1,39 @@ +
+ English + 简体中文 +
+ +# ✔[UptimeFlare](https://github.com/lyc8503/UptimeFlare) + +一个由 Cloudflare Workers 驱动的功能丰富、Serverless 且免费的 Uptime 监控及状态页面。 + +## ⭐功能 +- 开源,易于部署(全程无需本地工具,耗时不到 10 分钟),且完全免费 +- 监控功能 + - 最多支持 50 个 1 分钟精度的检查 + - 支持指定全球 [310+ 个城市](https://www.cloudflare.com/network/) 的监控节点 + - 支持 HTTP/HTTPS/TCP 端口监控 + - 最多 90 天的 uptime 历史记录和 uptime 百分比跟踪 + - 可自定义的 HTTP(s) 请求方法、头和主体 + - 可自定义的 HTTP(s) 状态码和关键字检查 + - 支持 [100 多个通知渠道](https://github.com/caronc/apprise/wiki) 的宕机消息通知 + - 可自定义的 Webhook +- 状态页面 + - 所有类型监控的交互式 ping(响应时间)图表 + - 响应式 UI,自适应PC/手机屏幕,及亮色/暗色系统主题 + - 配置选项丰富的状态页面 + - 可使用您自己的域名与 CNAME + - 可选的密码认证(私人状态页面) + - 用于获取实时状态数据的 JSON API + +## 👀演示 + +我自己的状态页面(在线演示):https://uptimeflare.pages.dev/ + +一些截图: + +![桌面,浅色主题](docs/desktop.png) + +## ⚡快速入门 / 📄文档 + +请参阅 [Wiki](https://github.com/lyc8503/UptimeFlare/wiki) From be832b031254f849230e371cfcb1e0035317b6a7 Mon Sep 17 00:00:00 2001 From: lyc8503 Date: Wed, 21 Aug 2024 17:07:39 +0800 Subject: [PATCH 5/6] add missing tag --- README.md | 2 +- README_zh-CN.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0c2506d..8221067 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ diff --git a/README_zh-CN.md b/README_zh-CN.md index 2d2cd52..3e867de 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -1,6 +1,6 @@
English - 简体中文 + 简体中文
# ✔[UptimeFlare](https://github.com/lyc8503/UptimeFlare) From 0303dc2991f0442d03dd78dacadfb53646d9dcff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E9=9B=A8=E6=B6=B5?= <106737705+wuyuhanzijin@users.noreply.github.com> Date: Tue, 17 Sep 2024 11:38:32 +0800 Subject: [PATCH 6/6] Update uptime.config.ts --- uptime.config.ts | 89 ++++++++++++++---------------------------------- 1 file changed, 26 insertions(+), 63 deletions(-) diff --git a/uptime.config.ts b/uptime.config.ts index acddf06..12c51b8 100644 --- a/uptime.config.ts +++ b/uptime.config.ts @@ -1,79 +1,42 @@ const pageConfig = { - // Title for your status page - title: "lyc8503's Status Page", - // Links shown at the header of your status page, could set `highlight` to `true` + title: "凌云·LinYun 服务状态", links: [ - { link: 'https://github.com/lyc8503', label: 'GitHub' }, - { link: 'https://blog.lyc8503.net/', label: 'Blog' }, - { link: 'mailto:me@lyc8503.net', label: 'Email Me', highlight: true }, + { link: 'https://www.linyunlink.top/links/', label: '友情链接'}, + { link: 'https://www.linyunlink.top/', label: '博客', highlight: true }, ], } const workerConfig = { - // Write KV at most every 3 minutes unless the status changed - kvWriteCooldownMinutes: 3, - // Enable HTTP Basic auth for status page & API by uncommenting the line below, format `:` - // passwordProtection: 'username:password', + // Write KV at most every 3 minutes unless the status changed. + kvWriteCooldownMinutes: 10, // Define all your monitors here monitors: [ - // Example HTTP Monitor + // ==========[凌云服务监控]========== { - // `id` should be unique, history will be kept if the `id` remains constant - id: 'foo_monitor', - // `name` is used at status page and callback message - name: 'My API Monitor', - // `method` should be a valid HTTP Method + id: 'linyun_blog_monitor', + name: '凌云·LinYun 博客', + method: 'GET', + target: 'https://www.linyunlink.top/', + tooltip: '凌云·LinYun 博客', + statusPageLink: 'https://www.linyunlink.top/', + }, + { + id: 'linyun_twikoo_monitor', + name: '凌云·LinYun Twikoo评论系统', method: 'POST', - // `target` is a valid URL - target: 'https://example.com', - // [OPTIONAL] `tooltip` is ONLY used at status page to show a tooltip - tooltip: 'This is a tooltip for this monitor', - // [OPTIONAL] `statusPageLink` is ONLY used for clickable link at status page - statusPageLink: 'https://example.com', - // [OPTIONAL] `expectedCodes` is an array of acceptable HTTP response codes, if not specified, default to 2xx - expectedCodes: [200], - // [OPTIONAL] `timeout` in millisecond, if not specified, default to 10000 - timeout: 10000, - // [OPTIONAL] headers to be sent - headers: { - 'User-Agent': 'Uptimeflare', - Authorization: 'Bearer YOUR_TOKEN_HERE', - }, - // [OPTIONAL] body to be sent - body: 'Hello, world!', - // [OPTIONAL] if specified, the response must contains the keyword to be considered as operational. - responseKeyword: 'success', - // [OPTIONAL] if specified, the check will run in your specified region, - // refer to docs https://github.com/lyc8503/UptimeFlare/wiki/Geo-specific-checks-setup before setting this value - checkLocationWorkerRoute: 'https://xxx.example.com', + target: 'https://twikoo.linyunlink.top/', + tooltip: '凌云·LinYun Twikoo 评论服务后端', + statusPageLink: 'https://twikoo.linyunlink.top/', }, - // Example TCP Monitor { - id: 'test_tcp_monitor', - name: 'Example TCP Monitor', - // `method` should be `TCP_PING` for tcp monitors - method: 'TCP_PING', - // `target` should be `host:port` for tcp monitors - target: '1.2.3.4:22', - tooltip: 'My production server SSH', - statusPageLink: 'https://example.com', - timeout: 5000, - }, + id: 'linyun_image_monitor', + name: '凌云·LinYun 图片托管站', + method: 'GET', + target: 'https://image.linyunlink.top/', + tooltip: '凌云·LinYun 图片托管站', + statusPageLink: 'https://image.linyunlink.top/', + } ], - notification: { - // [Optional] apprise API server URL - // if not specified, no notification will be sent - appriseApiServer: "https://apprise.example.com/notify", - // [Optional] recipient URL for apprise, refer to https://github.com/caronc/apprise - // if not specified, no notification will be sent - recipientUrl: "tgram://bottoken/ChatID", - // [Optional] timezone used in notification messages, default to "Etc/GMT" - timeZone: "Asia/Shanghai", - // [Optional] grace period in minutes before sending a notification - // notification will be sent only if the monitor is down for N continuous checks after the initial failure - // if not specified, notification will be sent immediately - gracePeriod: 5, - }, callbacks: { onStatusChange: async ( env: any,