Fix #897
This commit is contained in:
parent
e0028cb114
commit
bf49a548c7
@ -6,7 +6,7 @@ dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
const axios = require("axios");
|
||||
const { Prometheus } = require("../prometheus");
|
||||
const { log, UP, DOWN, PENDING, flipStatus, TimeLogger } = require("../../src/util");
|
||||
const { log, UP, DOWN, PENDING, flipStatus, TimeLogger, MAX_INTERVAL } = require("../../src/util");
|
||||
const { tcping, ping, dnsResolve, checkCertificate, checkStatusCode, getTotalClientInRoom, setting, mqttAsync } = require("../util-server");
|
||||
const { R } = require("redbean-node");
|
||||
const { BeanModel } = require("redbean-node/dist/bean-model");
|
||||
@ -167,7 +167,7 @@ class Monitor extends BeanModel {
|
||||
|
||||
let beatInterval = this.interval;
|
||||
|
||||
if (! beatInterval) {
|
||||
if (! beatInterval || beatInterval < 1) {
|
||||
beatInterval = 1;
|
||||
}
|
||||
|
||||
@ -178,6 +178,13 @@ class Monitor extends BeanModel {
|
||||
}
|
||||
}
|
||||
|
||||
// Prevent an issue like https://github.com/louislam/uptime-kuma/issues/897
|
||||
// Because setTimeout accept <= 2,147,483,647 ms only
|
||||
// But beatInterval is in second, so need to divided by 1000
|
||||
if (beatInterval > MAX_INTERVAL) {
|
||||
beatInterval = MAX_INTERVAL;
|
||||
}
|
||||
|
||||
// Expose here for prometheus update
|
||||
// undefined if not https
|
||||
let tlsInfo = undefined;
|
||||
|
@ -151,7 +151,7 @@
|
||||
<!-- Interval -->
|
||||
<div class="my-3">
|
||||
<label for="interval" class="form-label">{{ $t("Heartbeat Interval") }} ({{ $t("checkEverySecond", [ monitor.interval ]) }})</label>
|
||||
<input id="interval" v-model="monitor.interval" type="number" class="form-control" required min="20" step="1">
|
||||
<input id="interval" v-model="monitor.interval" type="number" class="form-control" required min="20" :max="maxInterval" step="1">
|
||||
</div>
|
||||
|
||||
<div class="my-3">
|
||||
@ -367,7 +367,7 @@ import CopyableInput from "../components/CopyableInput.vue";
|
||||
import NotificationDialog from "../components/NotificationDialog.vue";
|
||||
import ProxyDialog from "../components/ProxyDialog.vue";
|
||||
import TagsManager from "../components/TagsManager.vue";
|
||||
import { genSecret, isDev } from "../util.ts";
|
||||
import { genSecret, isDev, MAX_INTERVAL } from "../util.ts";
|
||||
|
||||
const toast = useToast();
|
||||
|
||||
@ -382,6 +382,7 @@ export default {
|
||||
|
||||
data() {
|
||||
return {
|
||||
maxInterval: MAX_INTERVAL,
|
||||
processing: false,
|
||||
monitor: {
|
||||
notificationIDList: {},
|
||||
|
@ -7,7 +7,7 @@
|
||||
// Backend uses the compiled file util.js
|
||||
// Frontend uses util.ts
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getMonitorRelativeURL = exports.genSecret = exports.getCryptoRandomInt = exports.getRandomInt = exports.getRandomArbitrary = exports.TimeLogger = exports.polyfill = exports.log = exports.debug = exports.ucfirst = exports.sleep = exports.flipStatus = exports.STATUS_PAGE_PARTIAL_DOWN = exports.STATUS_PAGE_ALL_UP = exports.STATUS_PAGE_ALL_DOWN = exports.PENDING = exports.UP = exports.DOWN = exports.appName = exports.isDev = void 0;
|
||||
exports.getMonitorRelativeURL = exports.genSecret = exports.getCryptoRandomInt = exports.getRandomInt = exports.getRandomArbitrary = exports.TimeLogger = exports.polyfill = exports.log = exports.debug = exports.ucfirst = exports.sleep = exports.flipStatus = exports.MAX_INTERVAL = exports.STATUS_PAGE_PARTIAL_DOWN = exports.STATUS_PAGE_ALL_UP = exports.STATUS_PAGE_ALL_DOWN = exports.PENDING = exports.UP = exports.DOWN = exports.appName = exports.isDev = void 0;
|
||||
const _dayjs = require("dayjs");
|
||||
const dayjs = _dayjs;
|
||||
exports.isDev = process.env.NODE_ENV === "development";
|
||||
@ -18,6 +18,7 @@ exports.PENDING = 2;
|
||||
exports.STATUS_PAGE_ALL_DOWN = 0;
|
||||
exports.STATUS_PAGE_ALL_UP = 1;
|
||||
exports.STATUS_PAGE_PARTIAL_DOWN = 2;
|
||||
exports.MAX_INTERVAL = 2147482;
|
||||
function flipStatus(s) {
|
||||
if (s === exports.UP) {
|
||||
return exports.DOWN;
|
||||
|
@ -19,6 +19,8 @@ export const STATUS_PAGE_ALL_DOWN = 0;
|
||||
export const STATUS_PAGE_ALL_UP = 1;
|
||||
export const STATUS_PAGE_PARTIAL_DOWN = 2;
|
||||
|
||||
export const MAX_INTERVAL = 2147482;
|
||||
|
||||
|
||||
export function flipStatus(s: number) {
|
||||
if (s === UP) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user