|
|
|
|
@ -326,7 +326,6 @@
|
|
|
|
|
v-model="monitor.hostname"
|
|
|
|
|
type="text"
|
|
|
|
|
class="form-control"
|
|
|
|
|
:pattern="`${monitor.type === 'mqtt' ? mqttIpOrHostnameRegexPattern : ipOrHostnameRegexPattern}`"
|
|
|
|
|
required
|
|
|
|
|
data-testid="hostname-input"
|
|
|
|
|
>
|
|
|
|
|
@ -1329,7 +1328,9 @@ import {
|
|
|
|
|
MIN_INTERVAL_SECOND,
|
|
|
|
|
sleep,
|
|
|
|
|
} from "../util.ts";
|
|
|
|
|
import { hostNameRegexPattern, timeDurationFormatter } from "../util-frontend";
|
|
|
|
|
import { timeDurationFormatter } from "../util-frontend";
|
|
|
|
|
import isFQDN from "validator/lib/isFQDN";
|
|
|
|
|
import isIP from "validator/lib/isIP";
|
|
|
|
|
import HiddenInput from "../components/HiddenInput.vue";
|
|
|
|
|
import EditMonitorConditions from "../components/EditMonitorConditions.vue";
|
|
|
|
|
|
|
|
|
|
@ -1417,8 +1418,6 @@ export default {
|
|
|
|
|
acceptedWebsocketCodeOptions: [],
|
|
|
|
|
dnsresolvetypeOptions: [],
|
|
|
|
|
kafkaSaslMechanismOptions: [],
|
|
|
|
|
ipOrHostnameRegexPattern: hostNameRegexPattern(),
|
|
|
|
|
mqttIpOrHostnameRegexPattern: hostNameRegexPattern(true),
|
|
|
|
|
gameList: null,
|
|
|
|
|
connectionStringTemplates: {
|
|
|
|
|
"sqlserver": "Server=<hostname>,<port>;Database=<your database>;User Id=<your user id>;Password=<your password>;Encrypt=<true/false>;TrustServerCertificate=<Yes/No>;Connection Timeout=<int>",
|
|
|
|
|
@ -2083,6 +2082,58 @@ message HealthCheckResponse {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Validate hostname field input for various monitors
|
|
|
|
|
if ([ "mqtt", "dns", "port", "ping", "steam", "gamedig", "radius", "tailscale-ping", "smtp", "snmp" ].includes(this.monitor.type) && this.monitor.hostname) {
|
|
|
|
|
let hostname = this.monitor.hostname.trim();
|
|
|
|
|
|
|
|
|
|
if (this.monitor.type === "mqtt") {
|
|
|
|
|
hostname = hostname.replace(/^(mqtt|ws)s?:\/\//, "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.monitor.type === "dns" && isIP(hostname)) {
|
|
|
|
|
toast.error(this.$t("hostnameCannotBeIP"));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Wildcard is allowed only for DNS
|
|
|
|
|
if (!isFQDN(hostname, {
|
|
|
|
|
allow_wildcard: this.monitor.type === "dns",
|
|
|
|
|
require_tld: false,
|
|
|
|
|
allow_underscores: true,
|
|
|
|
|
allow_trailing_dot: true,
|
|
|
|
|
}) && !isIP(hostname)) {
|
|
|
|
|
if (this.monitor.type === "dns") {
|
|
|
|
|
toast.error(this.$t("invalidDNSHostname"));
|
|
|
|
|
} else {
|
|
|
|
|
toast.error(this.$t("invalidHostnameOrIP"));
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Validate URL field input for various monitors
|
|
|
|
|
if ([ "http", "keyword", "json-query", "websocket-upgrade", "real-browser" ].includes(this.monitor.type) && this.monitor.url) {
|
|
|
|
|
try {
|
|
|
|
|
const url = new URL(this.monitor.url);
|
|
|
|
|
// Browser can encode *.hostname.com to %2A.hostname.com
|
|
|
|
|
if (url.hostname.includes("*") || url.hostname.includes("%2A")) {
|
|
|
|
|
toast.error(this.$t("wildcardOnlyForDNS"));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (!isFQDN(url.hostname, {
|
|
|
|
|
require_tld: false,
|
|
|
|
|
allow_underscores: true,
|
|
|
|
|
allow_trailing_dot: true,
|
|
|
|
|
}) && !isIP(url.hostname)) {
|
|
|
|
|
toast.error(this.$t("invalidHostnameOrIP"));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} catch (err) {
|
|
|
|
|
toast.error(this.$t("invalidURL"));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|