mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-20 18:55:49 +08:00
Add Websocket path to mqtt monitor for WebSocket connection (#6009)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lupaulus <20111917+lupaulus@users.noreply.github.com>
This commit is contained in:
@@ -71,6 +71,7 @@
|
||||
"locally configured mail transfer agent": "locally configured mail transfer agent",
|
||||
"Either enter the hostname of the server you want to connect to or localhost if you intend to use a locally configured mail transfer agent": "Either enter the hostname of the server you want to connect to or {localhost} if you intend to use a {local_mta}",
|
||||
"Port": "Port",
|
||||
"Path": "Path",
|
||||
"Heartbeat Interval": "Heartbeat Interval",
|
||||
"Request Timeout": "Request Timeout",
|
||||
"timeoutAfter": "Timeout after {0} seconds",
|
||||
@@ -266,6 +267,10 @@
|
||||
"Current User": "Current User",
|
||||
"topic": "Topic",
|
||||
"topicExplanation": "MQTT topic to monitor",
|
||||
"mqttWebSocketPath": "MQTT WebSocket Path",
|
||||
"mqttWebsocketPathExplanation": "WebSocket path for MQTT over WebSocket connections (e.g., /mqtt)",
|
||||
"mqttWebsocketPathInvalid": "Please use a valid WebSocket Path format",
|
||||
"mqttHostnameTip": "Please use this format {hostnameFormat}",
|
||||
"successKeyword": "Success Keyword",
|
||||
"successKeywordExplanation": "MQTT Keyword that will be considered as success",
|
||||
"recent": "Recent",
|
||||
|
@@ -311,6 +311,13 @@
|
||||
required
|
||||
data-testid="hostname-input"
|
||||
>
|
||||
<div v-if="monitor.type === 'mqtt'" class="form-text">
|
||||
<i18n-t tag="p" keypath="mqttHostnameTip">
|
||||
<template #hostnameFormat>
|
||||
<code>[mqtt,ws,wss]://hostname</code>
|
||||
</template>
|
||||
</i18n-t>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Port -->
|
||||
@@ -483,6 +490,21 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="my-3">
|
||||
<label for="mqttWebsocketPath" class="form-label">{{ $t("mqttWebSocketPath") }}</label>
|
||||
<input
|
||||
v-if="/wss?:\/\/.+/.test(monitor.hostname)"
|
||||
id="mqttWebsocketPath"
|
||||
v-model="monitor.mqttWebsocketPath"
|
||||
type="text"
|
||||
class="form-control"
|
||||
>
|
||||
<input v-else type="text" class="form-control" disabled>
|
||||
<div class="form-text">
|
||||
{{ $t("mqttWebsocketPathExplanation") }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="my-3">
|
||||
<label for="mqttCheckType" class="form-label">MQTT {{ $t("Check Type") }}</label>
|
||||
<select id="mqttCheckType" v-model="monitor.mqttCheckType" class="form-select" required>
|
||||
@@ -1181,6 +1203,7 @@ const monitorDefaults = {
|
||||
mqttUsername: "",
|
||||
mqttPassword: "",
|
||||
mqttTopic: "",
|
||||
mqttWebsocketPath: "",
|
||||
mqttSuccessMessage: "",
|
||||
mqttCheckType: "keyword",
|
||||
authMethod: null,
|
||||
@@ -1845,6 +1868,16 @@ message HealthCheckResponse {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Validate MQTT WebSocket Path pattern if present
|
||||
if (this.monitor.type === "mqtt" && this.monitor.mqttWebsocketPath) {
|
||||
const pattern = /^\/[A-Za-z0-9-_&()*+]*$/;
|
||||
if (!pattern.test(this.monitor.mqttWebsocketPath)) {
|
||||
toast.error(this.$t("mqttWebsocketPathInvalid"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user