Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
206c6df4aa | ||
|
|
e145068287 | ||
|
|
987ed64256 | ||
|
|
ae85af26bf | ||
|
|
023cf5782d | ||
|
|
babe5ae177 | ||
|
|
4222d39a8b | ||
|
|
fb69e29adf | ||
|
|
0d90083e63 | ||
|
|
ec129e3604 |
No files matched your search
@@ -48,6 +48,10 @@ You can see the latest build of [Checkmate](https://checkmate-demo.bluewavelabs.
|
|||||||
|
|
||||||
Usage instructions can be found [here](https://checkmate.so/docs).
|
Usage instructions can be found [here](https://checkmate.so/docs).
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
- [Docker](https://www.docker.com/) installed
|
||||||
|
- [Git](https://git-scm.com/) installed
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
See installation instructions in [Checkmate documentation portal](https://checkmate.so/docs).
|
See installation instructions in [Checkmate documentation portal](https://checkmate.so/docs).
|
||||||
@@ -80,7 +84,7 @@ You can see the memory footprint of MongoDB and Redis on the same server (398Mb
|
|||||||
If you have any questions, suggestions or comments, you have several options:
|
If you have any questions, suggestions or comments, you have several options:
|
||||||
|
|
||||||
- [Discord channel](https://discord.gg/NAb6H3UTjK) (preferred)
|
- [Discord channel](https://discord.gg/NAb6H3UTjK) (preferred)
|
||||||
- [GitHub Discussions](https://github.com/bluewave-labs/bluewave-uptime/discussions) (we check here from time to time)
|
- [GitHub Discussions](https://github.com/bluewave-labs/Checkmate/discussions) (we check here from time to time)
|
||||||
|
|
||||||
Feel free to ask questions or share your ideas - we'd love to hear from you!
|
Feel free to ask questions or share your ideas - we'd love to hear from you!
|
||||||
|
|
||||||
@@ -167,7 +171,7 @@ Here's how you can contribute:
|
|||||||
<img src="https://contrib.rocks/image?repo=bluewave-labs/checkmate" />
|
<img src="https://contrib.rocks/image?repo=bluewave-labs/checkmate" />
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
[](https://star-history.com/#bluewave-labs/bluewave-uptime&Date)
|
[](https://star-history.com/#bluewave-labs/Checkmate&Date)
|
||||||
|
|
||||||
## Our sponsors
|
## Our sponsors
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import Stack from "@mui/material/Stack";
|
|||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
|
|
||||||
import { useTheme, type Theme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import { useMemo, useState, useEffect } from "react";
|
import { useMemo, useState, useEffect } from "react";
|
||||||
import { getInfraGaugeColor } from "@/Utils/MonitorUtils";
|
import { getInfraGaugeColor } from "@/Utils/MonitorUtils";
|
||||||
|
|
||||||
@@ -17,10 +17,6 @@ export const Gauge = ({
|
|||||||
strokeWidth = 15,
|
strokeWidth = 15,
|
||||||
precision = 1,
|
precision = 1,
|
||||||
unit = "%",
|
unit = "%",
|
||||||
// colorFn lets callers override the default color logic.
|
|
||||||
// The Gauge was originally designed for metrics where higher values are worse (e.g., CPU usage).
|
|
||||||
// PageSpeed scores are the opposite—higher is better—so a custom colorFn can be used to invert the behavior.
|
|
||||||
colorFn,
|
|
||||||
}: {
|
}: {
|
||||||
isLoading?: boolean;
|
isLoading?: boolean;
|
||||||
progress?: number;
|
progress?: number;
|
||||||
@@ -28,7 +24,6 @@ export const Gauge = ({
|
|||||||
strokeWidth?: number;
|
strokeWidth?: number;
|
||||||
precision?: number;
|
precision?: number;
|
||||||
unit?: string;
|
unit?: string;
|
||||||
colorFn?: (val: number, theme: Theme) => string;
|
|
||||||
}) => {
|
}) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const progressWithinRange = Math.max(MINIMUM_VALUE, Math.min(progress, MAXIMUM_VALUE));
|
const progressWithinRange = Math.max(MINIMUM_VALUE, Math.min(progress, MAXIMUM_VALUE));
|
||||||
@@ -53,8 +48,7 @@ export const Gauge = ({
|
|||||||
return () => clearTimeout(timer);
|
return () => clearTimeout(timer);
|
||||||
}, [progress, circumference, strokeLength]);
|
}, [progress, circumference, strokeLength]);
|
||||||
|
|
||||||
const resolvedColorFn = colorFn ?? getInfraGaugeColor;
|
const fillColor = getInfraGaugeColor(progressWithinRange, theme);
|
||||||
const fillColor = resolvedColorFn(progressWithinRange, theme);
|
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ export const useMonitorForm = ({
|
|||||||
matchMethod: data?.matchMethod || "",
|
matchMethod: data?.matchMethod || "",
|
||||||
expectedValue: data?.expectedValue || "",
|
expectedValue: data?.expectedValue || "",
|
||||||
jsonPath: data?.jsonPath || "",
|
jsonPath: data?.jsonPath || "",
|
||||||
|
customUserAgent: data?.customUserAgent || "",
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case "ping":
|
case "ping":
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ export const useSettingsForm = ({ data = null }: UseSettingsFormOptions = {}) =>
|
|||||||
: 80,
|
: 80,
|
||||||
},
|
},
|
||||||
checkTTL: data?.checkTTL ?? 30,
|
checkTTL: data?.checkTTL ?? 30,
|
||||||
|
defaultUserAgent: data?.defaultUserAgent || "",
|
||||||
pagespeedApiKey: "",
|
pagespeedApiKey: "",
|
||||||
systemEmailPassword: "",
|
systemEmailPassword: "",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ export const useStatusPageForm = ({
|
|||||||
showUptimePercentage: data?.showUptimePercentage ?? true,
|
showUptimePercentage: data?.showUptimePercentage ?? true,
|
||||||
showAdminLoginLink: data?.showAdminLoginLink ?? false,
|
showAdminLoginLink: data?.showAdminLoginLink ?? false,
|
||||||
showInfrastructure: data?.showInfrastructure ?? false,
|
showInfrastructure: data?.showInfrastructure ?? false,
|
||||||
showPageSpeed: data?.showPageSpeed ?? false,
|
|
||||||
customCSS: data?.customCSS || "",
|
customCSS: data?.customCSS || "",
|
||||||
logo: transformLogo(data?.logo),
|
logo: transformLogo(data?.logo),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -795,6 +795,40 @@ const CreateMonitorPage = () => {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{watchedType === "http" && (
|
||||||
|
<ConfigBox
|
||||||
|
title={t("pages.createMonitor.form.userAgent.title")}
|
||||||
|
subtitle={t("pages.createMonitor.form.userAgent.description")}
|
||||||
|
rightContent={
|
||||||
|
<Controller
|
||||||
|
name="customUserAgent"
|
||||||
|
control={control}
|
||||||
|
render={({ field, fieldState }) => (
|
||||||
|
<TextField
|
||||||
|
{...field}
|
||||||
|
value={field.value ?? ""}
|
||||||
|
type="text"
|
||||||
|
fieldLabel={t("pages.createMonitor.form.userAgent.option.label")}
|
||||||
|
placeholder={t("pages.createMonitor.form.userAgent.option.placeholder")}
|
||||||
|
fullWidth
|
||||||
|
error={!!fieldState.error}
|
||||||
|
helperText={fieldState.error?.message ?? ""}
|
||||||
|
onChange={(e) => {
|
||||||
|
field.onChange(
|
||||||
|
e.target.value
|
||||||
|
.replace(/[<>]/g, "")
|
||||||
|
.replace(/(?:javascript|data|vbscript):/gi, "")
|
||||||
|
.replace(/[^\t\x20-\x7E\x80-\xFF]/g, "") // RFC 7230 header-safe chars only
|
||||||
|
.slice(0, 500)
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
{watchedType === "http" && (
|
{watchedType === "http" && (
|
||||||
<ConfigBox
|
<ConfigBox
|
||||||
title={t("pages.createMonitor.form.advanced.title")}
|
title={t("pages.createMonitor.form.advanced.title")}
|
||||||
|
|||||||
@@ -425,6 +425,39 @@ export const SettingsPage = () => {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{/* Default User-Agent - Admin Only */}
|
||||||
|
{isAdmin && (
|
||||||
|
<ConfigBox
|
||||||
|
title={t("pages.settings.form.userAgent.title")}
|
||||||
|
subtitle={t("pages.settings.form.userAgent.description")}
|
||||||
|
rightContent={
|
||||||
|
<Controller
|
||||||
|
name="defaultUserAgent"
|
||||||
|
control={form.control}
|
||||||
|
render={({ field, fieldState }) => (
|
||||||
|
<TextField
|
||||||
|
{...field}
|
||||||
|
value={field.value ?? ""}
|
||||||
|
fieldLabel={t("pages.settings.form.userAgent.option.label")}
|
||||||
|
placeholder={t("pages.settings.form.userAgent.option.placeholder")}
|
||||||
|
error={!!fieldState.error}
|
||||||
|
helperText={fieldState.error?.message}
|
||||||
|
onChange={(e) => {
|
||||||
|
field.onChange(
|
||||||
|
e.target.value
|
||||||
|
.replace(/[<>]/g, "")
|
||||||
|
.replace(/(?:javascript|data|vbscript):/gi, "")
|
||||||
|
.replace(/[^\t\x20-\x7E\x80-\xFF]/g, "") // RFC 7230 header-safe chars only
|
||||||
|
.slice(0, 500)
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Clear All Stats */}
|
{/* Clear All Stats */}
|
||||||
{isAdmin && (
|
{isAdmin && (
|
||||||
<ConfigBox
|
<ConfigBox
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import { useStatusPageForm } from "@/Hooks/useStatusPageForm";
|
|||||||
import type { StatusPageFormData } from "@/Validation/statusPage";
|
import type { StatusPageFormData } from "@/Validation/statusPage";
|
||||||
import { useGet, usePost, usePut, useDelete } from "@/Hooks/UseApi";
|
import { useGet, usePost, usePut, useDelete } from "@/Hooks/UseApi";
|
||||||
import type { Monitor } from "@/Types/Monitor";
|
import type { Monitor } from "@/Types/Monitor";
|
||||||
import type { StatusPageType, StatusPageResponse } from "@/Types/StatusPage";
|
import type { MonitorDisplayType, StatusPageResponse } from "@/Types/StatusPage";
|
||||||
import { getMonitorTypeLabel } from "@/Types/StatusPage";
|
import { getMonitorTypeLabel } from "@/Types/StatusPage";
|
||||||
import timezones from "@/Utils/timezones.json";
|
import timezones from "@/Utils/timezones.json";
|
||||||
import { useNavigate, useParams } from "react-router-dom";
|
import { useNavigate, useParams } from "react-router-dom";
|
||||||
@@ -37,17 +37,9 @@ import { HeaderConfigStatusControls } from "./Components/HeaderConfigStatusContr
|
|||||||
|
|
||||||
const monitorsUrl = (() => {
|
const monitorsUrl = (() => {
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
[
|
["http", "ping", "port", "docker", "game", "grpc", "websocket", "hardware"].forEach(
|
||||||
"http",
|
(type) => params.append("type", type)
|
||||||
"ping",
|
);
|
||||||
"port",
|
|
||||||
"docker",
|
|
||||||
"game",
|
|
||||||
"grpc",
|
|
||||||
"websocket",
|
|
||||||
"hardware",
|
|
||||||
"pagespeed",
|
|
||||||
].forEach((type) => params.append("type", type));
|
|
||||||
return `/monitors/team?${params.toString()}`;
|
return `/monitors/team?${params.toString()}`;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
@@ -67,9 +59,7 @@ const CreateStatusPage = () => {
|
|||||||
// Fetch existing status page data when configuring
|
// Fetch existing status page data when configuring
|
||||||
const { data: statusPageData, isLoading: isLoadingStatusPage } =
|
const { data: statusPageData, isLoading: isLoadingStatusPage } =
|
||||||
useGet<StatusPageResponse>(
|
useGet<StatusPageResponse>(
|
||||||
isCreate
|
isCreate ? null : `/status-page/${url}?type=uptime&type=infrastructure`
|
||||||
? null
|
|
||||||
: `/status-page/${url}?type=uptime&type=infrastructure&type=pagespeed`
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const { data: monitorsResponse } = useGet<Monitor[]>(monitorsUrl);
|
const { data: monitorsResponse } = useGet<Monitor[]>(monitorsUrl);
|
||||||
@@ -101,16 +91,14 @@ const CreateStatusPage = () => {
|
|||||||
}, [defaults, reset]);
|
}, [defaults, reset]);
|
||||||
|
|
||||||
const watchedMonitorIds: string[] = form.watch("monitors") ?? [];
|
const watchedMonitorIds: string[] = form.watch("monitors") ?? [];
|
||||||
const computedTypes: StatusPageType[] = useMemo(() => {
|
const computedTypes: MonitorDisplayType[] = useMemo(() => {
|
||||||
const selectedMonitors = (watchedMonitorIds ?? [])
|
const selectedMonitors = (watchedMonitorIds ?? [])
|
||||||
.map((id) => monitors.find((m) => m.id === id))
|
.map((id) => monitors.find((m) => m.id === id))
|
||||||
.filter((m): m is Monitor => m !== undefined);
|
.filter((m): m is Monitor => m !== undefined);
|
||||||
|
|
||||||
const typesSet = new Set<StatusPageType>();
|
const typesSet = new Set<MonitorDisplayType>();
|
||||||
selectedMonitors.forEach((m) => {
|
selectedMonitors.forEach((m) => {
|
||||||
if (m.type === "hardware") typesSet.add("infrastructure");
|
typesSet.add(m.type === "hardware" ? "infrastructure" : "uptime");
|
||||||
else if (m.type === "pagespeed") typesSet.add("pagespeed");
|
|
||||||
else typesSet.add("uptime");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return typesSet.size ? Array.from(typesSet) : ["uptime"];
|
return typesSet.size ? Array.from(typesSet) : ["uptime"];
|
||||||
@@ -151,7 +139,6 @@ const CreateStatusPage = () => {
|
|||||||
fd.append("showUptimePercentage", String(data.showUptimePercentage));
|
fd.append("showUptimePercentage", String(data.showUptimePercentage));
|
||||||
fd.append("showAdminLoginLink", String(data.showAdminLoginLink));
|
fd.append("showAdminLoginLink", String(data.showAdminLoginLink));
|
||||||
fd.append("showInfrastructure", String(data.showInfrastructure));
|
fd.append("showInfrastructure", String(data.showInfrastructure));
|
||||||
fd.append("showPageSpeed", String(data.showPageSpeed));
|
|
||||||
|
|
||||||
data.monitors.forEach((monitorId) => {
|
data.monitors.forEach((monitorId) => {
|
||||||
fd.append("monitors[]", monitorId);
|
fd.append("monitors[]", monitorId);
|
||||||
@@ -488,21 +475,6 @@ const CreateStatusPage = () => {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<Controller
|
|
||||||
name="showPageSpeed"
|
|
||||||
control={control}
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<Checkbox
|
|
||||||
checked={field.value}
|
|
||||||
onChange={field.onChange}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label={t("pages.statusPages.form.features.option.showPageSpeed.label")}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
{/* <Controller
|
{/* <Controller
|
||||||
name="showUptimePercentage"
|
name="showUptimePercentage"
|
||||||
control={control}
|
control={control}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { HistogramResponseTime, HeatmapResponseTime } from "@/Components/common"
|
|||||||
import { StatusLabel, BaseBox } from "@/Components/design-elements";
|
import { StatusLabel, BaseBox } from "@/Components/design-elements";
|
||||||
import { SwitchComponent } from "@/Components/inputs";
|
import { SwitchComponent } from "@/Components/inputs";
|
||||||
import { InfrastructureMetrics } from "@/Pages/StatusPage/Status/Components/InfrastructureMetrics";
|
import { InfrastructureMetrics } from "@/Pages/StatusPage/Status/Components/InfrastructureMetrics";
|
||||||
import { PageSpeedMetrics } from "@/Pages/StatusPage/Status/Components/PageSpeedMetrics";
|
|
||||||
|
|
||||||
import { useTheme, type Theme } from "@mui/material/styles";
|
import { useTheme, type Theme } from "@mui/material/styles";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
@@ -27,12 +26,8 @@ interface MonitorsListProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getMonitorBadgeStyles = (monitorType: string, theme: Theme) => {
|
const getMonitorBadgeStyles = (monitorType: string, theme: Theme) => {
|
||||||
const monitorColors: Record<string, string> = {
|
const bg =
|
||||||
hardware: theme.palette.info.light,
|
monitorType === "hardware" ? theme.palette.info.light : theme.palette.success.light;
|
||||||
pagespeed: theme.palette.warning.light,
|
|
||||||
};
|
|
||||||
|
|
||||||
const bg = monitorColors[monitorType] || theme.palette.success.light;
|
|
||||||
return {
|
return {
|
||||||
backgroundColor: bg,
|
backgroundColor: bg,
|
||||||
color: theme.palette.background.paper,
|
color: theme.palette.background.paper,
|
||||||
@@ -110,12 +105,6 @@ const MonitorContent = ({
|
|||||||
return <InfrastructureMetrics monitor={monitor} />;
|
return <InfrastructureMetrics monitor={monitor} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (monitor.type === "pagespeed") {
|
|
||||||
return statusPage.showPageSpeed === false ? null : (
|
|
||||||
<PageSpeedMetrics monitor={monitor} />
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (statusPage.showCharts === false) return null;
|
if (statusPage.showCharts === false) return null;
|
||||||
|
|
||||||
const checks = monitor.checks?.slice().reverse() ?? [];
|
const checks = monitor.checks?.slice().reverse() ?? [];
|
||||||
|
|||||||
@@ -1,122 +0,0 @@
|
|||||||
import Typography from "@mui/material/Typography";
|
|
||||||
import { Gauge } from "@/Components/design-elements";
|
|
||||||
import { useTheme } from "@mui/material/styles";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import type { Monitor } from "@/Types/Monitor";
|
|
||||||
import type { CheckSnapshot } from "@/Types/Check";
|
|
||||||
import Grid from "@mui/material/Grid";
|
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
import { LAYOUT, SPACING } from "@/Utils/Theme/constants";
|
|
||||||
import { getPageSpeedGaugeColor } from "@/Utils/MonitorUtils";
|
|
||||||
|
|
||||||
const GAUGE_RADIUS = 60;
|
|
||||||
const GAUGE_STROKE_WIDTH = 12;
|
|
||||||
|
|
||||||
interface StatusPageMonitor extends Monitor {
|
|
||||||
checks?: Monitor["recentChecks"];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MetricConfig {
|
|
||||||
key: string;
|
|
||||||
label: string;
|
|
||||||
progress: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
const MetricItem = ({ label, progress }: MetricConfig) => {
|
|
||||||
const theme = useTheme();
|
|
||||||
return (
|
|
||||||
<Grid
|
|
||||||
size={{ xs: 12, md: 3 }}
|
|
||||||
display="flex"
|
|
||||||
flexDirection="column"
|
|
||||||
alignItems="center"
|
|
||||||
textAlign="center"
|
|
||||||
gap={theme.spacing(SPACING.LG)}
|
|
||||||
padding={theme.spacing(LAYOUT.XS)}
|
|
||||||
sx={{
|
|
||||||
borderRight: { xs: "none", md: `1px solid ${theme.palette.divider}` },
|
|
||||||
borderBottom: { xs: `1px solid ${theme.palette.divider}`, md: "none" },
|
|
||||||
"&:last-child": {
|
|
||||||
borderRight: "none",
|
|
||||||
borderBottom: "none",
|
|
||||||
paddingBottom: theme.spacing(SPACING.LG),
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
display="flex"
|
|
||||||
flexDirection="column"
|
|
||||||
alignItems="center"
|
|
||||||
>
|
|
||||||
<Gauge
|
|
||||||
progress={progress}
|
|
||||||
radius={GAUGE_RADIUS}
|
|
||||||
strokeWidth={GAUGE_STROKE_WIDTH}
|
|
||||||
colorFn={getPageSpeedGaugeColor}
|
|
||||||
/>
|
|
||||||
<Typography variant="body2">{label}</Typography>
|
|
||||||
</Box>
|
|
||||||
</Grid>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const buildMetrics = (check: CheckSnapshot, t: (key: string) => string): MetricConfig[] =>
|
|
||||||
[
|
|
||||||
{
|
|
||||||
key: "performance",
|
|
||||||
label: t("pages.statusPages.monitorsList.pagespeed.performance"),
|
|
||||||
progress: check.performance,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "accessibility",
|
|
||||||
label: t("pages.statusPages.monitorsList.pagespeed.accessibility"),
|
|
||||||
progress: check.accessibility,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "bestPractices",
|
|
||||||
label: t("pages.statusPages.monitorsList.pagespeed.bestPractices"),
|
|
||||||
progress: check.bestPractices,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "seo",
|
|
||||||
label: t("pages.statusPages.monitorsList.pagespeed.seo"),
|
|
||||||
progress: check.seo,
|
|
||||||
},
|
|
||||||
].filter((m): m is MetricConfig => m.progress !== undefined);
|
|
||||||
|
|
||||||
export const PageSpeedMetrics = ({ monitor }: { monitor: StatusPageMonitor }) => {
|
|
||||||
const theme = useTheme();
|
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
const latestCheck = monitor.recentChecks?.[0] ?? monitor.checks?.[0];
|
|
||||||
|
|
||||||
if (!latestCheck) {
|
|
||||||
return (
|
|
||||||
<Typography
|
|
||||||
variant="body2"
|
|
||||||
color={theme.palette.text.secondary}
|
|
||||||
>
|
|
||||||
{t("pages.statusPages.monitorsList.noData")}
|
|
||||||
</Typography>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const metrics = buildMetrics(latestCheck, t);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Grid
|
|
||||||
container
|
|
||||||
alignItems="center"
|
|
||||||
padding={theme.spacing(LAYOUT.LG)}
|
|
||||||
flex={1}
|
|
||||||
>
|
|
||||||
{metrics.map((metric) => (
|
|
||||||
<MetricItem
|
|
||||||
key={metric.key}
|
|
||||||
label={metric.label}
|
|
||||||
progress={metric.progress}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</Grid>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -23,9 +23,7 @@ const StatusPageView = () => {
|
|||||||
const isSmall = useMediaQuery(theme.breakpoints.down("md"));
|
const isSmall = useMediaQuery(theme.breakpoints.down("md"));
|
||||||
const isPublic = location.pathname.startsWith("/status/public");
|
const isPublic = location.pathname.startsWith("/status/public");
|
||||||
|
|
||||||
const apiUrl = url
|
const apiUrl = url ? `/status-page/${url}?type=uptime&type=infrastructure` : null;
|
||||||
? `/status-page/${url}?type=uptime&type=infrastructure&type=pagespeed`
|
|
||||||
: null;
|
|
||||||
|
|
||||||
const { data, isLoading, error } = useGet<StatusPageResponse>(
|
const { data, isLoading, error } = useGet<StatusPageResponse>(
|
||||||
apiUrl,
|
apiUrl,
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ export interface Monitor {
|
|||||||
gameId?: string;
|
gameId?: string;
|
||||||
grpcServiceName?: string;
|
grpcServiceName?: string;
|
||||||
group: string | null;
|
group: string | null;
|
||||||
|
customUserAgent?: string | null;
|
||||||
geoCheckEnabled?: boolean;
|
geoCheckEnabled?: boolean;
|
||||||
geoCheckLocations?: GeoContinent[];
|
geoCheckLocations?: GeoContinent[];
|
||||||
geoCheckInterval?: number;
|
geoCheckInterval?: number;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ export interface Settings {
|
|||||||
systemEmailRequireTLS: boolean;
|
systemEmailRequireTLS: boolean;
|
||||||
systemEmailRejectUnauthorized: boolean;
|
systemEmailRejectUnauthorized: boolean;
|
||||||
showURL: boolean;
|
showURL: boolean;
|
||||||
|
defaultUserAgent?: string;
|
||||||
singleton: boolean;
|
singleton: boolean;
|
||||||
globalThresholds?: SettingsThresholds;
|
globalThresholds?: SettingsThresholds;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import type { Monitor, MonitorType } from "@/Types/Monitor";
|
import type { Monitor, MonitorType } from "@/Types/Monitor";
|
||||||
export const StatusPageTypes = ["uptime", "infrastructure", "pagespeed"] as const;
|
export type MonitorDisplayType = "uptime" | "infrastructure";
|
||||||
export type StatusPageType = (typeof StatusPageTypes)[number];
|
|
||||||
|
|
||||||
export const MONITOR_TYPE_KEYS: Partial<Record<MonitorType, string>> = {
|
export const MONITOR_TYPE_KEYS: Partial<Record<MonitorType, string>> = {
|
||||||
http: "pages.common.monitors.monitorTypes.optionHttp",
|
http: "pages.common.monitors.monitorTypes.optionHttp",
|
||||||
@@ -26,7 +25,7 @@ export interface StatusPage {
|
|||||||
id: string;
|
id: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
teamId: string;
|
teamId: string;
|
||||||
type: StatusPageType[];
|
type: MonitorDisplayType[];
|
||||||
companyName: string;
|
companyName: string;
|
||||||
url: string;
|
url: string;
|
||||||
timezone?: string;
|
timezone?: string;
|
||||||
@@ -43,7 +42,6 @@ export interface StatusPage {
|
|||||||
showUptimePercentage: boolean;
|
showUptimePercentage: boolean;
|
||||||
showAdminLoginLink: boolean;
|
showAdminLoginLink: boolean;
|
||||||
showInfrastructure: boolean;
|
showInfrastructure: boolean;
|
||||||
showPageSpeed: boolean;
|
|
||||||
customCSS: string;
|
customCSS: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
|
|||||||
@@ -78,12 +78,6 @@ export const getPageSpeedPalette = (score: number): PaletteKey => {
|
|||||||
else return "error";
|
else return "error";
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getPageSpeedGaugeColor = (val: number, theme: any) => {
|
|
||||||
if (val >= 90) return theme.palette.success.main;
|
|
||||||
else if (val >= 50) return theme.palette.warning.light;
|
|
||||||
else return theme.palette.error.light;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const formatUrl = (url: string, maxLength: number = 55) => {
|
export const formatUrl = (url: string, maxLength: number = 55) => {
|
||||||
if (!url) return "";
|
if (!url) return "";
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,16 @@ const httpSchema = baseSchema.extend({
|
|||||||
matchMethod: z.enum(["equal", "include", "regex", ""]).optional(),
|
matchMethod: z.enum(["equal", "include", "regex", ""]).optional(),
|
||||||
expectedValue: z.string().optional(),
|
expectedValue: z.string().optional(),
|
||||||
jsonPath: z.string().optional(),
|
jsonPath: z.string().optional(),
|
||||||
|
customUserAgent: z
|
||||||
|
.string()
|
||||||
|
.max(500)
|
||||||
|
.regex(
|
||||||
|
/^[\t\x20-\x7E\x80-\xFF]*$/,
|
||||||
|
"Only printable characters, spaces, and tabs are allowed (RFC 7230 §3.2.6)"
|
||||||
|
)
|
||||||
|
.transform((val) => (val.trim() === "" ? null : val.trim()))
|
||||||
|
.nullable()
|
||||||
|
.optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Ping monitor schema
|
// Ping monitor schema
|
||||||
|
|||||||
@@ -12,6 +12,15 @@ export const settingsSchema = z.object({
|
|||||||
systemEmailSecure: z.boolean().optional(),
|
systemEmailSecure: z.boolean().optional(),
|
||||||
systemEmailPool: z.boolean().optional(),
|
systemEmailPool: z.boolean().optional(),
|
||||||
showURL: z.boolean().optional(),
|
showURL: z.boolean().optional(),
|
||||||
|
defaultUserAgent: z
|
||||||
|
.string()
|
||||||
|
.max(500)
|
||||||
|
.regex(
|
||||||
|
/^[\t\x20-\x7E\x80-\xFF]*$/,
|
||||||
|
"Only printable characters, spaces, and tabs are allowed (RFC 7230)"
|
||||||
|
)
|
||||||
|
.transform((val) => (val.trim() === "" ? null : val.trim()))
|
||||||
|
.optional(),
|
||||||
checkTTL: z
|
checkTTL: z
|
||||||
.number()
|
.number()
|
||||||
.int()
|
.int()
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { StatusPageTypes } from "@/Types/StatusPage";
|
|
||||||
|
|
||||||
export const statusPageSchema = z.object({
|
export const statusPageSchema = z.object({
|
||||||
companyName: z
|
companyName: z
|
||||||
@@ -15,7 +14,9 @@ export const statusPageSchema = z.object({
|
|||||||
"URL can only contain lowercase letters, numbers, and hyphens"
|
"URL can only contain lowercase letters, numbers, and hyphens"
|
||||||
),
|
),
|
||||||
timezone: z.string().optional(),
|
timezone: z.string().optional(),
|
||||||
type: z.array(z.enum(StatusPageTypes)).min(1, "At least one type is required"),
|
type: z
|
||||||
|
.array(z.enum(["uptime", "infrastructure"]))
|
||||||
|
.min(1, "At least one type is required"),
|
||||||
color: z.string().min(1, "Color is required"),
|
color: z.string().min(1, "Color is required"),
|
||||||
monitors: z.array(z.string()).min(1, "At least one monitor is required"),
|
monitors: z.array(z.string()).min(1, "At least one monitor is required"),
|
||||||
isPublished: z.boolean(),
|
isPublished: z.boolean(),
|
||||||
@@ -23,7 +24,6 @@ export const statusPageSchema = z.object({
|
|||||||
showUptimePercentage: z.boolean(),
|
showUptimePercentage: z.boolean(),
|
||||||
showAdminLoginLink: z.boolean(),
|
showAdminLoginLink: z.boolean(),
|
||||||
showInfrastructure: z.boolean(),
|
showInfrastructure: z.boolean(),
|
||||||
showPageSpeed: z.boolean(),
|
|
||||||
customCSS: z.string().optional(),
|
customCSS: z.string().optional(),
|
||||||
logo: z
|
logo: z
|
||||||
.object({
|
.object({
|
||||||
|
|||||||
@@ -324,7 +324,6 @@ const statusPageValidation = joi.object({
|
|||||||
showCharts: joi.boolean(),
|
showCharts: joi.boolean(),
|
||||||
showAdminLoginLink: joi.boolean(),
|
showAdminLoginLink: joi.boolean(),
|
||||||
showInfrastructure: joi.boolean(),
|
showInfrastructure: joi.boolean(),
|
||||||
showPageSpeed: joi.boolean(),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const settingsValidation = joi.object({
|
const settingsValidation = joi.object({
|
||||||
|
|||||||
+16
-10
@@ -527,6 +527,14 @@
|
|||||||
},
|
},
|
||||||
"title": "TLS/SSL settings"
|
"title": "TLS/SSL settings"
|
||||||
},
|
},
|
||||||
|
"userAgent": {
|
||||||
|
"title": "Custom User-Agent",
|
||||||
|
"description": "Override the User-Agent header sent with HTTP requests for this monitor. Useful for identifying Checkmate in WAF logs. Leave blank to use the global default.",
|
||||||
|
"option": {
|
||||||
|
"label": "User-Agent",
|
||||||
|
"placeholder": "Checkmate/X.X (uptime monitor)"
|
||||||
|
}
|
||||||
|
},
|
||||||
"incidents": {
|
"incidents": {
|
||||||
"description": "A sliding window is used to determine when a monitor goes down. The status of a monitor will only change when the percentage of checks in the sliding window meet the specified value.",
|
"description": "A sliding window is used to determine when a monitor goes down. The status of a monitor will only change when the percentage of checks in the sliding window meet the specified value.",
|
||||||
"option": {
|
"option": {
|
||||||
@@ -1051,6 +1059,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"userAgent": {
|
||||||
|
"title": "Default User-Agent",
|
||||||
|
"description": "Set a default User-Agent header sent with all HTTP uptime monitor requests. Individual monitors can override this. Useful for identifying Checkmate in WAF logs and whitelists.",
|
||||||
|
"option": {
|
||||||
|
"label": "Default User-Agent",
|
||||||
|
"placeholder": "Checkmate/X.X (uptime monitor)"
|
||||||
|
}
|
||||||
|
},
|
||||||
"stats": {
|
"stats": {
|
||||||
"title": "Monitor history",
|
"title": "Monitor history",
|
||||||
"description": "Clear all monitoring history and statistics for your team. This action is irreversible.",
|
"description": "Clear all monitoring history and statistics for your team. This action is irreversible.",
|
||||||
@@ -1202,13 +1218,6 @@
|
|||||||
"used": "Used",
|
"used": "Used",
|
||||||
"total": "Total"
|
"total": "Total"
|
||||||
},
|
},
|
||||||
"pagespeed": {
|
|
||||||
"title": "PageSpeed",
|
|
||||||
"performance": "Performance",
|
|
||||||
"accessibility": "Accessibility",
|
|
||||||
"bestPractices": "Best Practices",
|
|
||||||
"seo": "SEO"
|
|
||||||
},
|
|
||||||
"uptime": {
|
"uptime": {
|
||||||
"title": "Uptime",
|
"title": "Uptime",
|
||||||
"responseTime": "Response time"
|
"responseTime": "Response time"
|
||||||
@@ -1307,9 +1316,6 @@
|
|||||||
},
|
},
|
||||||
"showInfrastructure": {
|
"showInfrastructure": {
|
||||||
"label": "Show infrastructure metrics"
|
"label": "Show infrastructure metrics"
|
||||||
},
|
|
||||||
"showPageSpeed": {
|
|
||||||
"label": "Show PageSpeed scores"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
import type { Pool } from "pg";
|
|
||||||
|
|
||||||
export const addShowPageSpeedToStatusPages = async (pool: Pool) => {
|
|
||||||
await pool.query(`
|
|
||||||
ALTER TABLE status_pages
|
|
||||||
ADD COLUMN IF NOT EXISTS show_page_speed BOOLEAN DEFAULT FALSE;
|
|
||||||
`);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const dropShowPageSpeedFromStatusPages = async (pool: Pool) => {
|
|
||||||
await pool.query(`
|
|
||||||
ALTER TABLE status_pages
|
|
||||||
DROP COLUMN IF EXISTS show_page_speed;
|
|
||||||
`);
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import type { Pool } from "pg";
|
||||||
|
|
||||||
|
export const addUserAgentFields = async (pool: Pool) => {
|
||||||
|
await pool.query(`
|
||||||
|
ALTER TABLE monitors
|
||||||
|
ADD COLUMN IF NOT EXISTS custom_user_agent TEXT;
|
||||||
|
|
||||||
|
ALTER TABLE app_settings
|
||||||
|
ADD COLUMN IF NOT EXISTS default_user_agent TEXT;
|
||||||
|
`);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const dropUserAgentFields = async (pool: Pool) => {
|
||||||
|
await pool.query(`
|
||||||
|
ALTER TABLE monitors
|
||||||
|
DROP COLUMN IF EXISTS custom_user_agent;
|
||||||
|
|
||||||
|
ALTER TABLE app_settings
|
||||||
|
DROP COLUMN IF EXISTS default_user_agent;
|
||||||
|
`);
|
||||||
|
};
|
||||||
@@ -21,7 +21,7 @@ import { createStatusPages, dropStatusPages } from "./0018_create_status_pages.j
|
|||||||
import { createAppSettings, dropAppSettings } from "./0019_create_app_settings.js";
|
import { createAppSettings, dropAppSettings } from "./0019_create_app_settings.js";
|
||||||
import { createContinuousAggregates, dropContinuousAggregates } from "./0020_create_continuous_aggregates.js";
|
import { createContinuousAggregates, dropContinuousAggregates } from "./0020_create_continuous_aggregates.js";
|
||||||
import { createRetentionCompression, dropRetentionCompression } from "./0021_create_retention_compression.js";
|
import { createRetentionCompression, dropRetentionCompression } from "./0021_create_retention_compression.js";
|
||||||
import { addShowPageSpeedToStatusPages, dropShowPageSpeedFromStatusPages } from "./0022_add_show_page_speed_to_status_pages.js";
|
import { addUserAgentFields, dropUserAgentFields } from "./0022_add_user_agent_fields.js";
|
||||||
|
|
||||||
const SERVICE_NAME = "TimescaleDB Migrations";
|
const SERVICE_NAME = "TimescaleDB Migrations";
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ const migrations: MigrationEntry[] = [
|
|||||||
{ name: "0019_create_app_settings", up: createAppSettings, down: dropAppSettings },
|
{ name: "0019_create_app_settings", up: createAppSettings, down: dropAppSettings },
|
||||||
{ name: "0020_create_continuous_aggregates", up: createContinuousAggregates, down: dropContinuousAggregates },
|
{ name: "0020_create_continuous_aggregates", up: createContinuousAggregates, down: dropContinuousAggregates },
|
||||||
{ name: "0021_create_retention_compression", up: createRetentionCompression, down: dropRetentionCompression },
|
{ name: "0021_create_retention_compression", up: createRetentionCompression, down: dropRetentionCompression },
|
||||||
{ name: "0022_add_show_page_speed_to_status_pages", up: addShowPageSpeedToStatusPages, down: dropShowPageSpeedFromStatusPages },
|
{ name: "0022_add_user_agent_fields", up: addUserAgentFields, down: dropUserAgentFields },
|
||||||
];
|
];
|
||||||
|
|
||||||
const ensureMigrationsTable = async (pool: Pool) => {
|
const ensureMigrationsTable = async (pool: Pool) => {
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ const AppSettingsSchema = new Schema<AppSettingsDocument>(
|
|||||||
systemEmailRequireTLS: { type: Boolean, default: false },
|
systemEmailRequireTLS: { type: Boolean, default: false },
|
||||||
systemEmailRejectUnauthorized: { type: Boolean, default: true },
|
systemEmailRejectUnauthorized: { type: Boolean, default: true },
|
||||||
showURL: { type: Boolean, default: false },
|
showURL: { type: Boolean, default: false },
|
||||||
|
defaultUserAgent: { type: String },
|
||||||
singleton: { type: Boolean, required: true, unique: true, default: true },
|
singleton: { type: Boolean, required: true, unique: true, default: true },
|
||||||
version: { type: Number, default: 1 },
|
version: { type: Number, default: 1 },
|
||||||
globalThresholds: { type: thresholdsSchema },
|
globalThresholds: { type: thresholdsSchema },
|
||||||
|
|||||||
@@ -339,6 +339,9 @@ const MonitorSchema = new Schema<MonitorDocument>(
|
|||||||
return value && value.trim() ? value.trim() : null;
|
return value && value.trim() ? value.trim() : null;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
customUserAgent: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
geoCheckEnabled: {
|
geoCheckEnabled: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
|
|||||||
@@ -104,10 +104,6 @@ const StatusPageSchema = new Schema<StatusPageDocument>(
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
showPageSpeed: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
customCSS: {
|
customCSS: {
|
||||||
type: String,
|
type: String,
|
||||||
default: "",
|
default: "",
|
||||||
|
|||||||
@@ -387,6 +387,7 @@ class MongoMonitorsRepository implements IMonitorsRepository {
|
|||||||
gameId: doc.gameId ?? undefined,
|
gameId: doc.gameId ?? undefined,
|
||||||
grpcServiceName: doc.grpcServiceName ?? undefined,
|
grpcServiceName: doc.grpcServiceName ?? undefined,
|
||||||
group: doc.group ?? null,
|
group: doc.group ?? null,
|
||||||
|
customUserAgent: doc.customUserAgent ?? undefined,
|
||||||
recentChecks: (doc.recentChecks ?? []).map((check: CheckSnapshotDocument) => this.toCheckSnapshot(check)),
|
recentChecks: (doc.recentChecks ?? []).map((check: CheckSnapshotDocument) => this.toCheckSnapshot(check)),
|
||||||
geoCheckEnabled: doc.geoCheckEnabled ?? false,
|
geoCheckEnabled: doc.geoCheckEnabled ?? false,
|
||||||
geoCheckLocations: doc.geoCheckLocations ?? [],
|
geoCheckLocations: doc.geoCheckLocations ?? [],
|
||||||
@@ -446,6 +447,7 @@ class MongoMonitorsRepository implements IMonitorsRepository {
|
|||||||
gameId: doc.gameId ?? undefined,
|
gameId: doc.gameId ?? undefined,
|
||||||
grpcServiceName: doc.grpcServiceName ?? undefined,
|
grpcServiceName: doc.grpcServiceName ?? undefined,
|
||||||
group: doc.group ?? null,
|
group: doc.group ?? null,
|
||||||
|
customUserAgent: doc.customUserAgent ?? undefined,
|
||||||
recentChecks: (doc.recentChecks ?? []).map((check: CheckSnapshotDocument) => this.toCheckSnapshot(check)),
|
recentChecks: (doc.recentChecks ?? []).map((check: CheckSnapshotDocument) => this.toCheckSnapshot(check)),
|
||||||
geoCheckEnabled: doc.geoCheckEnabled ?? false,
|
geoCheckEnabled: doc.geoCheckEnabled ?? false,
|
||||||
geoCheckLocations: doc.geoCheckLocations ?? [],
|
geoCheckLocations: doc.geoCheckLocations ?? [],
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ interface MonitorRow {
|
|||||||
game_id: string | null;
|
game_id: string | null;
|
||||||
grpc_service_name: string | null;
|
grpc_service_name: string | null;
|
||||||
monitor_group: string | null;
|
monitor_group: string | null;
|
||||||
|
custom_user_agent: string | null;
|
||||||
geo_check_enabled: boolean;
|
geo_check_enabled: boolean;
|
||||||
geo_check_locations: GeoContinent[] | null;
|
geo_check_locations: GeoContinent[] | null;
|
||||||
geo_check_interval_ms: number;
|
geo_check_interval_ms: number;
|
||||||
@@ -49,7 +50,7 @@ const MONITOR_COLUMNS = `id, user_id, team_id, name, description, type, status,
|
|||||||
interval_ms, is_active, status_window, status_window_size, status_window_threshold, uptime_percentage,
|
interval_ms, is_active, status_window, status_window_size, status_window_threshold, uptime_percentage,
|
||||||
cpu_alert_threshold, cpu_alert_counter, memory_alert_threshold, memory_alert_counter,
|
cpu_alert_threshold, cpu_alert_counter, memory_alert_threshold, memory_alert_counter,
|
||||||
disk_alert_threshold, disk_alert_counter, temp_alert_threshold, temp_alert_counter, selected_disks,
|
disk_alert_threshold, disk_alert_counter, temp_alert_threshold, temp_alert_counter, selected_disks,
|
||||||
game_id, grpc_service_name, monitor_group, geo_check_enabled, geo_check_locations, geo_check_interval_ms,
|
game_id, grpc_service_name, monitor_group, custom_user_agent, geo_check_enabled, geo_check_locations, geo_check_interval_ms,
|
||||||
created_at, updated_at`;
|
created_at, updated_at`;
|
||||||
|
|
||||||
export class TimescaleMonitorsRepository implements IMonitorsRepository {
|
export class TimescaleMonitorsRepository implements IMonitorsRepository {
|
||||||
@@ -62,8 +63,8 @@ export class TimescaleMonitorsRepository implements IMonitorsRepository {
|
|||||||
interval_ms, is_active, status_window, status_window_size, status_window_threshold,
|
interval_ms, is_active, status_window, status_window_size, status_window_threshold,
|
||||||
cpu_alert_threshold, cpu_alert_counter, memory_alert_threshold, memory_alert_counter,
|
cpu_alert_threshold, cpu_alert_counter, memory_alert_threshold, memory_alert_counter,
|
||||||
disk_alert_threshold, disk_alert_counter, temp_alert_threshold, temp_alert_counter, selected_disks,
|
disk_alert_threshold, disk_alert_counter, temp_alert_threshold, temp_alert_counter, selected_disks,
|
||||||
game_id, grpc_service_name, monitor_group, geo_check_enabled, geo_check_locations, geo_check_interval_ms)
|
game_id, grpc_service_name, monitor_group, custom_user_agent, geo_check_enabled, geo_check_locations, geo_check_interval_ms)
|
||||||
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$30,$31,$32,$33,$34)
|
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$30,$31,$32,$33,$34,$35)
|
||||||
RETURNING ${MONITOR_COLUMNS}`,
|
RETURNING ${MONITOR_COLUMNS}`,
|
||||||
[
|
[
|
||||||
userId,
|
userId,
|
||||||
@@ -97,6 +98,7 @@ export class TimescaleMonitorsRepository implements IMonitorsRepository {
|
|||||||
monitor.gameId ?? null,
|
monitor.gameId ?? null,
|
||||||
monitor.grpcServiceName ?? null,
|
monitor.grpcServiceName ?? null,
|
||||||
monitor.group ?? null,
|
monitor.group ?? null,
|
||||||
|
monitor.customUserAgent ?? null,
|
||||||
monitor.geoCheckEnabled ?? false,
|
monitor.geoCheckEnabled ?? false,
|
||||||
monitor.geoCheckLocations ?? [],
|
monitor.geoCheckLocations ?? [],
|
||||||
monitor.geoCheckInterval ?? 300000,
|
monitor.geoCheckInterval ?? 300000,
|
||||||
@@ -595,6 +597,7 @@ export class TimescaleMonitorsRepository implements IMonitorsRepository {
|
|||||||
["gameId", "game_id"],
|
["gameId", "game_id"],
|
||||||
["grpcServiceName", "grpc_service_name"],
|
["grpcServiceName", "grpc_service_name"],
|
||||||
["group", "monitor_group"],
|
["group", "monitor_group"],
|
||||||
|
["customUserAgent", "custom_user_agent"],
|
||||||
["geoCheckEnabled", "geo_check_enabled"],
|
["geoCheckEnabled", "geo_check_enabled"],
|
||||||
["geoCheckLocations", "geo_check_locations"],
|
["geoCheckLocations", "geo_check_locations"],
|
||||||
["geoCheckInterval", "geo_check_interval_ms"],
|
["geoCheckInterval", "geo_check_interval_ms"],
|
||||||
@@ -1034,6 +1037,7 @@ export class TimescaleMonitorsRepository implements IMonitorsRepository {
|
|||||||
gameId: row.game_id ?? undefined,
|
gameId: row.game_id ?? undefined,
|
||||||
grpcServiceName: row.grpc_service_name ?? undefined,
|
grpcServiceName: row.grpc_service_name ?? undefined,
|
||||||
group: row.monitor_group,
|
group: row.monitor_group,
|
||||||
|
customUserAgent: row.custom_user_agent ?? undefined,
|
||||||
geoCheckEnabled: row.geo_check_enabled,
|
geoCheckEnabled: row.geo_check_enabled,
|
||||||
geoCheckLocations: row.geo_check_locations ?? [],
|
geoCheckLocations: row.geo_check_locations ?? [],
|
||||||
geoCheckInterval: row.geo_check_interval_ms,
|
geoCheckInterval: row.geo_check_interval_ms,
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ class MongoSettingsRepository implements ISettingsRepository {
|
|||||||
systemEmailRequireTLS: doc.systemEmailRequireTLS ?? false,
|
systemEmailRequireTLS: doc.systemEmailRequireTLS ?? false,
|
||||||
systemEmailRejectUnauthorized: doc.systemEmailRejectUnauthorized ?? true,
|
systemEmailRejectUnauthorized: doc.systemEmailRejectUnauthorized ?? true,
|
||||||
showURL: doc.showURL ?? false,
|
showURL: doc.showURL ?? false,
|
||||||
|
defaultUserAgent: doc.defaultUserAgent ?? undefined,
|
||||||
singleton: doc.singleton,
|
singleton: doc.singleton,
|
||||||
version: doc.version ?? 1,
|
version: doc.version ?? 1,
|
||||||
globalThresholds: doc.globalThresholds ?? undefined,
|
globalThresholds: doc.globalThresholds ?? undefined,
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ interface SettingsRow {
|
|||||||
system_email_require_tls: boolean | null;
|
system_email_require_tls: boolean | null;
|
||||||
system_email_reject_unauthorized: boolean | null;
|
system_email_reject_unauthorized: boolean | null;
|
||||||
show_url: boolean | null;
|
show_url: boolean | null;
|
||||||
|
default_user_agent: string | null;
|
||||||
version: string | null;
|
version: string | null;
|
||||||
threshold_cpu_usage: number | null;
|
threshold_cpu_usage: number | null;
|
||||||
threshold_memory_usage: number | null;
|
threshold_memory_usage: number | null;
|
||||||
@@ -34,7 +35,7 @@ const COLUMNS = `id, check_ttl, language, jwt_secret, pagespeed_api_key,
|
|||||||
system_email_host, system_email_port, system_email_address, system_email_password, system_email_user,
|
system_email_host, system_email_port, system_email_address, system_email_password, system_email_user,
|
||||||
system_email_connection_host, system_email_tls_servername, system_email_secure, system_email_pool,
|
system_email_connection_host, system_email_tls_servername, system_email_secure, system_email_pool,
|
||||||
system_email_ignore_tls, system_email_require_tls, system_email_reject_unauthorized,
|
system_email_ignore_tls, system_email_require_tls, system_email_reject_unauthorized,
|
||||||
show_url, version, threshold_cpu_usage, threshold_memory_usage, threshold_disk_usage, threshold_temperature,
|
show_url, default_user_agent, version, threshold_cpu_usage, threshold_memory_usage, threshold_disk_usage, threshold_temperature,
|
||||||
created_at, updated_at`;
|
created_at, updated_at`;
|
||||||
|
|
||||||
export class TimescaleSettingsRepository implements ISettingsRepository {
|
export class TimescaleSettingsRepository implements ISettingsRepository {
|
||||||
@@ -46,8 +47,8 @@ export class TimescaleSettingsRepository implements ISettingsRepository {
|
|||||||
system_email_host, system_email_port, system_email_address, system_email_password, system_email_user,
|
system_email_host, system_email_port, system_email_address, system_email_password, system_email_user,
|
||||||
system_email_connection_host, system_email_tls_servername, system_email_secure, system_email_pool,
|
system_email_connection_host, system_email_tls_servername, system_email_secure, system_email_pool,
|
||||||
system_email_ignore_tls, system_email_require_tls, system_email_reject_unauthorized,
|
system_email_ignore_tls, system_email_require_tls, system_email_reject_unauthorized,
|
||||||
show_url, version, threshold_cpu_usage, threshold_memory_usage, threshold_disk_usage, threshold_temperature)
|
show_url, default_user_agent, version, threshold_cpu_usage, threshold_memory_usage, threshold_disk_usage, threshold_temperature)
|
||||||
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22)
|
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23)
|
||||||
RETURNING ${COLUMNS}`,
|
RETURNING ${COLUMNS}`,
|
||||||
[
|
[
|
||||||
settings.checkTTL ?? 30,
|
settings.checkTTL ?? 30,
|
||||||
@@ -67,6 +68,7 @@ export class TimescaleSettingsRepository implements ISettingsRepository {
|
|||||||
settings.systemEmailRequireTLS ?? false,
|
settings.systemEmailRequireTLS ?? false,
|
||||||
settings.systemEmailRejectUnauthorized ?? true,
|
settings.systemEmailRejectUnauthorized ?? true,
|
||||||
settings.showURL ?? false,
|
settings.showURL ?? false,
|
||||||
|
settings.defaultUserAgent ?? null,
|
||||||
settings.version ?? 1,
|
settings.version ?? 1,
|
||||||
settings.globalThresholds?.cpu ?? null,
|
settings.globalThresholds?.cpu ?? null,
|
||||||
settings.globalThresholds?.memory ?? null,
|
settings.globalThresholds?.memory ?? null,
|
||||||
@@ -113,6 +115,7 @@ export class TimescaleSettingsRepository implements ISettingsRepository {
|
|||||||
["systemEmailRequireTLS", "system_email_require_tls"],
|
["systemEmailRequireTLS", "system_email_require_tls"],
|
||||||
["systemEmailRejectUnauthorized", "system_email_reject_unauthorized"],
|
["systemEmailRejectUnauthorized", "system_email_reject_unauthorized"],
|
||||||
["showURL", "show_url"],
|
["showURL", "show_url"],
|
||||||
|
["defaultUserAgent", "default_user_agent"],
|
||||||
["version", "version"],
|
["version", "version"],
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -197,6 +200,7 @@ export class TimescaleSettingsRepository implements ISettingsRepository {
|
|||||||
systemEmailRequireTLS: row.system_email_require_tls ?? false,
|
systemEmailRequireTLS: row.system_email_require_tls ?? false,
|
||||||
systemEmailRejectUnauthorized: row.system_email_reject_unauthorized ?? true,
|
systemEmailRejectUnauthorized: row.system_email_reject_unauthorized ?? true,
|
||||||
showURL: row.show_url ?? false,
|
showURL: row.show_url ?? false,
|
||||||
|
defaultUserAgent: row.default_user_agent ?? undefined,
|
||||||
singleton: true,
|
singleton: true,
|
||||||
version: Number(row.version ?? 1),
|
version: Number(row.version ?? 1),
|
||||||
globalThresholds:
|
globalThresholds:
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ class MongoStatusPagesRepository implements IStatusPagesRepository {
|
|||||||
showUptimePercentage: doc.showUptimePercentage,
|
showUptimePercentage: doc.showUptimePercentage,
|
||||||
showAdminLoginLink: doc.showAdminLoginLink,
|
showAdminLoginLink: doc.showAdminLoginLink,
|
||||||
showInfrastructure: doc.showInfrastructure,
|
showInfrastructure: doc.showInfrastructure,
|
||||||
showPageSpeed: doc.showPageSpeed,
|
|
||||||
customCSS: doc.customCSS,
|
customCSS: doc.customCSS,
|
||||||
createdAt: this.toDateString(doc.createdAt),
|
createdAt: this.toDateString(doc.createdAt),
|
||||||
updatedAt: this.toDateString(doc.updatedAt),
|
updatedAt: this.toDateString(doc.updatedAt),
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ interface StatusPageRow {
|
|||||||
show_uptime_percentage: boolean;
|
show_uptime_percentage: boolean;
|
||||||
show_admin_login_link: boolean;
|
show_admin_login_link: boolean;
|
||||||
show_infrastructure: boolean;
|
show_infrastructure: boolean;
|
||||||
show_page_speed: boolean;
|
|
||||||
custom_css: string | null;
|
custom_css: string | null;
|
||||||
created_at: Date;
|
created_at: Date;
|
||||||
updated_at: Date;
|
updated_at: Date;
|
||||||
@@ -34,7 +33,7 @@ interface StatusPageRow {
|
|||||||
|
|
||||||
const COLUMNS = `id, user_id, team_id, types, company_name, url, timezone, color,
|
const COLUMNS = `id, user_id, team_id, types, company_name, url, timezone, color,
|
||||||
logo_data, logo_content_type, is_published, show_charts, show_uptime_percentage,
|
logo_data, logo_content_type, is_published, show_charts, show_uptime_percentage,
|
||||||
show_admin_login_link, show_infrastructure, show_page_speed, custom_css, created_at, updated_at`;
|
show_admin_login_link, show_infrastructure, custom_css, created_at, updated_at`;
|
||||||
|
|
||||||
export class TimescaleStatusPagesRepository implements IStatusPagesRepository {
|
export class TimescaleStatusPagesRepository implements IStatusPagesRepository {
|
||||||
constructor(private pool: Pool) {}
|
constructor(private pool: Pool) {}
|
||||||
@@ -43,8 +42,8 @@ export class TimescaleStatusPagesRepository implements IStatusPagesRepository {
|
|||||||
const result = await this.pool.query<StatusPageRow>(
|
const result = await this.pool.query<StatusPageRow>(
|
||||||
`INSERT INTO status_pages (user_id, team_id, types, company_name, url, timezone, color,
|
`INSERT INTO status_pages (user_id, team_id, types, company_name, url, timezone, color,
|
||||||
logo_data, logo_content_type, is_published, show_charts, show_uptime_percentage,
|
logo_data, logo_content_type, is_published, show_charts, show_uptime_percentage,
|
||||||
show_admin_login_link, show_infrastructure, show_page_speed, custom_css)
|
show_admin_login_link, show_infrastructure, custom_css)
|
||||||
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16)
|
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15)
|
||||||
RETURNING ${COLUMNS}`,
|
RETURNING ${COLUMNS}`,
|
||||||
[
|
[
|
||||||
userId,
|
userId,
|
||||||
@@ -61,7 +60,6 @@ export class TimescaleStatusPagesRepository implements IStatusPagesRepository {
|
|||||||
data.showUptimePercentage ?? false,
|
data.showUptimePercentage ?? false,
|
||||||
data.showAdminLoginLink ?? false,
|
data.showAdminLoginLink ?? false,
|
||||||
data.showInfrastructure ?? false,
|
data.showInfrastructure ?? false,
|
||||||
data.showPageSpeed ?? false,
|
|
||||||
data.customCSS ?? null,
|
data.customCSS ?? null,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
@@ -130,7 +128,6 @@ export class TimescaleStatusPagesRepository implements IStatusPagesRepository {
|
|||||||
["showUptimePercentage", "show_uptime_percentage"],
|
["showUptimePercentage", "show_uptime_percentage"],
|
||||||
["showAdminLoginLink", "show_admin_login_link"],
|
["showAdminLoginLink", "show_admin_login_link"],
|
||||||
["showInfrastructure", "show_infrastructure"],
|
["showInfrastructure", "show_infrastructure"],
|
||||||
["showPageSpeed", "show_page_speed"],
|
|
||||||
["customCSS", "custom_css"],
|
["customCSS", "custom_css"],
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -255,7 +252,6 @@ export class TimescaleStatusPagesRepository implements IStatusPagesRepository {
|
|||||||
showUptimePercentage: row.show_uptime_percentage,
|
showUptimePercentage: row.show_uptime_percentage,
|
||||||
showAdminLoginLink: row.show_admin_login_link,
|
showAdminLoginLink: row.show_admin_login_link,
|
||||||
showInfrastructure: row.show_infrastructure,
|
showInfrastructure: row.show_infrastructure,
|
||||||
showPageSpeed: row.show_page_speed,
|
|
||||||
customCSS: row.custom_css ?? "",
|
customCSS: row.custom_css ?? "",
|
||||||
createdAt: row.created_at.toISOString(),
|
createdAt: row.created_at.toISOString(),
|
||||||
updatedAt: row.updated_at.toISOString(),
|
updatedAt: row.updated_at.toISOString(),
|
||||||
|
|||||||
@@ -146,7 +146,8 @@ export class SuperSimpleQueue implements ISuperSimpleQueue {
|
|||||||
|
|
||||||
deleteJob = async (monitor: Monitor) => {
|
deleteJob = async (monitor: Monitor) => {
|
||||||
this.scheduler.removeJob(monitor.id);
|
this.scheduler.removeJob(monitor.id);
|
||||||
this.scheduler.removeJob(`${monitor.id}-geo`);
|
const geoJob = await this.scheduler.getJob(`${monitor.id}-geo`);
|
||||||
|
if (geoJob) await this.scheduler.removeJob(`${monitor.id}-geo`);
|
||||||
};
|
};
|
||||||
|
|
||||||
pauseJob = async (monitor: Monitor) => {
|
pauseJob = async (monitor: Monitor) => {
|
||||||
@@ -154,7 +155,9 @@ export class SuperSimpleQueue implements ISuperSimpleQueue {
|
|||||||
if (result === false) {
|
if (result === false) {
|
||||||
throw new Error("Failed to pause monitor");
|
throw new Error("Failed to pause monitor");
|
||||||
}
|
}
|
||||||
await this.scheduler.pauseJob(`${monitor.id}-geo`);
|
const geoJob = await this.scheduler.getJob(`${monitor.id}-geo`);
|
||||||
|
if (geoJob) await this.scheduler.removeJob(`${monitor.id}-geo`);
|
||||||
|
|
||||||
this.logger.debug({
|
this.logger.debug({
|
||||||
message: `Paused monitor ${monitor.id}`,
|
message: `Paused monitor ${monitor.id}`,
|
||||||
service: SERVICE_NAME,
|
service: SERVICE_NAME,
|
||||||
@@ -177,31 +180,35 @@ export class SuperSimpleQueue implements ISuperSimpleQueue {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private syncGeoJob = async (monitor: Monitor) => {
|
||||||
|
const geoJobId = `${monitor.id}-geo`;
|
||||||
|
const existingGeoJob = await this.scheduler.getJob(geoJobId);
|
||||||
|
|
||||||
|
// If geoChecks have been disabled, or the monitor type doesn't support them, remove
|
||||||
|
if (!monitor.geoCheckEnabled || !supportsGeoCheck(monitor.type)) {
|
||||||
|
if (existingGeoJob) this.scheduler.removeJob(geoJobId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the job exists, update it
|
||||||
|
if (existingGeoJob) {
|
||||||
|
this.scheduler.updateJob(geoJobId, { repeat: monitor.geoCheckInterval, active: monitor.isActive, data: monitor });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, create it
|
||||||
|
this.scheduler.addJob({
|
||||||
|
id: geoJobId,
|
||||||
|
template: "geo-check-job",
|
||||||
|
repeat: monitor.geoCheckInterval,
|
||||||
|
active: monitor.isActive,
|
||||||
|
data: monitor,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
updateJob = async (monitor: Monitor) => {
|
updateJob = async (monitor: Monitor) => {
|
||||||
this.scheduler.updateJob(monitor.id, { repeat: monitor.interval, data: monitor });
|
this.scheduler.updateJob(monitor.id, { repeat: monitor.interval, data: monitor });
|
||||||
|
await this.syncGeoJob(monitor);
|
||||||
// Handle geo check job lifecycle
|
|
||||||
const geoJobId = `${monitor.id}-geo`;
|
|
||||||
if (monitor.geoCheckEnabled && supportsGeoCheck(monitor.type)) {
|
|
||||||
// Check if geo job exists
|
|
||||||
const existingGeoJob = await this.scheduler.getJob(geoJobId);
|
|
||||||
if (existingGeoJob) {
|
|
||||||
// Update existing geo job
|
|
||||||
this.scheduler.updateJob(geoJobId, { repeat: monitor.geoCheckInterval, active: monitor.isActive, data: monitor });
|
|
||||||
} else {
|
|
||||||
// Create new geo job
|
|
||||||
this.scheduler.addJob({
|
|
||||||
id: geoJobId,
|
|
||||||
template: "geo-check-job",
|
|
||||||
repeat: monitor.geoCheckInterval,
|
|
||||||
active: monitor.isActive,
|
|
||||||
data: monitor,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Remove geo job if disabled or monitor type changed
|
|
||||||
this.scheduler.removeJob(geoJobId);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
shutdown = async () => {
|
shutdown = async () => {
|
||||||
|
|||||||
@@ -132,7 +132,15 @@ export class SuperSimpleQueueHelper implements ISuperSimpleQueueHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Step 2. Request monitor status
|
// Step 2. Request monitor status
|
||||||
const status = await this.networkService.requestStatus(monitor);
|
// Resolve default user agent for HTTP monitors (cached, invalidated on settings update)
|
||||||
|
let effectiveMonitor: Monitor = monitor;
|
||||||
|
if (monitor.type === "http" && !monitor.customUserAgent) {
|
||||||
|
const defaultUserAgent = await this.settingsService.getDefaultUserAgent();
|
||||||
|
if (defaultUserAgent) {
|
||||||
|
effectiveMonitor = { ...monitor, customUserAgent: defaultUserAgent };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const status = await this.networkService.requestStatus(effectiveMonitor);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
throw new Error("No network response");
|
throw new Error("No network response");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,15 +56,30 @@ export class HttpProvider implements IStatusProvider<HttpStatusPayload> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private sanitizeHeaderValue(value: string): string {
|
||||||
|
if (!value) return "";
|
||||||
|
|
||||||
|
return value
|
||||||
|
.replace(/[<>]/g, "")
|
||||||
|
.replace(/(?:javascript|data|vbscript):/gi, "")
|
||||||
|
.replace(/[^\t\x20-\x7E\x80-\xFF]/g, "") // allow only RFC 7230 header-safe characters
|
||||||
|
.trim()
|
||||||
|
.slice(0, 500);
|
||||||
|
}
|
||||||
|
|
||||||
async handle<T>(monitor: Monitor): Promise<MonitorStatusResponse<T>> {
|
async handle<T>(monitor: Monitor): Promise<MonitorStatusResponse<T>> {
|
||||||
const { url, secret, jsonPath, ignoreTlsErrors } = monitor;
|
const { url, secret, jsonPath, ignoreTlsErrors, customUserAgent } = monitor;
|
||||||
|
|
||||||
if (!url) {
|
if (!url) {
|
||||||
throw new Error("URL is required for HTTP monitor");
|
throw new Error("URL is required for HTTP monitor");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const headers: Record<string, string> = {};
|
||||||
|
if (secret) headers["Authorization"] = `Bearer ${secret}`;
|
||||||
|
if (customUserAgent) headers["User-Agent"] = this.sanitizeHeaderValue(customUserAgent);
|
||||||
|
|
||||||
const options: Record<string, unknown> = {
|
const options: Record<string, unknown> = {
|
||||||
headers: monitor.secret ? { Authorization: `Bearer ${secret}` } : undefined,
|
headers: Object.keys(headers).length > 0 ? headers : undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
options.agent = {
|
options.agent = {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ export interface ISettingsService {
|
|||||||
loadSettings(): EnvConfig;
|
loadSettings(): EnvConfig;
|
||||||
getSettings(): EnvConfig;
|
getSettings(): EnvConfig;
|
||||||
getDBSettings(): Promise<Settings>;
|
getDBSettings(): Promise<Settings>;
|
||||||
|
getDefaultUserAgent(): Promise<string | undefined>;
|
||||||
updateDbSettings(newSettings: SettingsUpdate): Promise<Settings>;
|
updateDbSettings(newSettings: SettingsUpdate): Promise<Settings>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,6 +28,7 @@ export class SettingsService implements ISettingsService {
|
|||||||
static SERVICE_NAME = SERVICE_NAME;
|
static SERVICE_NAME = SERVICE_NAME;
|
||||||
private settings: EnvConfig;
|
private settings: EnvConfig;
|
||||||
private settingsRepository: ISettingsRepository | null = null;
|
private settingsRepository: ISettingsRepository | null = null;
|
||||||
|
private cachedDefaultUserAgent: string | null | undefined = undefined;
|
||||||
|
|
||||||
constructor(env: ValidatedEnv) {
|
constructor(env: ValidatedEnv) {
|
||||||
this.settings = {
|
this.settings = {
|
||||||
@@ -70,8 +72,21 @@ export class SettingsService implements ISettingsService {
|
|||||||
return this.settingsRepository;
|
return this.settingsRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getDefaultUserAgent = async (): Promise<string | undefined> => {
|
||||||
|
if (this.cachedDefaultUserAgent !== undefined) {
|
||||||
|
return this.cachedDefaultUserAgent ?? undefined;
|
||||||
|
}
|
||||||
|
const settings = await this.getDBSettings();
|
||||||
|
this.cachedDefaultUserAgent = settings.defaultUserAgent ?? null;
|
||||||
|
return this.cachedDefaultUserAgent ?? undefined;
|
||||||
|
};
|
||||||
|
|
||||||
updateDbSettings = async (newSettings: SettingsUpdate) => {
|
updateDbSettings = async (newSettings: SettingsUpdate) => {
|
||||||
return await this.getRepository().update(newSettings);
|
const updated = await this.getRepository().update(newSettings);
|
||||||
|
if ("defaultUserAgent" in newSettings) {
|
||||||
|
this.cachedDefaultUserAgent = newSettings.defaultUserAgent ?? null;
|
||||||
|
}
|
||||||
|
return updated;
|
||||||
};
|
};
|
||||||
|
|
||||||
getDBSettings = async () => {
|
getDBSettings = async () => {
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ export interface Monitor {
|
|||||||
gameId?: string;
|
gameId?: string;
|
||||||
grpcServiceName?: string;
|
grpcServiceName?: string;
|
||||||
group: string | null;
|
group: string | null;
|
||||||
|
customUserAgent?: string | null;
|
||||||
geoCheckEnabled?: boolean;
|
geoCheckEnabled?: boolean;
|
||||||
geoCheckLocations?: GeoContinent[];
|
geoCheckLocations?: GeoContinent[];
|
||||||
geoCheckInterval?: number;
|
geoCheckInterval?: number;
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ export interface Settings {
|
|||||||
systemEmailRequireTLS: boolean;
|
systemEmailRequireTLS: boolean;
|
||||||
systemEmailRejectUnauthorized: boolean;
|
systemEmailRejectUnauthorized: boolean;
|
||||||
showURL: boolean;
|
showURL: boolean;
|
||||||
|
defaultUserAgent?: string;
|
||||||
singleton: boolean;
|
singleton: boolean;
|
||||||
version: number;
|
version: number;
|
||||||
globalThresholds?: SettingsThresholds;
|
globalThresholds?: SettingsThresholds;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export const StatusPageTypes = ["uptime", "infrastructure", "pagespeed"] as const;
|
export const StatusPageTypes = ["uptime", "infrastructure"] as const;
|
||||||
export type StatusPageType = (typeof StatusPageTypes)[number];
|
export type StatusPageType = (typeof StatusPageTypes)[number];
|
||||||
|
|
||||||
export interface StatusPageLogo {
|
export interface StatusPageLogo {
|
||||||
@@ -29,7 +29,6 @@ export interface StatusPage {
|
|||||||
showUptimePercentage: boolean;
|
showUptimePercentage: boolean;
|
||||||
showAdminLoginLink: boolean;
|
showAdminLoginLink: boolean;
|
||||||
showInfrastructure: boolean;
|
showInfrastructure: boolean;
|
||||||
showPageSpeed: boolean;
|
|
||||||
customCSS: string;
|
customCSS: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { booleanCoercion } from "./shared.js";
|
import { booleanCoercion, httpHeaderValueSchema } from "./shared.js";
|
||||||
import { GeoContinents } from "@/types/geoCheck.js";
|
import { GeoContinents } from "@/types/geoCheck.js";
|
||||||
import { MonitorMatchMethods, MonitorTypes } from "@/types/monitor.js";
|
import { MonitorMatchMethods, MonitorTypes } from "@/types/monitor.js";
|
||||||
|
|
||||||
@@ -75,6 +75,7 @@ export const createMonitorBodyValidation = z.object({
|
|||||||
grpcServiceName: z.union([z.string(), z.literal("")]).default(""),
|
grpcServiceName: z.union([z.string(), z.literal("")]).default(""),
|
||||||
selectedDisks: z.array(z.string()).optional(),
|
selectedDisks: z.array(z.string()).optional(),
|
||||||
group: z.union([z.string().max(50).trim(), z.null(), z.literal("")]).optional(),
|
group: z.union([z.string().max(50).trim(), z.null(), z.literal("")]).optional(),
|
||||||
|
customUserAgent: httpHeaderValueSchema.nullable().optional(),
|
||||||
geoCheckEnabled: z.boolean().optional(),
|
geoCheckEnabled: z.boolean().optional(),
|
||||||
geoCheckLocations: z.array(z.enum(GeoContinents)).optional(),
|
geoCheckLocations: z.array(z.enum(GeoContinents)).optional(),
|
||||||
geoCheckInterval: z.number().min(300000).optional(),
|
geoCheckInterval: z.number().min(300000).optional(),
|
||||||
@@ -104,6 +105,7 @@ export const editMonitorBodyValidation = z.object({
|
|||||||
grpcServiceName: z.union([z.string(), z.literal("")]).optional(),
|
grpcServiceName: z.union([z.string(), z.literal("")]).optional(),
|
||||||
selectedDisks: z.array(z.string()).optional(),
|
selectedDisks: z.array(z.string()).optional(),
|
||||||
group: z.union([z.string().max(50).trim(), z.null(), z.literal("")]).optional(),
|
group: z.union([z.string().max(50).trim(), z.null(), z.literal("")]).optional(),
|
||||||
|
customUserAgent: httpHeaderValueSchema.nullable().optional(),
|
||||||
geoCheckEnabled: z.boolean().optional(),
|
geoCheckEnabled: z.boolean().optional(),
|
||||||
geoCheckLocations: z.array(z.enum(GeoContinents)).optional(),
|
geoCheckLocations: z.array(z.enum(GeoContinents)).optional(),
|
||||||
geoCheckInterval: z.number().min(300000).optional(),
|
geoCheckInterval: z.number().min(300000).optional(),
|
||||||
@@ -157,6 +159,7 @@ const importedMonitorSchema = z.object({
|
|||||||
gameId: z.union([z.string(), z.literal("")]).optional(),
|
gameId: z.union([z.string(), z.literal("")]).optional(),
|
||||||
grpcServiceName: z.union([z.string(), z.literal("")]).default(""),
|
grpcServiceName: z.union([z.string(), z.literal("")]).default(""),
|
||||||
group: z.union([z.string().max(50).trim(), z.null()]).default(null),
|
group: z.union([z.string().max(50).trim(), z.null()]).default(null),
|
||||||
|
customUserAgent: httpHeaderValueSchema.nullable().optional(),
|
||||||
geoCheckEnabled: z.boolean().default(false),
|
geoCheckEnabled: z.boolean().default(false),
|
||||||
geoCheckLocations: z.array(z.enum(GeoContinents)).default([]),
|
geoCheckLocations: z.array(z.enum(GeoContinents)).default([]),
|
||||||
geoCheckInterval: z.number().min(300000).default(300000),
|
geoCheckInterval: z.number().min(300000).default(300000),
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { CHECK_TTL_SENTINEL } from "@/types/check.js";
|
import { CHECK_TTL_SENTINEL } from "@/types/check.js";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
import { httpHeaderValueSchema } from "@/validation/shared.js";
|
||||||
|
|
||||||
//****************************************
|
//****************************************
|
||||||
// Settings Validations
|
// Settings Validations
|
||||||
@@ -20,6 +21,7 @@ export const updateAppSettingsBodyValidation = z
|
|||||||
systemEmailTLSServername: z.string().nullable().optional(),
|
systemEmailTLSServername: z.string().nullable().optional(),
|
||||||
|
|
||||||
showURL: z.boolean().optional(),
|
showURL: z.boolean().optional(),
|
||||||
|
defaultUserAgent: httpHeaderValueSchema.nullable().optional(),
|
||||||
systemEmailSecure: z.boolean().optional(),
|
systemEmailSecure: z.boolean().optional(),
|
||||||
systemEmailPool: z.boolean().optional(),
|
systemEmailPool: z.boolean().optional(),
|
||||||
systemEmailIgnoreTLS: z.boolean().optional(),
|
systemEmailIgnoreTLS: z.boolean().optional(),
|
||||||
|
|||||||
@@ -21,6 +21,12 @@ export const booleanCoercion = z.preprocess((val) => {
|
|||||||
return val; // Let Zod validation handle invalid values
|
return val; // Let Zod validation handle invalid values
|
||||||
}, z.boolean());
|
}, z.boolean());
|
||||||
|
|
||||||
|
// RFC 7230: validate HTTP header field-value characters
|
||||||
|
export const httpHeaderValueSchema = z
|
||||||
|
.string()
|
||||||
|
.max(500)
|
||||||
|
.regex(/^[\t\x20-\x7E\x80-\xFF]*$/, "Must contain only valid HTTP header characters (RFC 7230)");
|
||||||
|
|
||||||
export const roleValidator = (allowedRoles: UserRole[]) => {
|
export const roleValidator = (allowedRoles: UserRole[]) => {
|
||||||
return z.array(z.custom<UserRole>()).refine((userRoles) => allowedRoles.some((role) => userRoles.includes(role)), {
|
return z.array(z.custom<UserRole>()).refine((userRoles) => allowedRoles.some((role) => userRoles.includes(role)), {
|
||||||
message: `You do not have the required authorization. Required roles: ${allowedRoles.join(", ")}`,
|
message: `You do not have the required authorization. Required roles: ${allowedRoles.join(", ")}`,
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ export const createStatusPageBodyValidation = z
|
|||||||
showUptimePercentage: booleanCoercion,
|
showUptimePercentage: booleanCoercion,
|
||||||
showAdminLoginLink: booleanCoercion.optional(),
|
showAdminLoginLink: booleanCoercion.optional(),
|
||||||
showInfrastructure: booleanCoercion.optional(),
|
showInfrastructure: booleanCoercion.optional(),
|
||||||
showPageSpeed: booleanCoercion.optional(),
|
|
||||||
removeLogo: z.union([z.literal("true"), z.literal("false")]).optional(),
|
removeLogo: z.union([z.literal("true"), z.literal("false")]).optional(),
|
||||||
})
|
})
|
||||||
.strip();
|
.strip();
|
||||||
|
|||||||
Reference in new issue
Block a user