mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-03-05 20:59:48 -08:00
Merge 32ed245f1a
into c7d7fdd632
This commit is contained in:
commit
039b2f8f19
27
db/knex_migrations/2025-03-04-0000-ping-advanced-options.js
Normal file
27
db/knex_migrations/2025-03-04-0000-ping-advanced-options.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
/* SQL:
|
||||
ALTER TABLE monitor ADD ping_count INTEGER default 1 not null;
|
||||
ALTER TABLE monitor ADD ping_numeric BOOLEAN default true not null;
|
||||
ALTER TABLE monitor ADD ping_deadline INTEGER default 10 not null;
|
||||
ALTER TABLE monitor ADD ping_timeout INTEGER default 2 not null;
|
||||
*/
|
||||
exports.up = function (knex) {
|
||||
// Add new columns to table monitor
|
||||
return knex.schema
|
||||
.alterTable("monitor", function (table) {
|
||||
table.integer("ping_count").defaultTo(1).notNullable();
|
||||
table.boolean("ping_numeric").defaultTo(true).notNullable();
|
||||
table.integer("ping_deadline").defaultTo(10).notNullable();
|
||||
table.integer("ping_timeout").defaultTo(2).notNullable();
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
exports.down = function (knex) {
|
||||
return knex.schema
|
||||
.alterTable("monitor", function (table) {
|
||||
table.dropColumn("ping_count");
|
||||
table.dropColumn("ping_numeric");
|
||||
table.dropColumn("ping_deadline");
|
||||
table.dropColumn("ping_timeout");
|
||||
});
|
||||
};
|
|
@ -2,7 +2,8 @@ const dayjs = require("dayjs");
|
|||
const axios = require("axios");
|
||||
const { Prometheus } = require("../prometheus");
|
||||
const { log, UP, DOWN, PENDING, MAINTENANCE, flipStatus, MAX_INTERVAL_SECOND, MIN_INTERVAL_SECOND,
|
||||
SQL_DATETIME_FORMAT, evaluateJsonQuery
|
||||
SQL_DATETIME_FORMAT, evaluateJsonQuery, PING_PACKET_SIZE_MIN, PING_PACKET_SIZE_MAX,
|
||||
PING_DEADLINE_MIN, PING_DEADLINE_MAX, PING_COUNT_MIN, PING_COUNT_MAX, PING_TIMEOUT_MIN, PING_TIMEOUT_MAX
|
||||
} = require("../../src/util");
|
||||
const { tcping, ping, checkCertificate, checkStatusCode, getTotalClientInRoom, setting, mssqlQuery, postgresQuery, mysqlQuery, setSetting, httpNtlm, radius, grpcQuery,
|
||||
redisPingAsync, kafkaProducerAsync, getOidcTokenClientCredentials, rootCertificatesFingerprints, axiosAbortSignal
|
||||
|
@ -155,6 +156,12 @@ class Monitor extends BeanModel {
|
|||
snmpVersion: this.snmpVersion,
|
||||
rabbitmqNodes: JSON.parse(this.rabbitmqNodes),
|
||||
conditions: JSON.parse(this.conditions),
|
||||
|
||||
// ping advanced options
|
||||
ping_numeric: this.isPingNumeric(),
|
||||
ping_count: this.ping_count,
|
||||
ping_deadline: this.ping_deadline,
|
||||
ping_timeout: this.ping_timeout,
|
||||
};
|
||||
|
||||
if (includeSensitiveData) {
|
||||
|
@ -247,6 +254,14 @@ class Monitor extends BeanModel {
|
|||
return Boolean(this.expiryNotification);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if ping should use numeric output only
|
||||
* @returns {boolean} True if IP addresses will be output instead of symbolic hostnames
|
||||
*/
|
||||
isPingNumeric() {
|
||||
return Boolean(this.ping_numeric);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse to boolean
|
||||
* @returns {boolean} Should TLS errors be ignored?
|
||||
|
@ -1500,6 +1515,22 @@ class Monitor extends BeanModel {
|
|||
if (this.interval < MIN_INTERVAL_SECOND) {
|
||||
throw new Error(`Interval cannot be less than ${MIN_INTERVAL_SECOND} seconds`);
|
||||
}
|
||||
|
||||
if (this.packetSize && (this.packetSize < PING_PACKET_SIZE_MIN || this.packetSize > PING_PACKET_SIZE_MAX)) {
|
||||
throw new Error(`Packet size must be between ${PING_PACKET_SIZE_MIN} and ${PING_PACKET_SIZE_MAX}`);
|
||||
}
|
||||
|
||||
if (this.ping_deadline && (this.ping_deadline < PING_DEADLINE_MIN || this.ping_deadline > PING_DEADLINE_MAX)) {
|
||||
throw new Error(`Deadline must be between ${PING_DEADLINE_MIN} and ${PING_DEADLINE_MAX} seconds`);
|
||||
}
|
||||
|
||||
if (this.ping_count && (this.ping_count < PING_COUNT_MIN || this.ping_count > PING_COUNT_MAX)) {
|
||||
throw new Error(`Echo requests count must be between ${PING_COUNT_MIN} and ${PING_COUNT_MAX}`);
|
||||
}
|
||||
|
||||
if (this.ping_timeout && (this.ping_timeout < PING_TIMEOUT_MIN || this.ping_timeout > PING_TIMEOUT_MAX)) {
|
||||
throw new Error(`Timeout must be between ${PING_TIMEOUT_MIN} and ${PING_TIMEOUT_MAX} seconds`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -875,6 +875,12 @@ let needSetup = false;
|
|||
bean.rabbitmqPassword = monitor.rabbitmqPassword;
|
||||
bean.conditions = JSON.stringify(monitor.conditions);
|
||||
|
||||
// ping advanced options
|
||||
bean.ping_numeric = monitor.ping_numeric;
|
||||
bean.ping_count = monitor.ping_count;
|
||||
bean.ping_deadline = monitor.ping_deadline;
|
||||
bean.ping_timeout = monitor.ping_timeout;
|
||||
|
||||
bean.validate();
|
||||
|
||||
await R.store(bean);
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
const tcpp = require("tcp-ping");
|
||||
const ping = require("@louislam/ping");
|
||||
const { R } = require("redbean-node");
|
||||
const { log, genSecret, badgeConstants } = require("../src/util");
|
||||
const {
|
||||
log, genSecret, badgeConstants,
|
||||
PING_PACKET_SIZE_DEFAULT, PING_DEADLINE_DEFAULT,
|
||||
PING_COUNT_DEFAULT, PING_TIMEOUT_DEFAULT
|
||||
} = require("../src/util");
|
||||
const passwordHash = require("./password-hash");
|
||||
const { Resolver } = require("dns");
|
||||
const iconv = require("iconv-lite");
|
||||
|
@ -118,20 +122,33 @@ exports.tcping = function (hostname, port) {
|
|||
|
||||
/**
|
||||
* Ping the specified machine
|
||||
* @param {string} hostname Hostname / address of machine
|
||||
* @param {number} size Size of packet to send
|
||||
* @param {string} destAddr Hostname / IP address of machine to ping
|
||||
* @param {number} count Number of packets to send before stopping
|
||||
* @param {string} sourceAddr Source address for sending/receiving echo requests
|
||||
* @param {boolean} numeric If true, IP addresses will be output instead of symbolic hostnames
|
||||
* @param {number} size Size (in bytes) of echo request to send
|
||||
* @param {number} deadline Maximum time in seconds before ping stops, regardless of packets sent
|
||||
* @param {number} timeout Maximum time in seconds to wait for each response
|
||||
* @returns {Promise<number>} Time for ping in ms rounded to nearest integer
|
||||
*/
|
||||
exports.ping = async (hostname, size = 56) => {
|
||||
exports.ping = async (
|
||||
destAddr,
|
||||
count = PING_COUNT_DEFAULT,
|
||||
sourceAddr = "",
|
||||
numeric = true,
|
||||
size = PING_PACKET_SIZE_DEFAULT,
|
||||
deadline = PING_DEADLINE_DEFAULT,
|
||||
timeout = PING_TIMEOUT_DEFAULT,
|
||||
) => {
|
||||
try {
|
||||
return await exports.pingAsync(hostname, false, size);
|
||||
return await exports.pingAsync(destAddr, false, count, sourceAddr, numeric, size, deadline, timeout);
|
||||
} catch (e) {
|
||||
// If the host cannot be resolved, try again with ipv6
|
||||
log.debug("ping", "IPv6 error message: " + e.message);
|
||||
|
||||
// As node-ping does not report a specific error for this, try again if it is an empty message with ipv6 no matter what.
|
||||
if (!e.message) {
|
||||
return await exports.pingAsync(hostname, true, size);
|
||||
return await exports.pingAsync(destAddr, true, count, sourceAddr, numeric, size, deadline, timeout);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
|
@ -140,18 +157,35 @@ exports.ping = async (hostname, size = 56) => {
|
|||
|
||||
/**
|
||||
* Ping the specified machine
|
||||
* @param {string} hostname Hostname / address of machine to ping
|
||||
* @param {string} destAddr Hostname / IP address of machine to ping
|
||||
* @param {boolean} ipv6 Should IPv6 be used?
|
||||
* @param {number} size Size of ping packet to send
|
||||
* @param {number} count Number of packets to send before stopping
|
||||
* @param {string} sourceAddr Source address for sending/receiving echo requests
|
||||
* @param {boolean} numeric If true, IP addresses will be output instead of symbolic hostnames
|
||||
* @param {number} size Size (in bytes) of echo request to send
|
||||
* @param {number} deadline Maximum time in seconds before ping stops, regardless of packets sent
|
||||
* @param {number} timeout Maximum time in seconds to wait for each response
|
||||
* @returns {Promise<number>} Time for ping in ms rounded to nearest integer
|
||||
*/
|
||||
exports.pingAsync = function (hostname, ipv6 = false, size = 56) {
|
||||
exports.pingAsync = function (
|
||||
destAddr,
|
||||
ipv6 = false,
|
||||
count = PING_COUNT_DEFAULT,
|
||||
sourceAddr = "",
|
||||
numeric = true,
|
||||
size = PING_PACKET_SIZE_DEFAULT,
|
||||
deadline = PING_DEADLINE_DEFAULT,
|
||||
timeout = PING_TIMEOUT_DEFAULT,
|
||||
) {
|
||||
return new Promise((resolve, reject) => {
|
||||
ping.promise.probe(hostname, {
|
||||
ping.promise.probe(destAddr, {
|
||||
v6: ipv6,
|
||||
min_reply: 1,
|
||||
deadline: 10,
|
||||
min_reply: count,
|
||||
sourceAddr: sourceAddr,
|
||||
numeric: numeric,
|
||||
packetSize: size,
|
||||
deadline: deadline,
|
||||
timeout: timeout
|
||||
}).then((res) => {
|
||||
// If ping failed, it will set field to unknown
|
||||
if (res.alive) {
|
||||
|
|
|
@ -1051,5 +1051,13 @@
|
|||
"RabbitMQ Password": "RabbitMQ Password",
|
||||
"rabbitmqHelpText": "To use the monitor, you will need to enable the Management Plugin in your RabbitMQ setup. For more information, please consult the {rabitmq_documentation}.",
|
||||
"SendGrid API Key": "SendGrid API Key",
|
||||
"Separate multiple email addresses with commas": "Separate multiple email addresses with commas"
|
||||
"Separate multiple email addresses with commas": "Separate multiple email addresses with commas",
|
||||
"pingCountLabel": "Max Packets",
|
||||
"pingCountDescription": "Number of packets to send before stopping",
|
||||
"pingNumericLabel": "Numeric Output",
|
||||
"pingNumericDescription": "If checked, IP addresses will be output instead of symbolic hostnames",
|
||||
"pingDeadlineLabel": "Max Duration",
|
||||
"pingDeadlineDescription": "Total time in seconds before ping stops, regardless of packets sent",
|
||||
"pingTimeoutLabel": "Response Timeout",
|
||||
"pingTimeoutDescription": "Maximum time in seconds to wait for each response"
|
||||
}
|
||||
|
|
|
@ -660,10 +660,48 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Ping packet size -->
|
||||
<!-- Max Packets / Count -->
|
||||
<div v-if="monitor.type === 'ping'" class="my-3">
|
||||
<label for="ping-count" class="form-label">{{ $t("pingCountLabel") }}</label>
|
||||
<input id="ping-count" v-model="monitor.ping_count" type="number" class="form-control" required :min="ping_count_min" :max="ping_count_max" step="1">
|
||||
<div class="form-text">
|
||||
{{ $t("pingCountDescription") }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Numeric Output -->
|
||||
<div v-if="monitor.type === 'ping'" class="my-3 form-check">
|
||||
<input id="ping_numeric" v-model="monitor.ping_numeric" type="checkbox" class="form-check-input" :checked="monitor.ping_numeric">
|
||||
<label class="form-check-label" for="ping_numeric">
|
||||
{{ $t("pingNumericLabel") }}
|
||||
</label>
|
||||
<div class="form-text">
|
||||
{{ $t("pingNumericDescription") }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Packet size -->
|
||||
<div v-if="monitor.type === 'ping'" class="my-3">
|
||||
<label for="packet-size" class="form-label">{{ $t("Packet Size") }}</label>
|
||||
<input id="packet-size" v-model="monitor.packetSize" type="number" class="form-control" required min="1" max="65500" step="1">
|
||||
<input id="packet-size" v-model="monitor.packetSize" type="number" class="form-control" required :min="packetSize_min" :max="packetSize_max" step="1">
|
||||
</div>
|
||||
|
||||
<!-- Max Duration / Deadline -->
|
||||
<div v-if="monitor.type === 'ping'" class="my-3">
|
||||
<label for="ping_deadline" class="form-label">{{ $t("pingDeadlineLabel") }}</label>
|
||||
<input id="ping_deadline" v-model="monitor.ping_deadline" type="number" class="form-control" required :min="ping_deadline_min" :max="ping_deadline_max" step="1">
|
||||
<div class="form-text">
|
||||
{{ $t("pingDeadlineDescription") }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Response Timeout -->
|
||||
<div v-if="monitor.type === 'ping'" class="my-3">
|
||||
<label for="ping_timeout" class="form-label">{{ $t("pingTimeoutLabel") }}</label>
|
||||
<input id="ping_timeout" v-model="monitor.ping_timeout" type="number" class="form-control" required :min="ping_timeout_min" :max="ping_timeout_max" step="1">
|
||||
<div class="form-text">
|
||||
{{ $t("pingTimeoutDescription") }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- HTTP / Keyword only -->
|
||||
|
@ -1060,7 +1098,25 @@ import DockerHostDialog from "../components/DockerHostDialog.vue";
|
|||
import RemoteBrowserDialog from "../components/RemoteBrowserDialog.vue";
|
||||
import ProxyDialog from "../components/ProxyDialog.vue";
|
||||
import TagsManager from "../components/TagsManager.vue";
|
||||
import { genSecret, isDev, MAX_INTERVAL_SECOND, MIN_INTERVAL_SECOND, sleep } from "../util.ts";
|
||||
import {
|
||||
genSecret,
|
||||
isDev,
|
||||
MAX_INTERVAL_SECOND,
|
||||
MIN_INTERVAL_SECOND,
|
||||
sleep,
|
||||
PING_PACKET_SIZE_MIN,
|
||||
PING_PACKET_SIZE_MAX,
|
||||
PING_PACKET_SIZE_DEFAULT,
|
||||
PING_DEADLINE_MIN,
|
||||
PING_DEADLINE_MAX,
|
||||
PING_DEADLINE_DEFAULT,
|
||||
PING_COUNT_MIN,
|
||||
PING_COUNT_MAX,
|
||||
PING_COUNT_DEFAULT,
|
||||
PING_TIMEOUT_MIN,
|
||||
PING_TIMEOUT_MAX,
|
||||
PING_TIMEOUT_DEFAULT
|
||||
} from "../util.ts";
|
||||
import { hostNameRegexPattern } from "../util-frontend";
|
||||
import HiddenInput from "../components/HiddenInput.vue";
|
||||
import EditMonitorConditions from "../components/EditMonitorConditions.vue";
|
||||
|
@ -1082,7 +1138,6 @@ const monitorDefaults = {
|
|||
notificationIDList: {},
|
||||
ignoreTls: false,
|
||||
upsideDown: false,
|
||||
packetSize: 56,
|
||||
expiryNotification: false,
|
||||
maxredirects: 10,
|
||||
accepted_statuscodes: [ "200-299" ],
|
||||
|
@ -1133,6 +1188,14 @@ export default {
|
|||
return {
|
||||
minInterval: MIN_INTERVAL_SECOND,
|
||||
maxInterval: MAX_INTERVAL_SECOND,
|
||||
ping_count_min: PING_COUNT_MIN,
|
||||
ping_count_max: PING_COUNT_MAX,
|
||||
packetSize_min: PING_PACKET_SIZE_MIN,
|
||||
packetSize_max: PING_PACKET_SIZE_MAX,
|
||||
ping_deadline_min: PING_DEADLINE_MIN,
|
||||
ping_deadline_max: PING_DEADLINE_MAX,
|
||||
ping_timeout_min: PING_TIMEOUT_MIN,
|
||||
ping_timeout_max: PING_TIMEOUT_MAX,
|
||||
processing: false,
|
||||
monitor: {
|
||||
notificationIDList: {},
|
||||
|
@ -1564,7 +1627,12 @@ message HealthCheckResponse {
|
|||
if (this.isAdd) {
|
||||
|
||||
this.monitor = {
|
||||
...monitorDefaults
|
||||
...monitorDefaults,
|
||||
ping_count: PING_COUNT_DEFAULT,
|
||||
ping_numeric: true,
|
||||
packetSize: PING_PACKET_SIZE_DEFAULT,
|
||||
ping_deadline: PING_DEADLINE_DEFAULT,
|
||||
ping_timeout: PING_TIMEOUT_DEFAULT,
|
||||
};
|
||||
|
||||
if (this.$root.proxyList && !this.monitor.proxyId) {
|
||||
|
|
42
src/util.js
42
src/util.js
|
@ -8,17 +8,34 @@
|
|||
// Backend uses the compiled file util.js
|
||||
// Frontend uses util.ts
|
||||
*/
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
var _a;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.sleep = exports.flipStatus = exports.badgeConstants = exports.CONSOLE_STYLE_BgGray = exports.CONSOLE_STYLE_BgWhite = exports.CONSOLE_STYLE_BgCyan = exports.CONSOLE_STYLE_BgMagenta = exports.CONSOLE_STYLE_BgBlue = exports.CONSOLE_STYLE_BgYellow = exports.CONSOLE_STYLE_BgGreen = exports.CONSOLE_STYLE_BgRed = exports.CONSOLE_STYLE_BgBlack = exports.CONSOLE_STYLE_FgPink = exports.CONSOLE_STYLE_FgBrown = exports.CONSOLE_STYLE_FgViolet = exports.CONSOLE_STYLE_FgLightBlue = exports.CONSOLE_STYLE_FgLightGreen = exports.CONSOLE_STYLE_FgOrange = exports.CONSOLE_STYLE_FgGray = exports.CONSOLE_STYLE_FgWhite = exports.CONSOLE_STYLE_FgCyan = exports.CONSOLE_STYLE_FgMagenta = exports.CONSOLE_STYLE_FgBlue = exports.CONSOLE_STYLE_FgYellow = exports.CONSOLE_STYLE_FgGreen = exports.CONSOLE_STYLE_FgRed = exports.CONSOLE_STYLE_FgBlack = exports.CONSOLE_STYLE_Hidden = exports.CONSOLE_STYLE_Reverse = exports.CONSOLE_STYLE_Blink = exports.CONSOLE_STYLE_Underscore = exports.CONSOLE_STYLE_Dim = exports.CONSOLE_STYLE_Bright = exports.CONSOLE_STYLE_Reset = exports.MIN_INTERVAL_SECOND = exports.MAX_INTERVAL_SECOND = exports.SQL_DATETIME_FORMAT_WITHOUT_SECOND = exports.SQL_DATETIME_FORMAT = exports.SQL_DATE_FORMAT = exports.STATUS_PAGE_MAINTENANCE = exports.STATUS_PAGE_PARTIAL_DOWN = exports.STATUS_PAGE_ALL_UP = exports.STATUS_PAGE_ALL_DOWN = exports.MAINTENANCE = exports.PENDING = exports.UP = exports.DOWN = exports.appName = exports.isNode = exports.isDev = void 0;
|
||||
exports.evaluateJsonQuery = exports.intHash = exports.localToUTC = exports.utcToLocal = exports.utcToISODateTime = exports.isoToUTCDateTime = exports.parseTimeFromTimeObject = exports.parseTimeObject = exports.getMaintenanceRelativeURL = exports.getMonitorRelativeURL = exports.genSecret = exports.getCryptoRandomInt = exports.getRandomInt = exports.getRandomArbitrary = exports.TimeLogger = exports.polyfill = exports.log = exports.debug = exports.ucfirst = void 0;
|
||||
exports.intHash = exports.localToUTC = exports.utcToLocal = exports.utcToISODateTime = exports.isoToUTCDateTime = exports.parseTimeFromTimeObject = exports.parseTimeObject = exports.getMaintenanceRelativeURL = exports.getMonitorRelativeURL = exports.genSecret = exports.getCryptoRandomInt = exports.getRandomInt = exports.getRandomArbitrary = exports.TimeLogger = exports.polyfill = exports.log = exports.debug = exports.ucfirst = void 0;
|
||||
exports.CONSOLE_STYLE_FgPink = exports.CONSOLE_STYLE_FgBrown = exports.CONSOLE_STYLE_FgViolet = exports.CONSOLE_STYLE_FgLightBlue = exports.CONSOLE_STYLE_FgLightGreen = exports.CONSOLE_STYLE_FgOrange = exports.CONSOLE_STYLE_FgGray = exports.CONSOLE_STYLE_FgWhite = exports.CONSOLE_STYLE_FgCyan = exports.CONSOLE_STYLE_FgMagenta = exports.CONSOLE_STYLE_FgBlue = exports.CONSOLE_STYLE_FgYellow = exports.CONSOLE_STYLE_FgGreen = exports.CONSOLE_STYLE_FgRed = exports.CONSOLE_STYLE_FgBlack = exports.CONSOLE_STYLE_Hidden = exports.CONSOLE_STYLE_Reverse = exports.CONSOLE_STYLE_Blink = exports.CONSOLE_STYLE_Underscore = exports.CONSOLE_STYLE_Dim = exports.CONSOLE_STYLE_Bright = exports.CONSOLE_STYLE_Reset = exports.PING_TIMEOUT_DEFAULT = exports.PING_TIMEOUT_MAX = exports.PING_TIMEOUT_MIN = exports.PING_COUNT_DEFAULT = exports.PING_COUNT_MAX = exports.PING_COUNT_MIN = exports.PING_DEADLINE_DEFAULT = exports.PING_DEADLINE_MAX = exports.PING_DEADLINE_MIN = exports.PING_PACKET_SIZE_DEFAULT = exports.PING_PACKET_SIZE_MAX = exports.PING_PACKET_SIZE_MIN = exports.MIN_INTERVAL_SECOND = exports.MAX_INTERVAL_SECOND = exports.SQL_DATETIME_FORMAT_WITHOUT_SECOND = exports.SQL_DATETIME_FORMAT = exports.SQL_DATE_FORMAT = exports.STATUS_PAGE_MAINTENANCE = exports.STATUS_PAGE_PARTIAL_DOWN = exports.STATUS_PAGE_ALL_UP = exports.STATUS_PAGE_ALL_DOWN = exports.MAINTENANCE = exports.PENDING = exports.UP = exports.DOWN = exports.appName = exports.isNode = exports.isDev = void 0;
|
||||
exports.evaluateJsonQuery = exports.intHash = exports.localToUTC = exports.utcToLocal = exports.utcToISODateTime = exports.isoToUTCDateTime = exports.parseTimeFromTimeObject = exports.parseTimeObject = exports.getMaintenanceRelativeURL = 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.badgeConstants = exports.CONSOLE_STYLE_BgGray = exports.CONSOLE_STYLE_BgWhite = exports.CONSOLE_STYLE_BgCyan = exports.CONSOLE_STYLE_BgMagenta = exports.CONSOLE_STYLE_BgBlue = exports.CONSOLE_STYLE_BgYellow = exports.CONSOLE_STYLE_BgGreen = exports.CONSOLE_STYLE_BgRed = exports.CONSOLE_STYLE_BgBlack = void 0;
|
||||
const dayjs_1 = __importDefault(require("dayjs"));
|
||||
const dayjs = require("dayjs");
|
||||
const jsonata = require("jsonata");
|
||||
const jsonata = __importStar(require("jsonata"));
|
||||
exports.isDev = process.env.NODE_ENV === "development";
|
||||
exports.isNode = typeof process !== "undefined" && ((_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node);
|
||||
exports.appName = "Uptime Kuma";
|
||||
|
@ -35,6 +52,18 @@ exports.SQL_DATETIME_FORMAT = "YYYY-MM-DD HH:mm:ss";
|
|||
exports.SQL_DATETIME_FORMAT_WITHOUT_SECOND = "YYYY-MM-DD HH:mm";
|
||||
exports.MAX_INTERVAL_SECOND = 2073600;
|
||||
exports.MIN_INTERVAL_SECOND = 20;
|
||||
exports.PING_PACKET_SIZE_MIN = 1;
|
||||
exports.PING_PACKET_SIZE_MAX = 65500;
|
||||
exports.PING_PACKET_SIZE_DEFAULT = 56;
|
||||
exports.PING_DEADLINE_MIN = 0;
|
||||
exports.PING_DEADLINE_MAX = 300;
|
||||
exports.PING_DEADLINE_DEFAULT = 0;
|
||||
exports.PING_COUNT_MIN = 1;
|
||||
exports.PING_COUNT_MAX = 100;
|
||||
exports.PING_COUNT_DEFAULT = 3;
|
||||
exports.PING_TIMEOUT_MIN_TIMEOU = 0;
|
||||
exports.PING_TIMEOUT_MAX = 60;
|
||||
exports.PING_TIMEOUT_DEFAULT = 0;
|
||||
exports.CONSOLE_STYLE_Reset = "\x1b[0m";
|
||||
exports.CONSOLE_STYLE_Bright = "\x1b[1m";
|
||||
exports.CONSOLE_STYLE_Dim = "\x1b[2m";
|
||||
|
@ -66,7 +95,6 @@ exports.CONSOLE_STYLE_BgMagenta = "\x1b[45m";
|
|||
exports.CONSOLE_STYLE_BgCyan = "\x1b[46m";
|
||||
exports.CONSOLE_STYLE_BgWhite = "\x1b[47m";
|
||||
exports.CONSOLE_STYLE_BgGray = "\x1b[100m";
|
||||
|
||||
const consoleModuleColors = [
|
||||
exports.CONSOLE_STYLE_FgCyan,
|
||||
exports.CONSOLE_STYLE_FgGreen,
|
||||
|
@ -458,4 +486,4 @@ async function evaluateJsonQuery(data, jsonPath, jsonPathOperator, expectedValue
|
|||
throw new Error(`Error evaluating JSON query: ${err.message}. Response from server was: ${response}`);
|
||||
}
|
||||
}
|
||||
exports.evaluateJsonQuery = evaluateJsonQuery;
|
||||
exports.evaluateJsonQuery = evaluateJsonQuery;
|
||||
|
|
20
src/util.ts
20
src/util.ts
|
@ -39,6 +39,26 @@ export const SQL_DATETIME_FORMAT_WITHOUT_SECOND = "YYYY-MM-DD HH:mm";
|
|||
export const MAX_INTERVAL_SECOND = 2073600; // 24 days
|
||||
export const MIN_INTERVAL_SECOND = 20; // 20 seconds
|
||||
|
||||
// Packet Size limits
|
||||
export const PING_PACKET_SIZE_MIN = 1;
|
||||
export const PING_PACKET_SIZE_MAX = 65500;
|
||||
export const PING_PACKET_SIZE_DEFAULT = 56;
|
||||
|
||||
// Deadline limits (in seconds)
|
||||
export const PING_DEADLINE_MIN = 1;
|
||||
export const PING_DEADLINE_MAX = 300;
|
||||
export const PING_DEADLINE_DEFAULT = 10;
|
||||
|
||||
// Ping count limits
|
||||
export const PING_COUNT_MIN = 1;
|
||||
export const PING_COUNT_MAX = 100;
|
||||
export const PING_COUNT_DEFAULT = 1;
|
||||
|
||||
// Timeout limits (in seconds)
|
||||
export const PING_TIMEOUT_MIN = 1;
|
||||
export const PING_TIMEOUT_MAX = 60;
|
||||
export const PING_TIMEOUT_DEFAULT = 2;
|
||||
|
||||
// Console colors
|
||||
// https://stackoverflow.com/questions/9781218/how-to-change-node-jss-console-font-color
|
||||
export const CONSOLE_STYLE_Reset = "\x1b[0m";
|
||||
|
|
Loading…
Reference in a new issue