From 152c93e7d3b50519d640e70d3383f77d87e67ea4 Mon Sep 17 00:00:00 2001 From: Hemanth Date: Fri, 27 Jun 2025 22:30:33 +0530 Subject: [PATCH] added rtsp details --- server/model/monitor.js | 6 ++++++ server/monitor-types/rtsp.js | 18 +++++++++++++++--- server/server.js | 3 +++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index c1db77e8b..dbc365487 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -197,6 +197,12 @@ class Monitor extends BeanModel { kafkaProducerSaslOptions: JSON.parse(this.kafkaProducerSaslOptions), rabbitmqUsername: this.rabbitmqUsername, rabbitmqPassword: this.rabbitmqPassword, + rtspUsername: this.rtspUsername, + rtspPassword: this.rtspPassword, + rtspPath:this.rtspPath + + + }; } diff --git a/server/monitor-types/rtsp.js b/server/monitor-types/rtsp.js index bc4f57486..a52e40aa4 100644 --- a/server/monitor-types/rtsp.js +++ b/server/monitor-types/rtsp.js @@ -4,12 +4,24 @@ class RtspMonitorType { name = "rtsp"; /** - * @param {Object} monitor - monitor config containing rtspUrl and timeout + * @param {Object} monitor - monitor config containing hostname, port, username, password, path, and timeout * @param {Object} heartbeat - object to update with status and message */ async check(monitor, heartbeat) { - const url = monitor.rtspUrl; - const timeoutMs = (monitor.timeout || 10) * 1000; + const { rtsp_username, rtsp_password, hostname, port, rtsp_path, timeout } = monitor; + const timeoutMs = (timeout || 10) * 1000; + + // Construct the RTSP URL from individual components + let url = `rtsp://${hostname}:${port}${rtsp_path}`; + + // If username and password are provided, inject them into the URL + if (rtsp_username && rtsp_password !== undefined) { + const auth = `${rtsp_username}:${rtsp_password}@`; + const urlPattern = /^rtsp:\/\//; + + // Inject authentication details into URL (before host) + url = url.replace(urlPattern, `rtsp://${auth}`); + } heartbeat.status = DOWN; heartbeat.msg = "Starting RTSP stream check..."; diff --git a/server/server.js b/server/server.js index 5b2f41a2e..9a5042310 100644 --- a/server/server.js +++ b/server/server.js @@ -877,6 +877,9 @@ let needSetup = false; bean.rabbitmqPassword = monitor.rabbitmqPassword; bean.conditions = JSON.stringify(monitor.conditions); bean.manual_status = monitor.manual_status; + bean.rtspUsername=monitor.rtspUsername + bean.rtspPassword=monitor.rtspPassword + bean.rtspPath=monitor.path // ping advanced options bean.ping_numeric = monitor.ping_numeric;